lucene-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Vadim Kirilchuk (JIRA)" <>
Subject [jira] [Updated] (SOLR-2141) NullPointerException when using escapeSql function
Date Mon, 12 Nov 2012 14:23:13 GMT


Vadim Kirilchuk updated SOLR-2141:

    Attachment: dih-file.xml


I am facing this error too and it seems that something is broken in 4.x branch.

I am attaching two files which can help to reproduce the problem:
1) dih-config.xml
contains dih configuration which uses escapeSql function with outer entity parameter
2) dih-file.xml 
To create outer entity without any db related stuff i need to create it from file.
Note: YOU MUST CHANGE ABSOLUTE PATH TO THIS FILE IN dih-config.xml to correct one.

Ok, i can also shay the light on what happens under the hood:

The problem is in instances of VariableResolverImpl which are created every time anyone calls

First, it is called to create function namespaces which are cached in DocBuilder instance.

Then it is created when DocBuilder#doFullDump() is called.

Then subEntity tries to resolve its 'query' parameter which has escapeSql function, and escapeSql
function tries to resolve its param with the first VariableResolver which know nothing about
current context and outer entity values.

However all fails a little bit later, when EvaluatorBag#evaluate() is called:
List l = parseParams(expression, context.getVariableResolver());
        if (l.size() != 1) {
          throw new DataImportHandlerException(SEVERE, "'escapeSql' must have at least one
parameter ");
        String s = l.get(0).toString();
        return s.replaceAll

Here parseParams returns list with single VariableWrapper, but wrapper.toString returns null
because variable cant be resolved. And finally (ta-dam!) replaceAll method is called on null

don`t be confused with FileDataSource for first entity mixed up with Sql query for second
entity. Absense of sql datasource has no effect on this bug.

Thanks, it would be great if this bug will be fixed ASAP.

> NullPointerException when using escapeSql function
> --------------------------------------------------
>                 Key: SOLR-2141
>                 URL:
>             Project: Solr
>          Issue Type: Bug
>          Components: contrib - DataImportHandler
>    Affects Versions: 1.4.1
>         Environment: openjdk 1.6.0 b12
>            Reporter: Edward Rudd
>            Assignee: Koji Sekiguchi
>         Attachments: dih-config.xml, dih-file.xml, SOLR-2141-sample.patch
> I have two entities defined, nested in each other..
> <entity name="article" query="select category, subcategory from articles">
>    <entity name="other" query="select other from othertable where category='${dataimporter.functions.escapeSql(article.category)}'
>               AND subcategory='${dataimporter.functions.escapeSql(article.subcategory)}'">
>    </entity>
> </entity>
> Now, when I run that it bombs on any article where subcategory = '' (it's a NOT NULL
column so empty string is there)  If i do where subcategory!='' in the article query it works
fine (aside from not pulling in all of the articles).
> org.apache.solr.handler.dataimport.DataImportHandlerException: java.lang.NullPointerException
>         at org.apache.solr.handler.dataimport.DocBuilder.buildDocument(
>         at org.apache.solr.handler.dataimport.DocBuilder.buildDocument(
>         at org.apache.solr.handler.dataimport.DocBuilder.doFullDump(
>         at org.apache.solr.handler.dataimport.DocBuilder.execute(
>         at org.apache.solr.handler.dataimport.DataImporter.doFullImport(
>         at org.apache.solr.handler.dataimport.DataImporter.runCmd(
>         at org.apache.solr.handler.dataimport.DataImporter$
> Caused by: java.lang.NullPointerException
>         at org.apache.solr.handler.dataimport.EvaluatorBag$1.evaluate(
>         at org.apache.solr.handler.dataimport.EvaluatorBag$5.get(
>         at org.apache.solr.handler.dataimport.EvaluatorBag$5.get(
>         at org.apache.solr.handler.dataimport.VariableResolverImpl.resolve(
>         at org.apache.solr.handler.dataimport.TemplateString.fillTokens(
>         at org.apache.solr.handler.dataimport.TemplateString.replaceTokens(
>         at org.apache.solr.handler.dataimport.VariableResolverImpl.replaceTokens(
>         at org.apache.solr.handler.dataimport.SqlEntityProcessor.nextRow(
>         at org.apache.solr.handler.dataimport.EntityProcessorWrapper.nextRow(
>         at org.apache.solr.handler.dataimport.DocBuilder.buildDocument(
>         ... 6 more

This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see:

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message