Uploaded image for project: 'Oozie'
  1. Oozie
  2. OOZIE-3468

[build] Use modernizer plugin

    XMLWordPrintableJSON

    Details

    • Type: Improvement
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: trunk
    • Fix Version/s: 5.2.0
    • Component/s: build
    • Labels:
      None

      Description

      Recently I've opened a few jiras which suggested to use standard java classes instead of external libraries ( OOZIE-3463, OOZIE-3467). There is a tool which can find such technical depts: maven modernizer plugin.

      The usage is quite simple:

      $ mvn modernizer:modernizer
      ...
      [ERROR] /src/oozie/core/src/main/java/org/apache/oozie/StringBlob.java:88: Prefer java.lang.String.<init>(byte[], java.nio.charset.Charset)                                       
      [ERROR] /src/oozie/core/src/main/java/org/apache/oozie/StringBlob.java:122: Prefer java.nio.charset.StandardCharsets              
      [ERROR] /src/oozie/core/src/main/java/org/apache/oozie/servlet/V2ValidateServlet.java:85: Prefer java.nio.charset.StandardCharsets  
      [ERROR] /src/oozie/core/src/main/java/org/apache/oozie/servlet/V2ValidateServlet.java:92: Prefer java.nio.charset.StandardCharsets 
      [ERROR] /src/oozie/core/src/main/java/org/apache/oozie/servlet/V1JobsServlet.java:188: Prefer java.util.ArrayList<>()         
      [ERROR] /src/oozie/core/src/main/java/org/apache/oozie/servlet/JVMInfo.java:91: Prefer java.lang.StringBuilder                       
      [ERROR] /src/oozie/core/src/main/java/org/apache/oozie/servlet/JVMInfo.java:101: Prefer java.lang.StringBuilder                       
      [ERROR] /src/oozie/core/src/main/java/org/apache/oozie/servlet/JVMInfo.java:110: Prefer java.lang.StringBuilder                       
      [ERROR] /src/oozie/core/src/main/java/org/apache/oozie/servlet/JVMInfo.java:119: Prefer java.lang.StringBuilder                       
      [ERROR] /src/oozie/core/src/main/java/org/apache/oozie/servlet/VersionServlet.java:36: Prefer java.util.Collections.emptyList() 
      [ERROR] /src/oozie/core/src/main/java/org/apache/oozie/servlet/V1AdminServlet.java:49: Prefer java.util.Collections.emptyList() 
      ...
      

      There are several ways to use this plugin:

      1. Add the plugin to the root pom and let developers manually use this plugin. It's the simplest solution, but it will be easy to forget it.
      2. Add this to the precommit script similarly to findbugs and at least avoid to insert new code which uses old style API. Probably we will have the same problems like we have with findbugs, we will have lots of false positive warnings.
      3. Turn the plugin on by default and fail the compilation if it finds any problem. I think this is too strict.

      If we choose option 2 or 3 we should probably specify an ignore list, I don't think for instance that we really want to change all the new Long(10) code to Long.valueOf(10).

      By default this plugin checks the target java version (1.8 right now) but it's possible to specify 1.7 instead if we want to focus on those problems first. (It was not working for me without specifying the java version.)

       

        Attachments

        1. OOZIE-3468-01-wip.patch
          0.7 kB
          Andras Salamon
        2. OOZIE-3468-02-wip.patch
          5 kB
          Andras Salamon
        3. OOZIE-3468-03-wip.patch
          6 kB
          Andras Salamon
        4. OOZIE-3468-04.patch
          6 kB
          Andras Salamon
        5. OOZIE-3468-06.patch
          6 kB
          Andras Salamon
        6. OOZIE-3468-07.patch
          6 kB
          Andras Salamon

          Activity

            People

            • Assignee:
              asalamon74 Andras Salamon
              Reporter:
              asalamon74 Andras Salamon
            • Votes:
              0 Vote for this issue
              Watchers:
              5 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: