You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by ni...@apache.org on 2014/12/22 02:09:07 UTC
[3/3] camel git commit: CAMEL-8168 Fixed the issue that mina2 doesn't
unbind from the listening port
CAMEL-8168 Fixed the issue that mina2 doesn't unbind from the listening port
Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/4e4cc189
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/4e4cc189
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/4e4cc189
Branch: refs/heads/master
Commit: 4e4cc18929ae1e35515667d368be687d31930a93
Parents: 4dfdc84
Author: Willem Jiang <wi...@gmail.com>
Authored: Mon Dec 22 08:49:14 2014 +0800
Committer: Willem Jiang <wi...@gmail.com>
Committed: Mon Dec 22 09:08:30 2014 +0800
----------------------------------------------------------------------
.../apache/camel/component/mina2/Mina2Consumer.java | 10 +++++++++-
.../apache/camel/component/mina2/Mina2TcpTest.java | 15 +++++++++++++--
2 files changed, 22 insertions(+), 3 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/camel/blob/4e4cc189/components/camel-mina2/src/main/java/org/apache/camel/component/mina2/Mina2Consumer.java
----------------------------------------------------------------------
diff --git a/components/camel-mina2/src/main/java/org/apache/camel/component/mina2/Mina2Consumer.java b/components/camel-mina2/src/main/java/org/apache/camel/component/mina2/Mina2Consumer.java
index df85635..deea5b6 100644
--- a/components/camel-mina2/src/main/java/org/apache/camel/component/mina2/Mina2Consumer.java
+++ b/components/camel-mina2/src/main/java/org/apache/camel/component/mina2/Mina2Consumer.java
@@ -95,7 +95,15 @@ public class Mina2Consumer extends DefaultConsumer {
@Override
protected void doStop() throws Exception {
LOG.info("Unbinding from server address: {} using acceptor: {}", address, acceptor);
- acceptor.unbind(address);
+ // need to check if the address is IPV4 TCP all net work address
+ if (address instanceof InetSocketAddress) {
+ if ("0.0.0.0".equals(((InetSocketAddress)address).getAddress().getHostAddress())) {
+ acceptor.unbind(acceptor.getLocalAddresses());
+ }
+ } else {
+ acceptor.unbind(address);
+ }
+
super.doStop();
}
http://git-wip-us.apache.org/repos/asf/camel/blob/4e4cc189/components/camel-mina2/src/test/java/org/apache/camel/component/mina2/Mina2TcpTest.java
----------------------------------------------------------------------
diff --git a/components/camel-mina2/src/test/java/org/apache/camel/component/mina2/Mina2TcpTest.java b/components/camel-mina2/src/test/java/org/apache/camel/component/mina2/Mina2TcpTest.java
index f268a10..f9b1762 100644
--- a/components/camel-mina2/src/test/java/org/apache/camel/component/mina2/Mina2TcpTest.java
+++ b/components/camel-mina2/src/test/java/org/apache/camel/component/mina2/Mina2TcpTest.java
@@ -26,7 +26,18 @@ import org.junit.Test;
public class Mina2TcpTest extends BaseMina2Test {
@Test
- public void testMinaRoute() throws Exception {
+ public void testMinaRoute1() throws Exception {
+ MockEndpoint endpoint = getMockEndpoint("mock:result");
+ Object body = "Hello there!";
+ endpoint.expectedBodiesReceived(body);
+
+ template.sendBodyAndHeader(String.format("mina2:tcp://localhost:%1$s?sync=false&minaLogger=true", getPort()), body, "cheese", 123);
+
+ assertMockEndpointsSatisfied();
+ }
+
+ @Test
+ public void testMinaRoute2() throws Exception {
MockEndpoint endpoint = getMockEndpoint("mock:result");
Object body = "Hello there!";
endpoint.expectedBodiesReceived(body);
@@ -40,7 +51,7 @@ public class Mina2TcpTest extends BaseMina2Test {
return new RouteBuilder() {
public void configure() {
- from(String.format("mina2:tcp://localhost:%1$s?sync=false&minaLogger=true", getPort())).to("log:before?showAll=true").to("mock:result").to("log:after?showAll=true");
+ from(String.format("mina2:tcp://0.0.0.0:%1$s?sync=false&minaLogger=true", getPort())).to("log:before?showAll=true").to("mock:result").to("log:after?showAll=true");
}
};
}