[2/3] camel git commit: CAMEL-8241: Work around bug in commons-exec to get camel-exec to work on unix with java 8.
CAMEL-8241: Work around bug in commons-exec to get camel-exec to work on unix with java 8. Project: http://git-wip-us.apache.org/repos/asf/camel/repo Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/3942 Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/3942 Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/3942 Branch: refs/heads/camel-2.14.x Commit: 3942e6ff42b5c0018e0770f3f55e207b527c Parents: 0231cdc Author: Claus Ibsen davscl...@apache.org Authored: Sun Feb 22 11:51:21 2015 +0100 Committer: Claus Ibsen davscl...@apache.org Committed: Sun Feb 22 11:55:24 2015 +0100 -- .../component/exec/ExecDefaultExecutor.java | 45 +++ .../camel/component/exec/ExecEndpoint.java | 1 - .../camel/component/exec/ExecProducer.java | 9 +- .../exec/impl/DefaultExecCommandExecutor.java | 29 - .../camel/component/exec/ExecEndpointTest.java | 3 - .../component/exec/ExecJava8IssueTest.java | 119 +++ 6 files changed, 200 insertions(+), 6 deletions(-) -- http://git-wip-us.apache.org/repos/asf/camel/blob/3942/components/camel-exec/src/main/java/org/apache/camel/component/exec/ExecDefaultExecutor.java -- diff --git a/components/camel-exec/src/main/java/org/apache/camel/component/exec/ExecDefaultExecutor.java b/components/camel-exec/src/main/java/org/apache/camel/component/exec/ExecDefaultExecutor.java new file mode 100644 index 000..14df04e --- /dev/null +++ b/components/camel-exec/src/main/java/org/apache/camel/component/exec/ExecDefaultExecutor.java @@ -0,0 +1,45 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the License); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an AS IS BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.camel.component.exec; + +import java.io.File; +import java.io.IOException; +import java.util.Map; + +import org.apache.commons.exec.CommandLine; +import org.apache.commons.exec.DefaultExecutor; + +public class ExecDefaultExecutor extends DefaultExecutor { + +private transient Process process; + +public ExecDefaultExecutor() { +} + +@Override +protected Process launch(CommandLine command, MapString, String env, File dir) throws IOException { +process = super.launch(command, env, dir); +return process; +} + +public int getExitValue() { +if (process != null !process.isAlive()) { +return process.exitValue(); +} +return 0; +} +} http://git-wip-us.apache.org/repos/asf/camel/blob/3942/components/camel-exec/src/main/java/org/apache/camel/component/exec/ExecEndpoint.java -- diff --git a/components/camel-exec/src/main/java/org/apache/camel/component/exec/ExecEndpoint.java b/components/camel-exec/src/main/java/org/apache/camel/component/exec/ExecEndpoint.java index 8851328..202ac70 100644 --- a/components/camel-exec/src/main/java/org/apache/camel/component/exec/ExecEndpoint.java +++ b/components/camel-exec/src/main/java/org/apache/camel/component/exec/ExecEndpoint.java @@ -61,7 +61,6 @@ public class ExecEndpoint extends DefaultEndpoint { super(uri, component); this.timeout = NO_TIMEOUT; this.binding = new DefaultExecBinding(); -this.commandExecutor = new DefaultExecCommandExecutor(); } public Producer createProducer() throws Exception { http://git-wip-us.apache.org/repos/asf/camel/blob/3942/components/camel-exec/src/main/java/org/apache/camel/component/exec/ExecProducer.java -- diff --git a/components/camel-exec/src/main/java/org/apache/camel/component/exec/ExecProducer.java b/components/camel-exec/src/main/java/org/apache/camel/component/exec/ExecProducer.java index aa125d4..49e1457 100644 --- a/components/camel-exec/src/main/java/org/apache/camel/component/exec/ExecProducer.java +++ b/components/camel-exec/src/main/java/org/apache/camel/component/exec/ExecProducer.java @@ -17,6 +17,7 @@ package org.apache.camel.component.exec; import
[1/3] camel git commit: CAMEL-8241: Work around bug in commons-exec to get camel-exec to work on unix with java 8.
Repository: camel Updated Branches: refs/heads/camel-2.14.x 0231cdc24 - 0462bc13e refs/heads/master 55cc138ae - 4283b0598 CAMEL-8241: Work around bug in commons-exec to get camel-exec to work on unix with java 8. Project: http://git-wip-us.apache.org/repos/asf/camel/repo Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/4283b059 Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/4283b059 Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/4283b059 Branch: refs/heads/master Commit: 4283b05984ff7d6ca1dfc7e0103f950a4eb144c6 Parents: 55cc138 Author: Claus Ibsen davscl...@apache.org Authored: Sun Feb 22 11:54:32 2015 +0100 Committer: Claus Ibsen davscl...@apache.org Committed: Sun Feb 22 11:54:32 2015 +0100 -- .../java/org/apache/camel/component/exec/ExecProducer.java | 3 ++- .../camel/component/exec/impl/DefaultExecCommandExecutor.java | 6 -- 2 files changed, 2 insertions(+), 7 deletions(-) -- http://git-wip-us.apache.org/repos/asf/camel/blob/4283b059/components/camel-exec/src/main/java/org/apache/camel/component/exec/ExecProducer.java -- diff --git a/components/camel-exec/src/main/java/org/apache/camel/component/exec/ExecProducer.java b/components/camel-exec/src/main/java/org/apache/camel/component/exec/ExecProducer.java index 49e1457..04b3917 100644 --- a/components/camel-exec/src/main/java/org/apache/camel/component/exec/ExecProducer.java +++ b/components/camel-exec/src/main/java/org/apache/camel/component/exec/ExecProducer.java @@ -45,7 +45,8 @@ public class ExecProducer extends DefaultProducer { ExecCommandExecutor executor = endpoint.getCommandExecutor(); if (executor == null) { -executor = new DefaultExecCommandExecutor(exchange); +// create a new non-shared executor +executor = new DefaultExecCommandExecutor(); } log.info(Executing {}, execCommand); http://git-wip-us.apache.org/repos/asf/camel/blob/4283b059/components/camel-exec/src/main/java/org/apache/camel/component/exec/impl/DefaultExecCommandExecutor.java -- diff --git a/components/camel-exec/src/main/java/org/apache/camel/component/exec/impl/DefaultExecCommandExecutor.java b/components/camel-exec/src/main/java/org/apache/camel/component/exec/impl/DefaultExecCommandExecutor.java index 33cf6a2..4ca391d 100644 --- a/components/camel-exec/src/main/java/org/apache/camel/component/exec/impl/DefaultExecCommandExecutor.java +++ b/components/camel-exec/src/main/java/org/apache/camel/component/exec/impl/DefaultExecCommandExecutor.java @@ -51,12 +51,6 @@ public class DefaultExecCommandExecutor implements ExecCommandExecutor { private static final Logger LOG = LoggerFactory.getLogger(DefaultExecCommandExecutor.class); -private final Exchange exchange; - -public DefaultExecCommandExecutor(Exchange exchange) { -this.exchange = exchange; -} - public ExecResult execute(ExecCommand command) { notNull(command, command);
[3/3] camel git commit: CAMEL-8241: Work around bug in commons-exec to get camel-exec to work on unix with java 8.
CAMEL-8241: Work around bug in commons-exec to get camel-exec to work on unix with java 8. Project: http://git-wip-us.apache.org/repos/asf/camel/repo Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/55cc138a Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/55cc138a Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/55cc138a Branch: refs/heads/master Commit: 55cc138ae9ebb9751846698fa44ac8e7683f3963 Parents: 3d98b30 Author: Claus Ibsen davscl...@apache.org Authored: Sun Feb 22 11:51:21 2015 +0100 Committer: Claus Ibsen davscl...@apache.org Committed: Sun Feb 22 11:51:21 2015 +0100 -- .../component/exec/ExecDefaultExecutor.java | 45 +++ .../camel/component/exec/ExecEndpoint.java | 1 - .../camel/component/exec/ExecProducer.java | 9 +- .../exec/impl/DefaultExecCommandExecutor.java | 29 - .../camel/component/exec/ExecEndpointTest.java | 3 - .../component/exec/ExecJava8IssueTest.java | 119 +++ 6 files changed, 200 insertions(+), 6 deletions(-) -- http://git-wip-us.apache.org/repos/asf/camel/blob/55cc138a/components/camel-exec/src/main/java/org/apache/camel/component/exec/ExecDefaultExecutor.java -- diff --git a/components/camel-exec/src/main/java/org/apache/camel/component/exec/ExecDefaultExecutor.java b/components/camel-exec/src/main/java/org/apache/camel/component/exec/ExecDefaultExecutor.java new file mode 100644 index 000..14df04e --- /dev/null +++ b/components/camel-exec/src/main/java/org/apache/camel/component/exec/ExecDefaultExecutor.java @@ -0,0 +1,45 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the License); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an AS IS BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.camel.component.exec; + +import java.io.File; +import java.io.IOException; +import java.util.Map; + +import org.apache.commons.exec.CommandLine; +import org.apache.commons.exec.DefaultExecutor; + +public class ExecDefaultExecutor extends DefaultExecutor { + +private transient Process process; + +public ExecDefaultExecutor() { +} + +@Override +protected Process launch(CommandLine command, MapString, String env, File dir) throws IOException { +process = super.launch(command, env, dir); +return process; +} + +public int getExitValue() { +if (process != null !process.isAlive()) { +return process.exitValue(); +} +return 0; +} +} http://git-wip-us.apache.org/repos/asf/camel/blob/55cc138a/components/camel-exec/src/main/java/org/apache/camel/component/exec/ExecEndpoint.java -- diff --git a/components/camel-exec/src/main/java/org/apache/camel/component/exec/ExecEndpoint.java b/components/camel-exec/src/main/java/org/apache/camel/component/exec/ExecEndpoint.java index dd2196e..d1c7f1c 100644 --- a/components/camel-exec/src/main/java/org/apache/camel/component/exec/ExecEndpoint.java +++ b/components/camel-exec/src/main/java/org/apache/camel/component/exec/ExecEndpoint.java @@ -73,7 +73,6 @@ public class ExecEndpoint extends DefaultEndpoint { super(uri, component); this.timeout = NO_TIMEOUT; this.binding = new DefaultExecBinding(); -this.commandExecutor = new DefaultExecCommandExecutor(); } public Producer createProducer() throws Exception { http://git-wip-us.apache.org/repos/asf/camel/blob/55cc138a/components/camel-exec/src/main/java/org/apache/camel/component/exec/ExecProducer.java -- diff --git a/components/camel-exec/src/main/java/org/apache/camel/component/exec/ExecProducer.java b/components/camel-exec/src/main/java/org/apache/camel/component/exec/ExecProducer.java index aa125d4..49e1457 100644 --- a/components/camel-exec/src/main/java/org/apache/camel/component/exec/ExecProducer.java +++ b/components/camel-exec/src/main/java/org/apache/camel/component/exec/ExecProducer.java @@ -17,6 +17,7 @@ package org.apache.camel.component.exec; import
camel git commit: CAMEL-8241: Work around bug in commons-exec to get camel-exec to work on unix with java 8.
Repository: camel Updated Branches: refs/heads/camel-2.14.x 4125e9d86 - 4314959d5 CAMEL-8241: Work around bug in commons-exec to get camel-exec to work on unix with java 8. Project: http://git-wip-us.apache.org/repos/asf/camel/repo Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/4314959d Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/4314959d Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/4314959d Branch: refs/heads/camel-2.14.x Commit: 4314959d5fb60b5709d8bbebf42dd93b8858c387 Parents: 4125e9d Author: Claus Ibsen davscl...@apache.org Authored: Mon Feb 23 07:58:40 2015 +0100 Committer: Claus Ibsen davscl...@apache.org Committed: Mon Feb 23 07:58:40 2015 +0100 -- .../org/apache/camel/component/exec/ExecDefaultExecutor.java | 2 +- .../org/apache/camel/component/exec/ExecJava8IssueTest.java | 8 ++-- 2 files changed, 7 insertions(+), 3 deletions(-) -- http://git-wip-us.apache.org/repos/asf/camel/blob/4314959d/components/camel-exec/src/main/java/org/apache/camel/component/exec/ExecDefaultExecutor.java -- diff --git a/components/camel-exec/src/main/java/org/apache/camel/component/exec/ExecDefaultExecutor.java b/components/camel-exec/src/main/java/org/apache/camel/component/exec/ExecDefaultExecutor.java index 14df04e..753af19 100644 --- a/components/camel-exec/src/main/java/org/apache/camel/component/exec/ExecDefaultExecutor.java +++ b/components/camel-exec/src/main/java/org/apache/camel/component/exec/ExecDefaultExecutor.java @@ -31,7 +31,7 @@ public class ExecDefaultExecutor extends DefaultExecutor { } @Override -protected Process launch(CommandLine command, MapString, String env, File dir) throws IOException { +protected Process launch(CommandLine command, Map env, File dir) throws IOException { process = super.launch(command, env, dir); return process; } http://git-wip-us.apache.org/repos/asf/camel/blob/4314959d/components/camel-exec/src/test/java/org/apache/camel/component/exec/ExecJava8IssueTest.java -- diff --git a/components/camel-exec/src/test/java/org/apache/camel/component/exec/ExecJava8IssueTest.java b/components/camel-exec/src/test/java/org/apache/camel/component/exec/ExecJava8IssueTest.java index 5fa78d4..c9cdb24 100644 --- a/components/camel-exec/src/test/java/org/apache/camel/component/exec/ExecJava8IssueTest.java +++ b/components/camel-exec/src/test/java/org/apache/camel/component/exec/ExecJava8IssueTest.java @@ -103,10 +103,14 @@ public class ExecJava8IssueTest extends Assert { * Creates a script which will append world to a file */ private void writeScript(File script) throws IOException { -try (FileWriter fw = new FileWriter(script); - PrintWriter pw = new PrintWriter(fw)) { +FileWriter fw = new FileWriter(script); +try { +PrintWriter pw = new PrintWriter(fw); String s = echo \ world\ $1; pw.print(s); +} finally { +fw.flush(); +fw.close(); } }