Details

    • Type: Sub-task
    • Status: Closed
    • Priority: Minor
    • Resolution: Implemented
    • Affects Version/s: Trunk
    • Fix Version/s: Upcoming Release
    • Component/s: base
    • Labels:
      None

      Description

      FileLoader.java:30, SE_NO_SERIALVERSIONID,

      SnVI: org.apache.ofbiz.base.config.FileLoader is Serializable; consider declaring a serialVersionUID

      This class implements the Serializable interface, but does not define a serialVersionUID field. A change as simple as adding a reference to a .class object will add synthetic fields to the class, which will unfortunately change the implicit serialVersionUID (e.g., adding a reference to String.class will generate a static field class$java$lang$String). Also, different source code to bytecode compilers may use different naming conventions for synthetic variables generated for references to class objects or inner classes. To ensure interoperability of Serializable across versions, consider adding an explicit serialVersionUID.

      MainResourceHandler.java:-1, CI_CONFUSED_INHERITANCE,

      CI: Class org.apache.ofbiz.base.config.MainResourceHandler is final but declares protected field org.apache.ofbiz.base.config.MainResourceHandler.xmlFilename

      This class is declared to be final, but declares fields to be protected. Since the class is final, it can not be derived from, and the use of protected is confusing. The access modifier for the field should be changed to private or public to represent the true use for the field.

      MainResourceHandler.java:-1, CI_CONFUSED_INHERITANCE,

      CI: Class org.apache.ofbiz.base.config.MainResourceHandler is final but declares protected field org.apache.ofbiz.base.config.MainResourceHandler.location

      This class is declared to be final, but declares fields to be protected. Since the class is final, it can not be derived from, and the use of protected is confusing. The access modifier for the field should be changed to private or public to represent the true use for the field.

      MainResourceHandler.java:-1, CI_CONFUSED_INHERITANCE,

      CI: Class org.apache.ofbiz.base.config.MainResourceHandler is final but declares protected field org.apache.ofbiz.base.config.MainResourceHandler.loaderName

      This class is declared to be final, but declares fields to be protected. Since the class is final, it can not be derived from, and the use of protected is confusing. The access modifier for the field should be changed to private or public to represent the true use for the field.

      MainResourceHandler.java:37, SE_NO_SERIALVERSIONID,

      SnVI: org.apache.ofbiz.base.config.MainResourceHandler is Serializable; consider declaring a serialVersionUID

      This class implements the Serializable interface, but does not define a serialVersionUID field. A change as simple as adding a reference to a .class object will add synthetic fields to the class, which will unfortunately change the implicit serialVersionUID (e.g., adding a reference to String.class will generate a static field class$java$lang$String). Also, different source code to bytecode compilers may use different naming conventions for synthetic variables generated for references to class objects or inner classes. To ensure interoperability of Serializable across versions, consider adding an explicit serialVersionUID.

      ResourceLoader.java:159, REC_CATCH_EXCEPTION,

      REC: Exception is caught when Exception is not thrown in org.apache.ofbiz.base.config.ResourceLoader.makeLoader(Element)

      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 ... }

      UrlLoader.java:30, SE_NO_SERIALVERSIONID,

      SnVI: org.apache.ofbiz.base.config.UrlLoader is Serializable; consider declaring a serialVersionUID

      This class implements the Serializable interface, but does not define a serialVersionUID field. A change as simple as adding a reference to a .class object will add synthetic fields to the class, which will unfortunately change the implicit serialVersionUID (e.g., adding a reference to String.class will generate a static field class$java$lang$String). Also, different source code to bytecode compilers may use different naming conventions for synthetic variables generated for references to class objects or inner classes. To ensure interoperability of Serializable across versions, consider adding an explicit serialVersionUID.

      1. OFBIZ-9566.patch
        9 kB
        Tobias Laufkötter

        Activity

        Hide
        jacques.le.roux Jacques Le Roux added a comment -

        Tobias, we crossed on wire. I think it's good to be said in Jira, but I did not put in the comment since finally no action.

        Show
        jacques.le.roux Jacques Le Roux added a comment - Tobias, we crossed on wire. I think it's good to be said in Jira, but I did not put in the comment since finally no action.
        Hide
        jacques.le.roux Jacques Le Roux added a comment -

        Hi Tobias,

        Your patch is in trunk at revision: 1804639.

        Please consider giving more information about the proceeded changes when possible (cf commit comment), thanks

        Show
        jacques.le.roux Jacques Le Roux added a comment - Hi Tobias, Your patch is in trunk at revision: 1804639. Please consider giving more information about the proceeded changes when possible (cf commit comment), thanks
        Hide
        tlaufkoetter Tobias Laufkötter added a comment -

        please read http://markmail.org/message/x7r34bss3fwy2bn3 (backward)

        That's why I chose to ignore the FindBugs warning. Would it be better to just leave it out of the report?

        Show
        tlaufkoetter Tobias Laufkötter added a comment - please read http://markmail.org/message/x7r34bss3fwy2bn3 (backward) That's why I chose to ignore the FindBugs warning. Would it be better to just leave it out of the report?
        Hide
        jacques.le.roux Jacques Le Roux added a comment -

        Tobias,

        About

        I chose to catch the explicitly thrown exceptions for ResourceLoader.java:159, REC_CATCH_EXCEPTION, because I share FindBug's opinion. I would still like to have some input on this, in case it really was intentional and needs to be this way.

        I agree with FindBug's and your opinion. I guess most of the time it's only lazyness or haste. It's much easier now with multi exceptions catch so should not be an excuse.

        Show
        jacques.le.roux Jacques Le Roux added a comment - Tobias, About I chose to catch the explicitly thrown exceptions for ResourceLoader.java:159, REC_CATCH_EXCEPTION, because I share FindBug's opinion. I would still like to have some input on this, in case it really was intentional and needs to be this way. I agree with FindBug's and your opinion. I guess most of the time it's only lazyness or haste. It's much easier now with multi exceptions catch so should not be an excuse.
        Hide
        tlaufkoetter Tobias Laufkötter added a comment -

        Fixed the issue number in patch name.

        Show
        tlaufkoetter Tobias Laufkötter added a comment - Fixed the issue number in patch name.
        Hide
        jacques.le.roux Jacques Le Roux added a comment -

        Hi Tobias,

        About

        consider declaring a serialVersionUID

        please read http://markmail.org/message/x7r34bss3fwy2bn3 (backward)

        Show
        jacques.le.roux Jacques Le Roux added a comment - Hi Tobias, About consider declaring a serialVersionUID please read http://markmail.org/message/x7r34bss3fwy2bn3 (backward)
        Hide
        tlaufkoetter Tobias Laufkötter added a comment -
        • serialVersionUID was ignored.
        • The protected fields were set to private since the class is not extended anywhere. If they need to be accessed in the future, getter that return an unmodifiable version should be implemented (Collections.unmodifiableXXX).
        • I chose to catch the explicitly thrown exceptions for ResourceLoader.java:159, REC_CATCH_EXCEPTION, because I share FindBug's opinion. I would still like to have some input on this, in case it really was intentional and needs to be this way.
        Show
        tlaufkoetter Tobias Laufkötter added a comment - serialVersionUID was ignored. The protected fields were set to private since the class is not extended anywhere. If they need to be accessed in the future, getter that return an unmodifiable version should be implemented ( Collections.unmodifiableXXX ). I chose to catch the explicitly thrown exceptions for ResourceLoader.java:159, REC_CATCH_EXCEPTION , because I share FindBug's opinion. I would still like to have some input on this, in case it really was intentional and needs to be this way.

          People

          • Assignee:
            jacques.le.roux Jacques Le Roux
            Reporter:
            tlaufkoetter Tobias Laufkötter
          • Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development