[
https://issues.apache.org/jira/browse/CAMEL-11595?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16507432#comment-16507432
]
ASF GitHub Bot commented on CAMEL-11595:
----------------------------------------
aldettinger closed pull request #2368: CAMEL-11595: Fixed the reader premature
closure by competing thread
URL: https://github.com/apache/camel/pull/2368
This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:
As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):
diff --git
a/components/camel-univocity-parsers/src/main/java/org/apache/camel/dataformat/univocity/AbstractUniVocityDataFormat.java
b/components/camel-univocity-parsers/src/main/java/org/apache/camel/dataformat/univocity/AbstractUniVocityDataFormat.java
index b4c8deec47f..8a7c4fa95f4 100644
---
a/components/camel-univocity-parsers/src/main/java/org/apache/camel/dataformat/univocity/AbstractUniVocityDataFormat.java
+++
b/components/camel-univocity-parsers/src/main/java/org/apache/camel/dataformat/univocity/AbstractUniVocityDataFormat.java
@@ -116,15 +116,13 @@ protected CPS initialValue() {
}
}
+ HeaderRowProcessor headerRowProcessor = new HeaderRowProcessor();
+ CPS settings = parserSettings.get();
+ settings.setProcessor(headerRowProcessor);
+ P parser = createParser(settings);
+ // univocity-parsers is responsible for closing the reader, even in
case of error
Reader reader = new InputStreamReader(stream,
getCharsetName(exchange));
- try {
- HeaderRowProcessor headerRowProcessor = new HeaderRowProcessor();
- CPS settings = parserSettings.get();
- settings.setRowProcessor(headerRowProcessor);
- return unmarshaller.unmarshal(reader, createParser(settings),
headerRowProcessor);
- } finally {
- reader.close();
- }
+ return unmarshaller.unmarshal(reader, parser, headerRowProcessor);
}
/**
diff --git
a/components/camel-univocity-parsers/src/main/java/org/apache/camel/dataformat/univocity/UniVocityFixedWidthDataFormat.java
b/components/camel-univocity-parsers/src/main/java/org/apache/camel/dataformat/univocity/UniVocityFixedWidthDataFormat.java
index e3a3d05d170..1f4a02837df 100644
---
a/components/camel-univocity-parsers/src/main/java/org/apache/camel/dataformat/univocity/UniVocityFixedWidthDataFormat.java
+++
b/components/camel-univocity-parsers/src/main/java/org/apache/camel/dataformat/univocity/UniVocityFixedWidthDataFormat.java
@@ -19,7 +19,7 @@
import java.io.Writer;
import java.util.LinkedHashMap;
-import com.univocity.parsers.fixed.FixedWidthFieldLengths;
+import com.univocity.parsers.fixed.FixedWidthFields;
import com.univocity.parsers.fixed.FixedWidthFormat;
import com.univocity.parsers.fixed.FixedWidthParser;
import com.univocity.parsers.fixed.FixedWidthParserSettings;
@@ -188,7 +188,7 @@ protected void configureFormat(FixedWidthFormat format) {
*
* @return new {@code FixedWidthFieldLengths} based on the header and
field lengthsl
*/
- private FixedWidthFieldLengths createFixedWidthFieldLengths() {
+ private FixedWidthFields createFixedWidthFieldLengths() {
// Ensure that the field lengths have been defined.
if (fieldLengths == null) {
throw new IllegalArgumentException("The fieldLengths must have
been defined in order to use the fixed-width format.");
@@ -196,7 +196,7 @@ private FixedWidthFieldLengths
createFixedWidthFieldLengths() {
// If there's no header then we only use their length
if (headers == null) {
- return new FixedWidthFieldLengths(fieldLengths);
+ return new FixedWidthFields(fieldLengths);
}
// Use both headers and field lengths (same size and no duplicate
headers)
@@ -210,7 +210,7 @@ private FixedWidthFieldLengths
createFixedWidthFieldLengths() {
if (fields.size() != headers.length) {
throw new IllegalArgumentException("The headers cannot have
duplicates in order to use the fixed-width format.");
}
- return new FixedWidthFieldLengths(fields);
+ return new FixedWidthFields(fields);
}
@Override
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
> camel-univocity-parsers - A number of stream closed exception in tests
> ----------------------------------------------------------------------
>
> Key: CAMEL-11595
> URL: https://issues.apache.org/jira/browse/CAMEL-11595
> Project: Camel
> Issue Type: Bug
> Components: tests
> Affects Versions: 2.21.1, 2.22.0
> Reporter: Claus Ibsen
> Assignee: Alex Dettinger
> Priority: Minor
> Fix For: 2.21.2, 2.22.0
>
>
> I wonder if we can look into these exceptions during these tests. It may be
> just that we need a nicer stop/cleanup of the test or something else.
> {code}
> [INFO] Running
> org.apache.camel.dataformat.univocity.UniVocityCsvDataFormatMarshalSpringTest
> [INFO] Tests run: 5, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 2.553
> s - in
> org.apache.camel.dataformat.univocity.UniVocityCsvDataFormatMarshalSpringTest
> [INFO] Running
> org.apache.camel.dataformat.univocity.UniVocityCsvDataFormatMarshalTest
> [INFO] Tests run: 5, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.822
> s - in org.apache.camel.dataformat.univocity.UniVocityCsvDataFormatMarshalTest
> [INFO] Running
> org.apache.camel.dataformat.univocity.UniVocityCsvDataFormatTest
> [INFO] Tests run: 18, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.346
> s - in org.apache.camel.dataformat.univocity.UniVocityCsvDataFormatTest
> [INFO] Running
> org.apache.camel.dataformat.univocity.UniVocityCsvDataFormatUnmarshalSpringTest
> Exception in thread "Character reading thread"
> java.lang.IllegalStateException: Error processing input
> at
> com.univocity.parsers.common.input.concurrent.ConcurrentCharLoader.run(ConcurrentCharLoader.java:92)
> at java.lang.Thread.run(Thread.java:748)
> Caused by: java.io.IOException: Stream closed
> at sun.nio.cs.StreamDecoder.ensureOpen(StreamDecoder.java:46)
> at sun.nio.cs.StreamDecoder.read(StreamDecoder.java:148)
> at java.io.InputStreamReader.read(InputStreamReader.java:184)
> at
> com.univocity.parsers.common.input.concurrent.CharBucket.fill(CharBucket.java:70)
> at
> com.univocity.parsers.common.input.concurrent.ConcurrentCharLoader.run(ConcurrentCharLoader.java:81)
> ... 1 more
> [INFO] Tests run: 5, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 2.669
> s - in
> org.apache.camel.dataformat.univocity.UniVocityCsvDataFormatUnmarshalSpringTest
> [INFO] Running
> org.apache.camel.dataformat.univocity.UniVocityCsvDataFormatUnmarshalTest
> Exception in thread "Character reading thread"
> java.lang.IllegalStateException: Error processing input
> at
> com.univocity.parsers.common.input.concurrent.ConcurrentCharLoader.run(ConcurrentCharLoader.java:92)
> at java.lang.Thread.run(Thread.java:748)
> Caused by: java.io.IOException: Stream closed
> at sun.nio.cs.StreamDecoder.ensureOpen(StreamDecoder.java:46)
> at sun.nio.cs.StreamDecoder.read(StreamDecoder.java:148)
> at java.io.InputStreamReader.read(InputStreamReader.java:184)
> at
> com.univocity.parsers.common.input.concurrent.CharBucket.fill(CharBucket.java:70)
> at
> com.univocity.parsers.common.input.concurrent.ConcurrentCharLoader.run(ConcurrentCharLoader.java:81)
> ... 1 more
> [INFO] Tests run: 5, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.84 s
> - in org.apache.camel.dataformat.univocity.UniVocityCsvDataFormatUnmarshalTest
> [INFO] Running
> org.apache.camel.dataformat.univocity.UniVocityFixedWidthDataFormatMarshalSpringTest
> [INFO] Tests run: 5, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 2.638
> s - in
> org.apache.camel.dataformat.univocity.UniVocityFixedWidthDataFormatMarshalSpringTest
> [INFO] Running
> org.apache.camel.dataformat.univocity.UniVocityFixedWidthDataFormatMarshalTest
> [INFO] Tests run: 5, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.826
> s - in
> org.apache.camel.dataformat.univocity.UniVocityFixedWidthDataFormatMarshalTest
> [INFO] Running
> org.apache.camel.dataformat.univocity.UniVocityFixedWidthDataFormatTest
> [INFO] Tests run: 22, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.344
> s - in org.apache.camel.dataformat.univocity.UniVocityFixedWidthDataFormatTest
> [INFO] Running
> org.apache.camel.dataformat.univocity.UniVocityFixedWidthDataFormatUnmarshalSpringTest
> Exception in thread "Character reading thread"
> java.lang.IllegalStateException: Error processing input
> at
> com.univocity.parsers.common.input.concurrent.ConcurrentCharLoader.run(ConcurrentCharLoader.java:92)
> at java.lang.Thread.run(Thread.java:748)
> Caused by: java.io.IOException: Stream closed
> at sun.nio.cs.StreamDecoder.ensureOpen(StreamDecoder.java:46)
> at sun.nio.cs.StreamDecoder.read(StreamDecoder.java:148)
> at java.io.InputStreamReader.read(InputStreamReader.java:184)
> at
> com.univocity.parsers.common.input.concurrent.CharBucket.fill(CharBucket.java:70)
> at
> com.univocity.parsers.common.input.concurrent.ConcurrentCharLoader.run(ConcurrentCharLoader.java:81)
> ... 1 more
> [INFO] Tests run: 5, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 2.715
> s - in
> org.apache.camel.dataformat.univocity.UniVocityFixedWidthDataFormatUnmarshalSpringTest
> [INFO] Running
> org.apache.camel.dataformat.univocity.UniVocityFixedWidthDataFormatUnmarshalTest
> Exception in thread "Character reading thread"
> java.lang.IllegalStateException: Error processing input
> at
> com.univocity.parsers.common.input.concurrent.ConcurrentCharLoader.run(ConcurrentCharLoader.java:92)
> at java.lang.Thread.run(Thread.java:748)
> Caused by: java.io.IOException: Stream closed
> at sun.nio.cs.StreamDecoder.ensureOpen(StreamDecoder.java:46)
> at sun.nio.cs.StreamDecoder.read(StreamDecoder.java:148)
> at java.io.InputStreamReader.read(InputStreamReader.java:184)
> at
> com.univocity.parsers.common.input.concurrent.CharBucket.fill(CharBucket.java:70)
> at
> com.univocity.parsers.common.input.concurrent.ConcurrentCharLoader.run(ConcurrentCharLoader.java:81)
> ... 1 more
> [INFO] Tests run: 5, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.837
> s - in
> org.apache.camel.dataformat.univocity.UniVocityFixedWidthDataFormatUnmarshalTest
> [INFO] Running
> org.apache.camel.dataformat.univocity.UniVocityTsvDataFormatMarshalSpringTest
> [INFO] Tests run: 5, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 2.609
> s - in
> org.apache.camel.dataformat.univocity.UniVocityTsvDataFormatMarshalSpringTest
> [INFO] Running
> org.apache.camel.dataformat.univocity.UniVocityTsvDataFormatMarshalTest
> [INFO] Tests run: 5, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.829
> s - in org.apache.camel.dataformat.univocity.UniVocityTsvDataFormatMarshalTest
> [INFO] Running
> org.apache.camel.dataformat.univocity.UniVocityTsvDataFormatTest
> [INFO] Tests run: 15, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.344
> s - in org.apache.camel.dataformat.univocity.UniVocityTsvDataFormatTest
> [INFO] Running
> org.apache.camel.dataformat.univocity.UniVocityTsvDataFormatUnmarshalSpringTest
> Exception in thread "Character reading thread"
> java.lang.IllegalStateException: Error processing input
> at
> com.univocity.parsers.common.input.concurrent.ConcurrentCharLoader.run(ConcurrentCharLoader.java:92)
> at java.lang.Thread.run(Thread.java:748)
> Caused by: java.io.IOException: Stream closed
> at sun.nio.cs.StreamDecoder.ensureOpen(StreamDecoder.java:46)
> at sun.nio.cs.StreamDecoder.read(StreamDecoder.java:148)
> at java.io.InputStreamReader.read(InputStreamReader.java:184)
> at
> com.univocity.parsers.common.input.concurrent.CharBucket.fill(CharBucket.java:70)
> at
> com.univocity.parsers.common.input.concurrent.ConcurrentCharLoader.run(ConcurrentCharLoader.java:81)
> ... 1 more
> [INFO] Tests run: 5, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 2.658
> s - in
> org.apache.camel.dataformat.univocity.UniVocityTsvDataFormatUnmarshalSpringTest
> [INFO] Running
> org.apache.camel.dataformat.univocity.UniVocityTsvDataFormatUnmarshalTest
> Exception in thread "Character reading thread"
> java.lang.IllegalStateException: Error processing input
> at
> com.univocity.parsers.common.input.concurrent.ConcurrentCharLoader.run(ConcurrentCharLoader.java:92)
> at java.lang.Thread.run(Thread.java:748)
> Caused by: java.io.IOException: Stream closed
> at sun.nio.cs.StreamDecoder.ensureOpen(StreamDecoder.java:46)
> at sun.nio.cs.StreamDecoder.read(StreamDecoder.java:148)
> at java.io.InputStreamReader.read(InputStreamReader.java:184)
> at
> com.univocity.parsers.common.input.concurrent.CharBucket.fill(CharBucket.java:70)
> at
> com.univocity.parsers.common.input.concurrent.ConcurrentCharLoader.run(ConcurrentCharLoader.java:81)
> ... 1 more
> [INFO] Tests run: 5, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.838
> s - in
> org.apache.camel.dataformat.univocity.UniVocityTsvDataFormatUnmarshalTest
> [INFO]
> {code}
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)