You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by da...@apache.org on 2020/08/06 04:18:22 UTC
[camel] branch master updated: Update FlatpackEndpoint.java (#4074)
This is an automated email from the ASF dual-hosted git repository.
davsclaus 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 fb3fe09 Update FlatpackEndpoint.java (#4074)
fb3fe09 is described below
commit fb3fe09f7acc940d9d3d6ca80c917f09ca17a8f0
Author: Shailendra Pandey <sh...@gmail.com>
AuthorDate: Thu Aug 6 09:47:59 2020 +0530
Update FlatpackEndpoint.java (#4074)
exchange.getIn().getMandatoryBody(Reader.class); was getting called twice in the case of DelimitedParser. And the BufferedReader is not getting closed the issue of this cause of file locking in the case of DelimitedParser.
---
.../java/org/apache/camel/component/flatpack/FlatpackEndpoint.java | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/components/camel-flatpack/src/main/java/org/apache/camel/component/flatpack/FlatpackEndpoint.java b/components/camel-flatpack/src/main/java/org/apache/camel/component/flatpack/FlatpackEndpoint.java
index 070baef..856af37 100644
--- a/components/camel-flatpack/src/main/java/org/apache/camel/component/flatpack/FlatpackEndpoint.java
+++ b/components/camel-flatpack/src/main/java/org/apache/camel/component/flatpack/FlatpackEndpoint.java
@@ -101,16 +101,18 @@ public class FlatpackEndpoint extends DefaultPollingEndpoint {
}
public Parser createParser(Exchange exchange) throws Exception {
- Reader bodyReader = exchange.getIn().getMandatoryBody(Reader.class);
+ Reader bodyReader = null;
try {
if (FlatpackType.fixed == type) {
+ bodyReader = exchange.getIn().getMandatoryBody(Reader.class);
return createFixedParser(resourceUri, bodyReader);
} else {
return createDelimitedParser(exchange);
}
} catch (Exception e) {
// must close reader in case of some exception
- IOHelper.close(bodyReader);
+ if(bodyReader != null)
+ IOHelper.close(bodyReader);
throw e;
}
}