Uploaded image for project: 'Spring Framework'
  1. Spring Framework
  2. SPR-17214

Compiled elvis operator does not work correctly when default value is a complex expression

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Minor
    • Resolution: Complete
    • Affects Version/s: 4.3.18, 5.0.8
    • Fix Version/s: 4.3.19, 5.0.9, 5.1 RC3
    • Component/s: Core:SpEL
    • Labels:
    • Last commented by a User:
      true

      Description

      Following exception raised when I execute "record.get('MR_dlEARFCN')?:record.put('MR_dlEARFCN',expression.dl_CarrierFreq?.longValue())"

      Caused by: java.lang.ArrayIndexOutOfBoundsException: -1
       at org.springframework.asm.Frame.merge(Frame.java:1501) ~[spring-core-5.0.8.RELEASE.jar:5.0.8.RELEASE]
       at org.springframework.asm.Frame.merge(Frame.java:1478) ~[spring-core-5.0.8.RELEASE.jar:5.0.8.RELEASE]
       at org.springframework.asm.MethodWriter.visitMaxs(MethodWriter.java:1520) ~[spring-core-5.0.8.RELEASE.jar:5.0.8.RELEASE]
       at org.springframework.expression.spel.standard.SpelCompiler.createExpressionClass(SpelCompiler.java:175) ~[spring-expression-5.0.8.RELEASE.jar:5.0.8.RELEASE]
       at org.springframework.expression.spel.standard.SpelCompiler.compile(SpelCompiler.java:104) ~[spring-expression-5.0.8.RELEASE.jar:5.0.8.RELEASE]
       at org.springframework.expression.spel.standard.SpelExpression.compileExpression(SpelExpression.java:517) ~[spring-expression-5.0.8.RELEASE.jar:5.0.8.RELEASE]
       at org.springframework.expression.spel.standard.SpelExpression.checkCompile(SpelExpression.java:487) ~[spring-expression-5.0.8.RELEASE.jar:5.0.8.RELEASE]
       at org.springframework.expression.spel.standard.SpelExpression.getValue(SpelExpression.java:372) ~[spring-expression-5.0.8.RELEASE.jar:5.0.8.RELEASE]
      

      If I change expression to "record.get('MR_dlEARFCN')==null?record.put('MR_dlEARFCN',expression.dl_CarrierFreq?.longValue()):null", the following exception is raised:

      Caused by: java.lang.IllegalStateException: Failed to instantiate CompiledExpression
       at org.springframework.expression.spel.standard.SpelCompiler.compile(SpelCompiler.java:110) ~[spring-expression-5.0.8.RELEASE.jar:5.0.8.RELEASE]
       at org.springframework.expression.spel.standard.SpelExpression.compileExpression(SpelExpression.java:517) ~[spring-expression-5.0.8.RELEASE.jar:5.0.8.RELEASE]
       at org.springframework.expression.spel.standard.SpelExpression.checkCompile(SpelExpression.java:487) ~[spring-expression-5.0.8.RELEASE.jar:5.0.8.RELEASE]
       at org.springframework.expression.spel.standard.SpelExpression.getValue(SpelExpression.java:372) ~[spring-expression-5.0.8.RELEASE.jar:5.0.8.RELEASE]
       ... 17 more
      Caused by: java.lang.VerifyError: (class: spel/Ex62, method: getValue signature: (Ljava/lang/Object;Lorg/springframework/expression/EvaluationContext;)Ljava/lang/Object;) Inconsistent stack height 1 != 0
       at java.lang.Class.getDeclaredConstructors0(Native Method) ~[?:1.8.0_121]
       at java.lang.Class.privateGetDeclaredConstructors(Class.java:2671) ~[?:1.8.0_121]
       at java.lang.Class.getConstructor0(Class.java:3075) ~[?:1.8.0_121]
       at java.lang.Class.getDeclaredConstructor(Class.java:2178) ~[?:1.8.0_121]
       at org.springframework.util.ReflectionUtils.accessibleConstructor(ReflectionUtils.java:503) ~[spring-core-5.0.8.RELEASE.jar:5.0.8.RELEASE]
       at org.springframework.expression.spel.standard.SpelCompiler.compile(SpelCompiler.java:107) ~[spring-expression-5.0.8.RELEASE.jar:5.0.8.RELEASE]
       at org.springframework.expression.spel.standard.SpelExpression.compileExpression(SpelExpression.java:517) ~[spring-expression-5.0.8.RELEASE.jar:5.0.8.RELEASE]
       at org.springframework.expression.spel.standard.SpelExpression.checkCompile(SpelExpression.java:487) ~[spring-expression-5.0.8.RELEASE.jar:5.0.8.RELEASE]
       at org.springframework.expression.spel.standard.SpelExpression.getValue(SpelExpression.java:372) ~[spring-expression-5.0.8.RELEASE.jar:5.0.8.RELEASE]
      

       
      I have to use "record.put('MR_dlEARFCN',record.get('MR_dlEARFCN')==null?expression.dl_CarrierFreq?.longValue():record.get('MR_dlEARFCN'))"  to make it work.

        Attachments

          Activity

            People

            • Assignee:
              aclement Andy Clement
              Reporter:
              heyouxian heyouxian
              Last updater:
              Spring Issuemaster
            • Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:
                Days since last comment:
                47 weeks, 1 day ago