Solr
  1. Solr
  2. SOLR-2463

Using an evaluator outside the scope of an entity results in a null context

    Details

    • Type: Bug Bug
    • Status: Open
    • Priority: Major Major
    • Resolution: Unresolved
    • Affects Version/s: 3.1.1, 3.5, 3.6, 3.6.1, 4.0-ALPHA
    • Fix Version/s: 3.1.1
    • Labels:
      None

      Description

      When using an Evaluator outside an entity element the Context argument is null.

      foo.LowerCaseFunctionEvaluator.java
      public class LowerCaseFunctionEvaluator extends Evaluator {
       public String evaluate(String expression, Context context) {
         List l = EvaluatorBag.parseParams(expression, context.getVariableResolver());
         
         if (l.size() != 1) {
           throw new RuntimeException("'toLowerCase' must have only one parameter ");
         }
      
         return l.get(0).toString().toLowerCase();
       }
      }
      
      data-config.xml
      <dataSource name="..."
                  type="..."
                  driver="..."
                  url="..."
                  user="${dataimporter.functions.toLowerCase('THIS_WILL_NOT_WORK')}"
                  password="..."/>
      
      data-config.xml
      <entity name="..."
              dataSource="..."
              query="select * from ${dataimporter.functions.toLowerCase('THIS_WILL_WORK')}"/>
      

      This use case worked in 1.4

        Issue Links

          Activity

          Robert Zotter made changes -
          Affects Version/s 3.6.1 [ 12320754 ]
          Affects Version/s 3.6 [ 12319065 ]
          Robert Zotter made changes -
          Link This issue is duplicated by SOLR-2899 [ SOLR-2899 ]
          Robert Zotter made changes -
          Affects Version/s 3.5 [ 12317876 ]
          Affects Version/s 3.1 [ 12314371 ]
          Priority Minor [ 4 ] Major [ 3 ]
          Frank Wesemann made changes -
          Link This issue is related to SOLR-2186 [ SOLR-2186 ]
          Shalin Shekhar Mangar made changes -
          Assignee Shalin Shekhar Mangar [ shalinmangar ]
          Robert Zotter made changes -
          Description When using an Evaluator outside an entity element the Context argument is null.

          {code:title=foo.LowerCaseFunctionEvaluator.java|borderStyle=solid}
          public class LowerCaseFunctionEvaluator extends Evaluator {
           public String evaluate(String expression, Context context) {
             List l = EvaluatorBag.parseParams(expression, context.getVariableResolver());
             if (l.size() != 1) {
               throw new RuntimeException("'toLowerCase' must have only one parameter ");
             }

             return l.get(0).toString().toLowerCase();
           }
          }
          {code}

          {code:title=data-config.xml|borderStyle=solid}
          <dataSource name="..."
                      type="..."
                      driver="..."
                      url="..."
                      user="${dataimporter.functions.toLowerCase('THIS_WILL_NOT_WORK')}"
                      password="..."/>
          {code}

          {code:title=data-config.xml|borderStyle=solid}
          <entity name="..."
                  dataSource="..."
                  query="select * from ${dataimporter.functions.toLowerCase('THIS_WILL_WORK')}"/>
          {code}

          This use case worked in 1.4
          When using an Evaluator outside an entity element the Context argument is null.

          {code:title=foo.LowerCaseFunctionEvaluator.java|borderStyle=solid}
          public class LowerCaseFunctionEvaluator extends Evaluator {
           public String evaluate(String expression, Context context) {
             List l = EvaluatorBag.parseParams(expression, context.getVariableResolver());
             
             if (l.size() != 1) {
               throw new RuntimeException("'toLowerCase' must have only one parameter ");
             }

             return l.get(0).toString().toLowerCase();
           }
          }
          {code}

          {code:title=data-config.xml|borderStyle=solid}
          <dataSource name="..."
                      type="..."
                      driver="..."
                      url="..."
                      user="${dataimporter.functions.toLowerCase('THIS_WILL_NOT_WORK')}"
                      password="..."/>
          {code}

          {code:title=data-config.xml|borderStyle=solid}
          <entity name="..."
                  dataSource="..."
                  query="select * from ${dataimporter.functions.toLowerCase('THIS_WILL_WORK')}"/>
          {code}

          This use case worked in 1.4
          Robert Zotter made changes -
          Fix Version/s 3.1.1 [ 12316257 ]
          Robert Zotter made changes -
          Description When using an Evaluator outside an entity element the Context argument is null.

          {code:title=foo.LowerCaseFunctionEvaluator.java|borderStyle=solid}
          public class LowerCaseFunctionEvaluator extends Evaluator {
           public String evaluate(String expression, Context context) {
             List l = EvaluatorBag.parseParams(expression, context.getVariableResolver());
             if (l.size() != 1) {
               throw new RuntimeException("'toLowerCase' must have only one parameter ");
             }

             return l.get(0).toString().toLowerCase();
           }
          }
          {code}

          {code:title=data-config.xml|borderStyle=solid}
          <dataSource name="..."
                      type="..."
                      driver="..."
                      url="..."
                      user="${dataimporter.functions.toLowerCase('THIS_WILL_NOT_WORK')}"
                      password="..."/>
          {code}

          {code:title=data-config.xml|borderStyle=solid}
           <entity name="..."
                   dataSource="..."
                   query="select * from ${dataimporter.functions.toLowerCase('THIS_WILL_WORK')}"/>
          {code}
          When using an Evaluator outside an entity element the Context argument is null.

          {code:title=foo.LowerCaseFunctionEvaluator.java|borderStyle=solid}
          public class LowerCaseFunctionEvaluator extends Evaluator {
           public String evaluate(String expression, Context context) {
             List l = EvaluatorBag.parseParams(expression, context.getVariableResolver());
             if (l.size() != 1) {
               throw new RuntimeException("'toLowerCase' must have only one parameter ");
             }

             return l.get(0).toString().toLowerCase();
           }
          }
          {code}

          {code:title=data-config.xml|borderStyle=solid}
          <dataSource name="..."
                      type="..."
                      driver="..."
                      url="..."
                      user="${dataimporter.functions.toLowerCase('THIS_WILL_NOT_WORK')}"
                      password="..."/>
          {code}

          {code:title=data-config.xml|borderStyle=solid}
          <entity name="..."
                  dataSource="..."
                  query="select * from ${dataimporter.functions.toLowerCase('THIS_WILL_WORK')}"/>
          {code}

          This use case worked in 1.4
          Robert Zotter made changes -
          Field Original Value New Value
          Description When using an Evaluator outside an entity element the Context argument is null.

          public class LowerCaseFunctionEvaluator extends Evaluator {
           public String evaluate(String expression, Context context) {
             List l = EvaluatorBag.parseParams(expression, context.getVariableResolver());
             if (l.size() != 1) {
               throw new RuntimeException("'toLowerCase' must have only one parameter ");
             }

             return l.get(0).toString().toLowerCase();
           }
          }

          <dataSource name="..."
                        type="..."
                        driver="..."
                        url="..."
                        user="${dataimporter.functions.toLowerCase('THIS_WILL_NOT_WORK')}"
                        password="..."
                        batchSize="..."/>


           <entity name="..."
                      dataSource="..."
                      query="select * from ${dataimporter.functions.toLowerCase('THIS_WILL_WORK')}"
          When using an Evaluator outside an entity element the Context argument is null.

          {code:title=foo.LowerCaseFunctionEvaluator.java|borderStyle=solid}
          public class LowerCaseFunctionEvaluator extends Evaluator {
           public String evaluate(String expression, Context context) {
             List l = EvaluatorBag.parseParams(expression, context.getVariableResolver());
             if (l.size() != 1) {
               throw new RuntimeException("'toLowerCase' must have only one parameter ");
             }

             return l.get(0).toString().toLowerCase();
           }
          }
          {code}

          {code:title=data-config.xml|borderStyle=solid}
          <dataSource name="..."
                      type="..."
                      driver="..."
                      url="..."
                      user="${dataimporter.functions.toLowerCase('THIS_WILL_NOT_WORK')}"
                      password="..."/>
          {code}

          {code:title=data-config.xml|borderStyle=solid}
           <entity name="..."
                   dataSource="..."
                   query="select * from ${dataimporter.functions.toLowerCase('THIS_WILL_WORK')}"/>
          {code}
          Robert Zotter created issue -

            People

            • Assignee:
              Shalin Shekhar Mangar
              Reporter:
              Robert Zotter
            • Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

              • Created:
                Updated:

                Development