Uploaded image for project: 'Commons OGNL (Dormant)'
  1. Commons OGNL (Dormant)
  2. OGNL-215

[PATCH] Use StringBuilder instead of StringBuffer, deprecate >=JDK1.5 conditionals and use CONSTANT.equals(variable).



    • Improvement
    • Status: Resolved
    • Minor
    • Resolution: Fixed
    • None
    • 4.0
    • None
    • None


      This patch replaces all StringBuffer references with StringBuilder for better performance. Improved performance has not been verified but it is fairly well established that StringBuilder performs better in single threaded use cases (see http://littletutorials.com/2008/07/16/stringbuffer-vs-stringbuilder-performance-comparison/). All JDK1.5 checking has also been deprecated/removed since OGNL is now dependent upon >=JDK1.5 these days. Lastly, all remaining variable.equals(CONSTANT) has been flipped to the null safe CONSTANT.equals(variable).

      A list of modified classes and changes are given here :-

      MenuItem: toString() now uses a chained StringBuilder instead of StringBuffer.

      StaticsAndConstructorsTest: use StringBuilder instead of StringBuffer.

      EnumerationPropertyAccessor: Test CONSTANT.equals(variable).

      ExpressionCompiler: Test CONSTANT.equals(variable).

      ASTMethod: Variable naming (don't use acronyms), remove OgnlRuntime.isJdk15() check.


      • Remove JDK1.5 checking since OGNL now requires >=JDK1.5.
      • The isJdk15() method is now deprecated.
      • Variable naming (don't use acronyms.
      • getPointerString(int) now uses StringBuilder instead of StringBuffer.
      • getUniqueDescriptor(Object, boolean) now uses StringBuilder instead of StringBuffer.
      • package private method findType() unused to removed.
      • Simplify getMethods(Class<?>,boolean) with ternary.
      • getStaticField(OgnlContext,String,String) test CONSTANT.equals(variable) and remove JDK1.5 conditionals.
      • A lot of variable naming!

      SetPropertyAccessor: Test CONSTANT.equals(variable) and simplify conditionals.

      ASTStaticField: Test CONSTANT.equals(variable), remove JDK1.5 conditionals and variable naming.

      MapPropertyAccessor: Simplify conditionals.

      ArrayPropertyAccessor: Test CONSTANT.equals(variable).

      IteratorPropertyAccessor: Test CONSTANT.equals(variable).

      OgnlOps: Use StringBuilder instead of StringBuffer.

      ognl.jjt: Variable naming, use StringBuilder instead of StringBuffer. Replace new String(stringBuffer) with stringBuffer.toString().

      Cheers, Adrian.


        1. patch-OGNL38.txt
          91 kB
          Adrian Cumiskey



            maurizio.cucchiara Maurizio Cucchiara
            acumiskey Adrian Cumiskey
            0 Vote for this issue
            0 Start watching this issue