This is an automated email from the ASF dual-hosted git repository.
aldettinger pushed a commit to branch camel-2.21.x
in repository https://gitbox.apache.org/repos/asf/camel.git
The following commit(s) were added to refs/heads/camel-2.21.x by this push:
new e0771ba CAMEL-11595: Fixed the reader premature closure by competing
threads
e0771ba is described below
commit e0771ba349f12903377ed13d0591bd822657ed67
Author: aldettinger <[email protected]>
AuthorDate: Sun Jun 10 13:59:28 2018 +0200
CAMEL-11595: Fixed the reader premature closure by competing threads
(cherry picked from commit cab92ad5d74014311901194a2a2a2d57cc1a0fcc)
---
.../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 5ba5494..621c104 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 c68daf7..b5ce57c 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
[email protected].