diff --git a/contrib/dataimporthandler/src/main/java/org/apache/solr/handler/dataimport/DocBuilder.java b/contrib/dataimporthandler/src/main/java/org/apache/solr/handler/dataimport/DocBuilder.java index 09fc694b498..eb57c4d5469 100644 --- a/contrib/dataimporthandler/src/main/java/org/apache/solr/handler/dataimport/DocBuilder.java +++ b/contrib/dataimporthandler/src/main/java/org/apache/solr/handler/dataimport/DocBuilder.java @@ -307,7 +307,6 @@ public class DocBuilder { ContextImpl ctx = new ContextImpl(entity, vr, null, pk == null ? Context.FULL_DUMP : Context.DELTA_DUMP, session, parentCtx, this); - vr.context = ctx; entityProcessor.init(ctx); if (requestParameters.start > 0) { @@ -347,7 +346,6 @@ public class DocBuilder { Map arow = entityProcessor.nextRow(); if (arow == null) { - entityProcessor.destroy(); break; } @@ -425,6 +423,7 @@ public class DocBuilder { if (verboseDebug) { writer.log(SolrWriter.END_ENTITY, null, null); } + entityProcessor.destroy(); } } @@ -587,7 +586,6 @@ public class DocBuilder { EntityProcessor entityProcessor = getEntityProcessor(entity); ContextImpl context1 = new ContextImpl(entity, resolver, null, Context.FIND_DELTA, session, null, this); - resolver.context = context1; entityProcessor.init(context1); Set> myModifiedPks = new HashSet>(); diff --git a/contrib/dataimporthandler/src/main/java/org/apache/solr/handler/dataimport/EntityProcessorWrapper.java b/contrib/dataimporthandler/src/main/java/org/apache/solr/handler/dataimport/EntityProcessorWrapper.java index 91920be126b..c72172eeef5 100644 --- a/contrib/dataimporthandler/src/main/java/org/apache/solr/handler/dataimport/EntityProcessorWrapper.java +++ b/contrib/dataimporthandler/src/main/java/org/apache/solr/handler/dataimport/EntityProcessorWrapper.java @@ -49,6 +49,8 @@ public class EntityProcessorWrapper extends EntityProcessor { protected List> rowcache; + private Context contextCopy; + public EntityProcessorWrapper(EntityProcessor delegate, DocBuilder docBuilder) { this.delegate = delegate; this.docBuilder = docBuilder; @@ -58,6 +60,9 @@ public class EntityProcessorWrapper extends EntityProcessor { rowcache = null; this.context = context; resolver = (VariableResolverImpl) context.getVariableResolver(); + //context has to be set correctly . keep the copy of the old one so that it can be restored in destroy + contextCopy = resolver.context; + resolver.context = context; if (entityName == null) { onError = resolver.replaceTokens(context.getEntityAttribute(ON_ERROR)); if (onError == null) onError = ABORT; @@ -255,6 +260,8 @@ public class EntityProcessorWrapper extends EntityProcessor { public void destroy() { delegate.destroy(); + resolver.context = contextCopy; + contextCopy = null; } @Override diff --git a/contrib/dataimporthandler/src/main/java/org/apache/solr/handler/dataimport/VariableResolverImpl.java b/contrib/dataimporthandler/src/main/java/org/apache/solr/handler/dataimport/VariableResolverImpl.java index 6e26a5df5f1..ac59916890e 100644 --- a/contrib/dataimporthandler/src/main/java/org/apache/solr/handler/dataimport/VariableResolverImpl.java +++ b/contrib/dataimporthandler/src/main/java/org/apache/solr/handler/dataimport/VariableResolverImpl.java @@ -37,7 +37,7 @@ public class VariableResolverImpl extends VariableResolver { /** * Used for creating Evaluators */ - ContextImpl context; + Context context; private final TemplateString templateString = new TemplateString();