Repository: camel Updated Branches: refs/heads/master 56eb9fe50 -> 80c85b6ba
CAMEL-10091: Camel-Git: Always check if Git instance is null in GitProducer before closing Project: http://git-wip-us.apache.org/repos/asf/camel/repo Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/4e31f233 Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/4e31f233 Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/4e31f233 Branch: refs/heads/master Commit: 4e31f23373d3019fa648ed41c4cac78a6852a62d Parents: 56eb9fe Author: Andrea Cosentino <anco...@gmail.com> Authored: Mon Jun 27 09:01:02 2016 +0200 Committer: Andrea Cosentino <anco...@gmail.com> Committed: Mon Jun 27 09:01:02 2016 +0200 ---------------------------------------------------------------------- .../apache/camel/component/git/producer/GitProducer.java | 8 ++++++-- .../camel/component/git/producer/GitProducerTest.java | 9 +++++++++ 2 files changed, 15 insertions(+), 2 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/camel/blob/4e31f233/components/camel-git/src/main/java/org/apache/camel/component/git/producer/GitProducer.java ---------------------------------------------------------------------- diff --git a/components/camel-git/src/main/java/org/apache/camel/component/git/producer/GitProducer.java b/components/camel-git/src/main/java/org/apache/camel/component/git/producer/GitProducer.java index a73deec..31e9ce8 100644 --- a/components/camel-git/src/main/java/org/apache/camel/component/git/producer/GitProducer.java +++ b/components/camel-git/src/main/java/org/apache/camel/component/git/producer/GitProducer.java @@ -174,7 +174,9 @@ public class GitProducer extends DefaultProducer { LOG.error("There was an error in Git " + operation + " operation"); throw e; } finally { - result.close(); + if (ObjectHelper.isNotEmpty(result)) { + result.close(); + } } } @@ -189,7 +191,9 @@ public class GitProducer extends DefaultProducer { LOG.error("There was an error in Git " + operation + " operation"); throw e; } finally { - result.close(); + if (ObjectHelper.isNotEmpty(result)) { + result.close(); + } } } http://git-wip-us.apache.org/repos/asf/camel/blob/4e31f233/components/camel-git/src/test/java/org/apache/camel/component/git/producer/GitProducerTest.java ---------------------------------------------------------------------- diff --git a/components/camel-git/src/test/java/org/apache/camel/component/git/producer/GitProducerTest.java b/components/camel-git/src/test/java/org/apache/camel/component/git/producer/GitProducerTest.java index 5a91654..a9000df 100755 --- a/components/camel-git/src/test/java/org/apache/camel/component/git/producer/GitProducerTest.java +++ b/components/camel-git/src/test/java/org/apache/camel/component/git/producer/GitProducerTest.java @@ -19,6 +19,7 @@ package org.apache.camel.component.git.producer; import java.io.File; import java.util.List; +import org.apache.camel.CamelExecutionException; import org.apache.camel.Exchange; import org.apache.camel.Processor; import org.apache.camel.builder.RouteBuilder; @@ -48,6 +49,14 @@ public class GitProducerTest extends GitTestSupport { assertEquals(gitDir.exists(), true); } + @Test(expected = CamelExecutionException.class) + public void doubleCloneOperationTest() throws Exception { + template.sendBody("direct:clone", ""); + template.sendBody("direct:clone", ""); + File gitDir = new File(gitLocalRepo, ".git"); + assertEquals(gitDir.exists(), true); + } + @Test public void addTest() throws Exception {