You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tika.apache.org by ta...@apache.org on 2018/06/14 20:49:08 UTC
[tika] 03/04: TIKA-2668 -- fix TaggedSAXException for Java 11-ea
This is an automated email from the ASF dual-hosted git repository.
tallison pushed a commit to branch branch_1x
in repository https://gitbox.apache.org/repos/asf/tika.git
commit f3099356527805426135987cb62353c9da24b573
Author: tballison <ta...@mitre.org>
AuthorDate: Thu Jun 14 12:45:20 2018 -0400
TIKA-2668 -- fix TaggedSAXException for Java 11-ea
---
.../org/apache/tika/sax/TaggedSAXException.java | 1 -
.../apache/tika/sax/BodyContentHandlerTest.java | 34 +++++++++++++++++++++-
2 files changed, 33 insertions(+), 2 deletions(-)
diff --git a/tika-core/src/main/java/org/apache/tika/sax/TaggedSAXException.java b/tika-core/src/main/java/org/apache/tika/sax/TaggedSAXException.java
index d2db72a..19b4ea8 100644
--- a/tika-core/src/main/java/org/apache/tika/sax/TaggedSAXException.java
+++ b/tika-core/src/main/java/org/apache/tika/sax/TaggedSAXException.java
@@ -38,7 +38,6 @@ public class TaggedSAXException extends SAXException {
*/
public TaggedSAXException(SAXException original, Object tag) {
super(original.getMessage(), original);
- initCause(original); // SAXException has it's own chaining mechanism!
this.tag = tag;
}
diff --git a/tika-core/src/test/java/org/apache/tika/sax/BodyContentHandlerTest.java b/tika-core/src/test/java/org/apache/tika/sax/BodyContentHandlerTest.java
index bf42706..c4acb03 100644
--- a/tika-core/src/test/java/org/apache/tika/sax/BodyContentHandlerTest.java
+++ b/tika-core/src/test/java/org/apache/tika/sax/BodyContentHandlerTest.java
@@ -20,15 +20,21 @@ import static java.nio.charset.StandardCharsets.UTF_8;
import static org.junit.Assert.assertEquals;
import java.io.ByteArrayOutputStream;
+import java.io.InputStream;
import java.io.OutputStream;
+import org.apache.tika.TikaTest;
import org.apache.tika.metadata.Metadata;
+import org.apache.tika.parser.AutoDetectParser;
+import org.apache.tika.parser.ParseContext;
+import org.apache.tika.parser.Parser;
+import org.apache.tika.parser.mock.MockParser;
import org.junit.Test;
/**
* Test cases for the {@link BodyContentHandler} class.
*/
-public class BodyContentHandlerTest {
+public class BodyContentHandlerTest extends TikaTest {
/**
* Test that the conversion to an {@link OutputStream} doesn't leave
@@ -49,4 +55,30 @@ public class BodyContentHandlerTest {
assertEquals("Test text\n", buffer.toString(UTF_8.name()));
}
+ @Test
+ public void testLimit() throws Exception {
+ //TIKA-2668 - java 11-ea
+ Parser p = new MockParser();
+ WriteOutContentHandler handler = new WriteOutContentHandler(15);
+ Metadata metadata = new Metadata();
+ ParseContext parseContext = new ParseContext();
+ Parser[] parsers = new Parser[1];
+ parsers[0] = p;
+ Parser autoDetectParser = new AutoDetectParser(parsers);
+ try (InputStream is = getResourceAsStream("/test-documents/example.xml")) {
+ autoDetectParser.parse(is, handler, metadata, parseContext);
+ } catch (Exception e) {
+ tryToFindIllegalStateException(e);
+ }
+ assertEquals("hello wo", handler.toString().trim());
+ }
+
+ private void tryToFindIllegalStateException(Throwable e) throws Exception {
+ if (e instanceof IllegalStateException) {
+ throw (Exception)e;
+ }
+ if (e.getCause() != null) {
+ tryToFindIllegalStateException(e.getCause());
+ }
+ }
}
--
To stop receiving notification emails like this one, please contact
tallison@apache.org.