mirror of https://github.com/apache/lucene.git
SOLR-2186 -- DataImportHandler's multi-threaded option throws NPE
git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1147023 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
2e14617e19
commit
80d436e29f
|
@ -18,20 +18,25 @@ package org.apache.solr.handler.dataimport;
|
|||
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
import org.w3c.dom.Document;
|
||||
import org.w3c.dom.Element;
|
||||
import org.xml.sax.InputSource;
|
||||
|
||||
import javax.xml.parsers.DocumentBuilder;
|
||||
import javax.xml.parsers.DocumentBuilderFactory;
|
||||
import javax.xml.transform.Transformer;
|
||||
import javax.xml.transform.TransformerFactory;
|
||||
import javax.xml.transform.dom.DOMSource;
|
||||
import javax.xml.transform.stream.StreamResult;
|
||||
import java.io.StringReader;
|
||||
import java.io.StringWriter;
|
||||
|
||||
/**Testcase for TikaEntityProcessor
|
||||
*
|
||||
* @since solr 1.5
|
||||
* @since solr 3.1
|
||||
*/
|
||||
public class TestTikaEntityProcessor extends AbstractDataImportHandlerTestCase {
|
||||
@BeforeClass
|
||||
public static void beforeClass() throws Exception {
|
||||
initCore("dataimport-solrconfig.xml", "dataimport-schema-no-unique-key.xml", getFile("solr-dihextras").getAbsolutePath());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testIndexingWithTikaEntityProcessor() throws Exception {
|
||||
String conf =
|
||||
private String conf =
|
||||
"<dataConfig>" +
|
||||
" <dataSource type=\"BinFileDataSource\"/>" +
|
||||
" <document>" +
|
||||
|
@ -42,12 +47,37 @@ public class TestTikaEntityProcessor extends AbstractDataImportHandlerTestCase {
|
|||
" </entity>" +
|
||||
" </document>" +
|
||||
"</dataConfig>";
|
||||
runFullImport(conf);
|
||||
assertQ(req("*:*")
|
||||
,"//*[@numFound='1']"
|
||||
|
||||
private String[] tests = {
|
||||
"//*[@numFound='1']"
|
||||
,"//str[@name='author'][.='Grant Ingersoll']"
|
||||
,"//str[@name='title'][.='solr-word']"
|
||||
,"//str[@name='text']"
|
||||
);
|
||||
};
|
||||
|
||||
|
||||
@BeforeClass
|
||||
public static void beforeClass() throws Exception {
|
||||
initCore("dataimport-solrconfig.xml", "dataimport-schema-no-unique-key.xml", getFile("solr-dihextras").getAbsolutePath());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testIndexingWithTikaEntityProcessor() throws Exception {
|
||||
runFullImport(conf);
|
||||
assertQ(req("*:*"), tests );
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testIndexingWithTikaEntityProcessorThreaded() throws Exception {
|
||||
DocumentBuilder builder = DocumentBuilderFactory.newInstance().newDocumentBuilder();
|
||||
Document doc = builder.parse(new InputSource(new StringReader(conf)));
|
||||
((Element) doc.getElementsByTagName("entity").item(0)).setAttribute("threads", "1");
|
||||
Transformer trans = TransformerFactory.newInstance().newTransformer();
|
||||
StringWriter writer = new StringWriter();
|
||||
trans.transform(new DOMSource(doc), new StreamResult(writer));
|
||||
|
||||
runFullImport(writer.toString());
|
||||
assertQ(req("*:*"), tests );
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -18,6 +18,7 @@ Bug Fixes
|
|||
----------------------
|
||||
* SOLR-2644: When using threads=2 the default logging is set too high (Bill Bell via shalin)
|
||||
* SOLR-2492: DIH does not commit if only deletes are processed (James Dyer via shalin)
|
||||
* SOLR-2186: DataImportHandler's multi-threaded option throws NPE (Lance Norskog, Frank Wesemann, shalin)
|
||||
|
||||
================== 3.3.0 ==================
|
||||
|
||||
|
|
|
@ -33,7 +33,7 @@ import java.util.concurrent.ConcurrentHashMap;
|
|||
* @since solr 1.3
|
||||
*/
|
||||
public class ContextImpl extends Context {
|
||||
private DataConfig.Entity entity;
|
||||
protected DataConfig.Entity entity;
|
||||
|
||||
private ContextImpl parent;
|
||||
|
||||
|
|
|
@ -28,7 +28,7 @@ public class ThreadedContext extends ContextImpl{
|
|||
|
||||
public ThreadedContext(DocBuilder.EntityRunner entityRunner, DocBuilder docBuilder) {
|
||||
super(entityRunner.entity,
|
||||
null,//to be fethed realtime
|
||||
null,//to be fetched realtime
|
||||
null,
|
||||
null,
|
||||
docBuilder.session,
|
||||
|
@ -75,7 +75,7 @@ public class ThreadedContext extends ContextImpl{
|
|||
@Override
|
||||
public String getResolvedEntityAttribute(String name) {
|
||||
checkLimited();
|
||||
return super.getResolvedEntityAttribute(name);
|
||||
return entity == null ? null : getVariableResolver().replaceTokens(entity.allAttributes.get(name));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
Loading…
Reference in New Issue