Details

      Description

      EntityQueryTestSuite.java:313, REC_CATCH_EXCEPTION

      • REC: Exception is caught when Exception is not thrown in org.apache.ofbiz.entity.test.EntityQueryTestSuite.testQueryIterator()

      This method uses a try-catch block that catches Exception objects, but Exception is not thrown within the try block, and RuntimeException is not explicitly caught. It is a common bug pattern to say try

      { ... } catch (Exception e) { something } as a shorthand for catching a number of types of exception each of whose catch blocks is identical, but this construct also accidentally catches RuntimeException as well, masking potential bugs.

      A better approach is to either explicitly catch the specific exceptions that are thrown, or to explicitly catch RuntimeException exception, rethrow it, and then catch all non-Runtime Exceptions, as shown below:

      try { ... } catch (RuntimeException e) { throw e; } catch (Exception e) { ... deal with all non-runtime exceptions ... }

      EntityQueryTestSuite.java:348, REC_CATCH_EXCEPTION
      - REC: Exception is caught when Exception is not thrown in org.apache.ofbiz.entity.test.EntityQueryTestSuite.testCursorForwardOnly()

      This method uses a try-catch block that catches Exception objects, but Exception is not thrown within the try block, and RuntimeException is not explicitly caught. It is a common bug pattern to say try { ... }

      catch (Exception e)

      { something } as a shorthand for catching a number of types of exception each of whose catch blocks is identical, but this construct also accidentally catches RuntimeException as well, masking potential bugs.

      A better approach is to either explicitly catch the specific exceptions that are thrown, or to explicitly catch RuntimeException exception, rethrow it, and then catch all non-Runtime Exceptions, as shown below:

      try { ... } catch (RuntimeException e) { throw e; } catch (Exception e) { ... deal with all non-runtime exceptions ... }

      EntityQueryTestSuite.java:383, REC_CATCH_EXCEPTION
      - REC: Exception is caught when Exception is not thrown in org.apache.ofbiz.entity.test.EntityQueryTestSuite.testCursorScrollSensitive()

      This method uses a try-catch block that catches Exception objects, but Exception is not thrown within the try block, and RuntimeException is not explicitly caught. It is a common bug pattern to say try { ... } catch (Exception e) { something }

      as a shorthand for catching a number of types of exception each of whose catch blocks is identical, but this construct also accidentally catches RuntimeException as well, masking potential bugs.

      A better approach is to either explicitly catch the specific exceptions that are thrown, or to explicitly catch RuntimeException exception, rethrow it, and then catch all non-Runtime Exceptions, as shown below:

      try

      { ... } catch (RuntimeException e) { throw e; } catch (Exception e) { ... deal with all non-runtime exceptions ... }

      EntityQueryTestSuite.java:418, REC_CATCH_EXCEPTION
      - REC: Exception is caught when Exception is not thrown in org.apache.ofbiz.entity.test.EntityQueryTestSuite.testCursorScrollInSensitive()

      This method uses a try-catch block that catches Exception objects, but Exception is not thrown within the try block, and RuntimeException is not explicitly caught. It is a common bug pattern to say try { ... } catch (Exception e) { something } as a shorthand for catching a number of types of exception each of whose catch blocks is identical, but this construct also accidentally catches RuntimeException as well, masking potential bugs.

      A better approach is to either explicitly catch the specific exceptions that are thrown, or to explicitly catch RuntimeException exception, rethrow it, and then catch all non-Runtime Exceptions, as shown below:

      try { ... }

      catch (RuntimeException e)

      { throw e; } catch (Exception e) { ... deal with all non-runtime exceptions ... }

      EntityTestSuite.java:462, DM_STRING_TOSTRING
      - Dm: org.apache.ofbiz.entity.test.EntityTestSuite.testCountViews() invokes toString() method on a String

      Calling String.toString() is just a redundant operation. Just use the String.

      EntityTestSuite.java:1201, SIC_INNER_SHOULD_BE_STATIC_ANON
      - SIC: The class org.apache.ofbiz.entity.test.EntityTestSuite$1 could be refactored into a named static inner class

      This class is an inner class, but does not use its embedded reference to the object which created it. This reference makes the instances of the class larger, and may keep the reference to the creator object alive longer than necessary. If possible, the class should be made into a static inner class. Since anonymous inner classes cannot be marked as static, doing this will require refactoring the inner class so that it is a named inner class.

      EntityTestSuite.java:1215, SIC_INNER_SHOULD_BE_STATIC_ANON
      - SIC: The class org.apache.ofbiz.entity.test.EntityTestSuite$2 could be refactored into a named static inner class

      This class is an inner class, but does not use its embedded reference to the object which created it. This reference makes the instances of the class larger, and may keep the reference to the creator object alive longer than necessary. If possible, the class should be made into a static inner class. Since anonymous inner classes cannot be marked as static, doing this will require refactoring the inner class so that it is a named inner class.

      EntityTestSuite.java:1260, REC_CATCH_EXCEPTION
      - REC: Exception is caught when Exception is not thrown in org.apache.ofbiz.entity.test.EntityTestSuite.testOneBigTransactionIsFasterThanSeveralSmallOnes()

      This method uses a try-catch block that catches Exception objects, but Exception is not thrown within the try block, and RuntimeException is not explicitly caught. It is a common bug pattern to say try { ... } catch (Exception e) { something } as a shorthand for catching a number of types of exception each of whose catch blocks is identical, but this construct also accidentally catches RuntimeException as well, masking potential bugs.

      A better approach is to either explicitly catch the specific exceptions that are thrown, or to explicitly catch RuntimeException exception, rethrow it, and then catch all non-Runtime Exceptions, as shown below:

      try { ... } catch (RuntimeException e) { throw e; }

      catch (Exception e)

      { ... deal with all non-runtime exceptions ... }

      EntityTestSuite.java:1263, DE_MIGHT_IGNORE

      • DE: org.apache.ofbiz.entity.test.EntityTestSuite.testOneBigTransactionIsFasterThanSeveralSmallOnes() might ignore java.lang.Exception

      This method might ignore an exception. In general, exceptions should be handled or reported in some way, or they should be thrown out of the method.

      EntityTestSuite.java:1314, SIC_INNER_SHOULD_BE_STATIC

      • SIC: Should org.apache.ofbiz.entity.test.EntityTestSuite$TestObserver be a static inner class?

      This class is an inner class, but does not use its embedded reference to the object which created it. This reference makes the instances of the class larger, and may keep the reference to the creator object alive longer than necessary. If possible, the class should be made static.

      EntityTestSuite.java:1320, URF_UNREAD_FIELD

      • UrF: Unread field: org.apache.ofbiz.entity.test.EntityTestSuite$TestObserver.observable

      This field is never read. Consider removing it from the class.

        Activity

        Hide
        jleichert Julian Leichert added a comment -

        All Classes

        • Catch(Exception) to multi-catch
        • minor Findbugs fixes
        Show
        jleichert Julian Leichert added a comment - All Classes Catch(Exception) to multi-catch minor Findbugs fixes
        Hide
        mbrohl Michael Brohl added a comment -

        Thanks Julian,

        your patch is in trunk r1812912.

        Show
        mbrohl Michael Brohl added a comment - Thanks Julian, your patch is in trunk r1812912.

          People

          • Assignee:
            mbrohl Michael Brohl
            Reporter:
            jleichert Julian Leichert
          • Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development