This is an automated email from the ASF dual-hosted git repository. aldettinger pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/camel.git
The following commit(s) were added to refs/heads/master by this push: new cab92ad CAMEL-11595: Fixed the reader premature closure by competing threads cab92ad is described below commit cab92ad5d74014311901194a2a2a2d57cc1a0fcc Author: aldettinger <aldettin...@gmail.com> AuthorDate: Sun Jun 10 13:59:28 2018 +0200 CAMEL-11595: Fixed the reader premature closure by competing threads --- .../dataformat/univocity/AbstractUniVocityDataFormat.java | 14 ++++++-------- .../univocity/UniVocityFixedWidthDataFormat.java | 8 ++++---- 2 files changed, 10 insertions(+), 12 deletions(-) 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 b4c8dee..8a7c4fa 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 @@ public abstract class AbstractUniVocityDataFormat<F extends Format, CWS extends } } + 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 e3a3d05..1f4a028 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 @@ package org.apache.camel.dataformat.univocity; 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 @@ public class UniVocityFixedWidthDataFormat extends AbstractUniVocityDataFormat<F * * @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 @@ public class UniVocityFixedWidthDataFormat extends AbstractUniVocityDataFormat<F // 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 @@ public class UniVocityFixedWidthDataFormat extends AbstractUniVocityDataFormat<F 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 -- To stop receiving notification emails like this one, please contact aldettin...@apache.org.