Lucene - Core
  1. Lucene - Core
  2. LUCENE-6193

Collapse identical catch branches in try-catch statements

    Details

    • Type: Task Task
    • Status: Closed
    • Priority: Trivial Trivial
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 5.1, 6.0
    • Component/s: None
    • Labels:
      None

      Description

      We are on Java 7+ so we can reduce verbosity by collapsing identical catch statements into one. We did the same for solr in SOLR-7014.

      1. LUCENE-6193.patch
        12 kB
        Shalin Shekhar Mangar

        Issue Links

          Activity

          Hide
          Shalin Shekhar Mangar added a comment -

          The only places where I did not make these changes are where the catch blocks have different comments or the code wasn't ASL.

          The following were excluded:

          1. org.apache.lucene.analysis.core.TestFactories
          2. org.apache.lucene.index.TestReaderClosed
          3. org.apache.lucene.queryparser.flexible.messages.NLS (one instance)
          4. org.egothor.stemmer.Diff (license different from ASL)
          5. org.tartarus.snowball.SnowballProgram (license different from ASL)
          Show
          Shalin Shekhar Mangar added a comment - The only places where I did not make these changes are where the catch blocks have different comments or the code wasn't ASL. The following were excluded: org.apache.lucene.analysis.core.TestFactories org.apache.lucene.index.TestReaderClosed org.apache.lucene.queryparser.flexible.messages.NLS (one instance) org.egothor.stemmer.Diff (license different from ASL) org.tartarus.snowball.SnowballProgram (license different from ASL)
          Hide
          ASF subversion and git services added a comment -

          Commit 1653707 from shalin@apache.org in branch 'dev/trunk'
          [ https://svn.apache.org/r1653707 ]

          LUCENE-6193: Collapse identical catch branches in try-catch statements

          Show
          ASF subversion and git services added a comment - Commit 1653707 from shalin@apache.org in branch 'dev/trunk' [ https://svn.apache.org/r1653707 ] LUCENE-6193 : Collapse identical catch branches in try-catch statements
          Hide
          ASF subversion and git services added a comment -

          Commit 1653709 from shalin@apache.org in branch 'dev/branches/branch_5x'
          [ https://svn.apache.org/r1653709 ]

          LUCENE-6193: Collapse identical catch branches in try-catch statements

          Show
          ASF subversion and git services added a comment - Commit 1653709 from shalin@apache.org in branch 'dev/branches/branch_5x' [ https://svn.apache.org/r1653709 ] LUCENE-6193 : Collapse identical catch branches in try-catch statements
          Hide
          Uwe Schindler added a comment -

          Hi,
          FYI: If you had in the past the multiple catch statements around reflection errors, all those exceptions have new superclass in Java 7: ReflectiveOperationException. This can sometimes simplify the code more! This applies in most cases around where you have stuff like ClassNotFoundException, IllegalAccessException, InstantiationException, InvocationTargetException, NoSuchFieldException, NoSuchMethodException, all handled by identical catch.

          Just catching ReflectiveOperationException around reflection access is in most cases all you need now.

          Show
          Uwe Schindler added a comment - Hi, FYI: If you had in the past the multiple catch statements around reflection errors, all those exceptions have new superclass in Java 7: ReflectiveOperationException. This can sometimes simplify the code more! This applies in most cases around where you have stuff like ClassNotFoundException, IllegalAccessException, InstantiationException, InvocationTargetException, NoSuchFieldException, NoSuchMethodException, all handled by identical catch. Just catching ReflectiveOperationException around reflection access is in most cases all you need now.
          Hide
          ASF subversion and git services added a comment -

          Commit 1653909 from shalin@apache.org in branch 'dev/trunk'
          [ https://svn.apache.org/r1653909 ]

          LUCENE-6193: Use ReflectiveOperationException to simplify catch clauses around reflection errors

          Show
          ASF subversion and git services added a comment - Commit 1653909 from shalin@apache.org in branch 'dev/trunk' [ https://svn.apache.org/r1653909 ] LUCENE-6193 : Use ReflectiveOperationException to simplify catch clauses around reflection errors
          Hide
          ASF subversion and git services added a comment -

          Commit 1653911 from shalin@apache.org in branch 'dev/branches/branch_5x'
          [ https://svn.apache.org/r1653911 ]

          LUCENE-6193: Use ReflectiveOperationException to simplify catch clauses around reflection errors

          Show
          ASF subversion and git services added a comment - Commit 1653911 from shalin@apache.org in branch 'dev/branches/branch_5x' [ https://svn.apache.org/r1653911 ] LUCENE-6193 : Use ReflectiveOperationException to simplify catch clauses around reflection errors
          Hide
          Shalin Shekhar Mangar added a comment -

          Thanks Uwe! I changed LockStressTest and JavascriptCompiler to use ReflectiveOperationException.

          Show
          Shalin Shekhar Mangar added a comment - Thanks Uwe! I changed LockStressTest and JavascriptCompiler to use ReflectiveOperationException.
          Hide
          Timothy Potter added a comment -

          Bulk close after 5.1 release

          Show
          Timothy Potter added a comment - Bulk close after 5.1 release

            People

            • Assignee:
              Shalin Shekhar Mangar
              Reporter:
              Shalin Shekhar Mangar
            • Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Development