Skip to content
This repository has been archived by the owner on Apr 11, 2024. It is now read-only.

Commit

Permalink
TIKA-2926 -- add property for container exception in RPW
Browse files Browse the repository at this point in the history
  • Loading branch information
tballison committed Aug 16, 2019
1 parent a0e87fb commit 67abff4
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
import org.apache.tika.parser.RecursiveParserWrapper;
import org.apache.tika.sax.AbstractRecursiveParserWrapperHandler;
import org.apache.tika.sax.BasicContentHandlerFactory;
import org.apache.tika.sax.RecursiveParserWrapperHandler;
import org.junit.Test;

public class RecursiveParserWrapperFSConsumerTest extends TikaTest {
Expand Down Expand Up @@ -130,7 +131,7 @@ queue, p, new BasicContentHandlerFactory(BasicContentHandlerFactory.HANDLER_TYPE
List<Metadata> results = JsonMetadataList.fromJson(new InputStreamReader(new ByteArrayInputStream(bytes), UTF_8));
assertEquals(2, results.size());
assertContains("another null pointer",
results.get(0).get(TikaCoreProperties.TIKA_META_EXCEPTION_PREFIX + "runtime"));
results.get(0).get(RecursiveParserWrapperHandler.CONTAINER_EXCEPTION));
assertEquals("Nikolai Lobachevsky", results.get(0).get("author"));
assertEquals("embeddedAuthor", results.get(1).get("author"));
assertContains("some_embedded_content", results.get(1).get(AbstractRecursiveParserWrapperHandler.TIKA_CONTENT));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ public void parse(InputStream stream, ContentHandler recursiveParserWrapperHandl
//try our best to record the problem in the metadata object
//then rethrow
String stackTrace = ExceptionUtils.getFilteredStackTrace(e);
metadata.add(TikaCoreProperties.TIKA_META_EXCEPTION_PREFIX+"runtime", stackTrace);
metadata.add(RecursiveParserWrapperHandler.CONTAINER_EXCEPTION, stackTrace);
throw e;
} finally {
long elapsedMillis = System.currentTimeMillis() - started;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,11 @@ public abstract class AbstractRecursiveParserWrapperHandler extends DefaultHandl
public final static Property EMBEDDED_RESOURCE_LIMIT_REACHED =
Property.internalBoolean(TikaCoreProperties.TIKA_META_EXCEPTION_PREFIX + "embedded_resource_limit_reached");

//exception in embedded file
public final static Property EMBEDDED_EXCEPTION = ParserUtils.EMBEDDED_EXCEPTION;

//exception in main file
public final static Property CONTAINER_EXCEPTION = Property.internalText(
TikaCoreProperties.TIKA_META_EXCEPTION_PREFIX+"runtime");
public final static Property EMBEDDED_RESOURCE_PATH =
Property.internalText(TikaCoreProperties.TIKA_META_PREFIX+"embedded_resource_path");

Expand Down

0 comments on commit 67abff4

Please sign in to comment.