Uploaded image for project: 'Commons JEXL'
  1. Commons JEXL
  2. JEXL-306

Ternary operator ? protects also its branches from resolution errors

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 3.1
    • 3.2
    • None

    Description

      Consider the following test case (suppose its added to IfTest)

          @Test
          public void testTernaryFail() throws Exception {
              JexlEvalContext jc = new JexlEvalContext();
              JexlExpression e = JEXL.createExpression("false ? bar : quux");
              Object o;
      
              jc.setStrict(true);
              jc.setSilent(false);
              try {
                 o = e.evaluate(jc);
                 Assert.fail("Should have failed");
              } catch (Exception ex) {
                 // OK
              }
          }
      

      The expected behavior is to fail with undefined variable... because neither bar nor quux is defined

      Attachments

        Activity

          People

            henrib Henri Biestro
            dmitri_blinov Dmitri Blinov
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: