From b7957d100dfd5c7e75beb171c5d544c465fda35b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=B8=89=E6=A8=B5?= Date: Sat, 19 Feb 2022 21:47:47 +0800 Subject: [PATCH 01/12] add simple test --- .../remoting/benchmark/BenchmarkServer.java | 2 +- .../simpledemo/QuickStartServerAndClient.java | 23 +++++++++++++++++++ .../remoting/simpledemo/SimpleRequest.java | 16 +++++++++++++ .../remoting/simpledemo/SimpleResponse.java | 15 ++++++++++++ .../simpledemo/SimpleUserProcessor.java | 19 +++++++++++++++ 5 files changed, 74 insertions(+), 1 deletion(-) create mode 100644 src/test/java/com/alipay/remoting/simpledemo/QuickStartServerAndClient.java create mode 100644 src/test/java/com/alipay/remoting/simpledemo/SimpleRequest.java create mode 100644 src/test/java/com/alipay/remoting/simpledemo/SimpleResponse.java create mode 100644 src/test/java/com/alipay/remoting/simpledemo/SimpleUserProcessor.java diff --git a/src/test/java/com/alipay/remoting/benchmark/BenchmarkServer.java b/src/test/java/com/alipay/remoting/benchmark/BenchmarkServer.java index e9705c33..eef121c0 100644 --- a/src/test/java/com/alipay/remoting/benchmark/BenchmarkServer.java +++ b/src/test/java/com/alipay/remoting/benchmark/BenchmarkServer.java @@ -32,4 +32,4 @@ public static void main(String[] args) { rpcServer.registerUserProcessor(new BenchmarkUserProcessor()); rpcServer.startup(); } -} +} \ No newline at end of file diff --git a/src/test/java/com/alipay/remoting/simpledemo/QuickStartServerAndClient.java b/src/test/java/com/alipay/remoting/simpledemo/QuickStartServerAndClient.java new file mode 100644 index 00000000..9702e449 --- /dev/null +++ b/src/test/java/com/alipay/remoting/simpledemo/QuickStartServerAndClient.java @@ -0,0 +1,23 @@ +package com.alipay.remoting.simpledemo; + +import com.alipay.remoting.exception.RemotingException; +import com.alipay.remoting.rpc.RpcClient; +import com.alipay.remoting.rpc.RpcServer; + +public class QuickStartServerAndClient { + public static void main(String[] args) throws RemotingException, InterruptedException { + RpcServer rpcServer = new RpcServer(9876); + rpcServer.registerUserProcessor(new SimpleUserProcessor()); + rpcServer.startup(); + + RpcClient rpcClient = new RpcClient(); + for (int i = 0; i < 10; i++) { + SimpleResponse response = (SimpleResponse) rpcClient.invokeSync("127.0.0.1:9876", new SimpleRequest(i), 1000); + System.out.println("i=" + i + " res=" + response.getRes()); + Thread.sleep(1000); + } + + rpcClient.shutdown(); + rpcServer.shutdown(); + } +} diff --git a/src/test/java/com/alipay/remoting/simpledemo/SimpleRequest.java b/src/test/java/com/alipay/remoting/simpledemo/SimpleRequest.java new file mode 100644 index 00000000..30dfbdda --- /dev/null +++ b/src/test/java/com/alipay/remoting/simpledemo/SimpleRequest.java @@ -0,0 +1,16 @@ +package com.alipay.remoting.simpledemo; + +import java.io.Serializable; + +public class SimpleRequest implements Serializable { + + private final int num; + + public SimpleRequest(int num) { + this.num = num; + } + + public int getNum() { + return num; + } +} diff --git a/src/test/java/com/alipay/remoting/simpledemo/SimpleResponse.java b/src/test/java/com/alipay/remoting/simpledemo/SimpleResponse.java new file mode 100644 index 00000000..b8ccf193 --- /dev/null +++ b/src/test/java/com/alipay/remoting/simpledemo/SimpleResponse.java @@ -0,0 +1,15 @@ +package com.alipay.remoting.simpledemo; + +import java.io.Serializable; + +public class SimpleResponse implements Serializable { + private int res; + + public SimpleResponse(int res) { + this.res = res; + } + + public int getRes() { + return res; + } +} diff --git a/src/test/java/com/alipay/remoting/simpledemo/SimpleUserProcessor.java b/src/test/java/com/alipay/remoting/simpledemo/SimpleUserProcessor.java new file mode 100644 index 00000000..438ed005 --- /dev/null +++ b/src/test/java/com/alipay/remoting/simpledemo/SimpleUserProcessor.java @@ -0,0 +1,19 @@ +package com.alipay.remoting.simpledemo; + +import com.alipay.remoting.AsyncContext; +import com.alipay.remoting.BizContext; +import com.alipay.remoting.rpc.protocol.AsyncUserProcessor; + +public class SimpleUserProcessor extends AsyncUserProcessor { + + @Override + public void handleRequest(BizContext bizCtx, AsyncContext asyncCtx, SimpleRequest request) { + int res = request.getNum() * request.getNum(); + asyncCtx.sendResponse(new SimpleResponse(res)); + } + + @Override + public String interest() { + return SimpleRequest.class.getName(); + } +} From ea817d326cd7d8c9333da1792395664eda484153 Mon Sep 17 00:00:00 2001 From: chuailiwu Date: Sat, 26 Feb 2022 19:17:12 +0800 Subject: [PATCH 02/12] modify log dependencies and a simple demo --- pom.xml | 13 ++++++++----- .../simpledemo/QuickStartServerAndClient.java | 1 + 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/pom.xml b/pom.xml index 7d126d3c..731e5956 100644 --- a/pom.xml +++ b/pom.xml @@ -82,8 +82,11 @@ UTF-8 1.7.21 + 2.17.1 + 3.4.4 1.0.12 2.4.0 + 4.13.1 @@ -116,31 +119,31 @@ junit junit - 4.13.1 + ${junit.version} test org.apache.logging.log4j log4j-api - 2.17.0 + ${log4j.version} test org.apache.logging.log4j log4j-core - 2.17.0 + ${log4j.version} test org.apache.logging.log4j log4j-slf4j-impl - 2.3 + ${log4j.version} test com.lmax disruptor - 3.2.0 + ${disruptor.verion} test diff --git a/src/test/java/com/alipay/remoting/simpledemo/QuickStartServerAndClient.java b/src/test/java/com/alipay/remoting/simpledemo/QuickStartServerAndClient.java index 9702e449..08541b38 100644 --- a/src/test/java/com/alipay/remoting/simpledemo/QuickStartServerAndClient.java +++ b/src/test/java/com/alipay/remoting/simpledemo/QuickStartServerAndClient.java @@ -11,6 +11,7 @@ public static void main(String[] args) throws RemotingException, InterruptedExce rpcServer.startup(); RpcClient rpcClient = new RpcClient(); + rpcClient.startup(); for (int i = 0; i < 10; i++) { SimpleResponse response = (SimpleResponse) rpcClient.invokeSync("127.0.0.1:9876", new SimpleRequest(i), 1000); System.out.println("i=" + i + " res=" + response.getRes()); From 11d10940554001440a7ac53475b9b1599229c5df Mon Sep 17 00:00:00 2001 From: chuailiwu Date: Sat, 26 Feb 2022 22:06:59 +0800 Subject: [PATCH 03/12] ipv6 parse --- .../alipay/remoting/rpc/RpcAddressParser.java | 40 +++--- .../remoting/rpc/RpcAddressParserTest.java | 114 ++++++++++++++++++ .../simpledemo/QuickStartServerAndClient.java | 21 +++- .../remoting/simpledemo/SimpleRequest.java | 16 +++ .../remoting/simpledemo/SimpleResponse.java | 16 +++ .../simpledemo/SimpleUserProcessor.java | 16 +++ 6 files changed, 207 insertions(+), 16 deletions(-) create mode 100644 src/test/java/com/alipay/remoting/rpc/RpcAddressParserTest.java diff --git a/src/main/java/com/alipay/remoting/rpc/RpcAddressParser.java b/src/main/java/com/alipay/remoting/rpc/RpcAddressParser.java index 2d32c5d4..26cee4d1 100644 --- a/src/main/java/com/alipay/remoting/rpc/RpcAddressParser.java +++ b/src/main/java/com/alipay/remoting/rpc/RpcAddressParser.java @@ -33,6 +33,7 @@ * *

Normal format example

*
127.0.0.1:12200?KEY1=VALUE1&KEY2=VALUE2
+ *
0:0:0:0:0:0:0:1:12200?KEY1=VALUE1&KEY2=VALUE2
* *

Illegal format example

*
@@ -61,30 +62,41 @@ public Url parse(String url) {
         if (null != parsedUrl) {
             return parsedUrl;
         }
+
         String ip = null;
         String port = null;
         Properties properties = null;
 
         int size = url.length();
         int pos = 0;
-        for (int i = 0; i < size; ++i) {
-            if (COLON == url.charAt(i)) {
-                ip = url.substring(pos, i);
-                pos = i;
-                // should not end with COLON
-                if (i == size - 1) {
-                    throw new IllegalArgumentException("Illegal format address string [" + url
-                                                       + "], should not end with COLON[:]! ");
-                }
+        int pathEndIdx = url.indexOf(QUES);
+        if (pathEndIdx < 0) {
+            pathEndIdx = size - 1;
+        } else {
+            pathEndIdx = pathEndIdx - 1;
+        }
+
+        int lastColon = -1;
+        for (int i = pathEndIdx; i >= 0; i--) {
+            if (url.charAt(i) == COLON) {
+                lastColon = i;
                 break;
             }
-            // must have one COLON
-            if (i == size - 1) {
-                throw new IllegalArgumentException("Illegal format address string [" + url
-                                                   + "], must have one COLON[:]! ");
-            }
         }
 
+        if (lastColon < 0) {
+            throw new IllegalArgumentException("Illegal format address string [" + url
+                                               + "], must have one COLON[:]! ");
+        }
+
+        // should not end with COLON
+        if (lastColon == size - 1) {
+            throw new IllegalArgumentException("Illegal format address string [" + url
+                                               + "], should not end with COLON[:]! ");
+        }
+        ip = url.substring(pos, lastColon);
+        pos = lastColon;
+
         for (int i = pos; i < size; ++i) {
             if (QUES == url.charAt(i)) {
                 port = url.substring(pos + 1, i);
diff --git a/src/test/java/com/alipay/remoting/rpc/RpcAddressParserTest.java b/src/test/java/com/alipay/remoting/rpc/RpcAddressParserTest.java
new file mode 100644
index 00000000..41ae36e2
--- /dev/null
+++ b/src/test/java/com/alipay/remoting/rpc/RpcAddressParserTest.java
@@ -0,0 +1,114 @@
+/*
+ * 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 com.alipay.remoting.rpc;
+
+import com.alipay.remoting.Url;
+import org.junit.Assert;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.rules.ExpectedException;
+
+public class RpcAddressParserTest {
+    private RpcAddressParser parser = new RpcAddressParser();
+
+    @Test
+    public void parseNormal() {
+        //normal ipv4 url
+        Url url = parser.parse("127.0.0.1:12200");
+        Assert.assertEquals("127.0.0.1", url.getIp());
+        Assert.assertEquals(12200, url.getPort());
+        url = parser.parse("127.0.0.1:12200?KEY1=VALUE1&KEY2=VALUE2");
+        Assert.assertEquals("127.0.0.1", url.getIp());
+        Assert.assertEquals(12200, url.getPort());
+        Assert.assertEquals(url.getProperties().size(), 2);
+
+        //normal ipv6 url
+        url = parser.parse("0:0:0:0:0:0:0:1:12200");
+        Assert.assertEquals("0:0:0:0:0:0:0:1", url.getIp());
+        Assert.assertEquals(12200, url.getPort());
+        url = parser.parse("0:0:0:0:0:0:0:1:12200?KEY1=VALUE1&KEY2=VALUE2");
+        Assert.assertEquals("0:0:0:0:0:0:0:1", url.getIp());
+        Assert.assertEquals(12200, url.getPort());
+        Assert.assertEquals(url.getProperties().size(), 2);
+    }
+
+    @Rule
+    public ExpectedException thrown = ExpectedException.none();
+
+    @Test
+    public void parseAbnormal_Blank() {
+        String urlStr = "";
+        thrown.expect(IllegalArgumentException.class);
+        thrown.expectMessage("Illegal format address string [" + urlStr
+                             + "], should not be blank! ");
+        parser.parse(urlStr);
+    }
+
+    @Test
+    public void parseAbnormal_NO_COLON() {
+        String urlStr = "127.0.0.1";
+        thrown.expect(IllegalArgumentException.class);
+        thrown.expectMessage("Illegal format address string [" + urlStr
+                             + "], must have one COLON[:]! ");
+        parser.parse(urlStr);
+    }
+
+    @Test
+    public void parseAbnormal_ENDWITH_COLON() {
+        String urlStr = "127.0.0.1:";
+        thrown.expect(IllegalArgumentException.class);
+        thrown.expectMessage("Illegal format address string [" + urlStr
+                             + "], should not end with COLON[:]! ");
+        parser.parse(urlStr);
+    }
+
+    @Test
+    public void parseAbnormal_ENDWITH_QUES() {
+        String urlStr = "127.0.0.1:12200?";
+        thrown.expect(IllegalArgumentException.class);
+        thrown.expectMessage("Illegal format address string [" + urlStr
+                             + "], should not end with QUES[?]! ");
+        parser.parse(urlStr);
+    }
+
+    @Test
+    public void parseAbnormal_ENDWITH_EQUAL() {
+        String urlStr = "127.0.0.1:12200?key1=";
+        thrown.expect(IllegalArgumentException.class);
+        thrown.expectMessage("Illegal format address string [" + urlStr
+                             + "], should not end with EQUAL[=]! ");
+        parser.parse(urlStr);
+    }
+
+    @Test
+    public void parseAbnormal_NO_EQUAL() {
+        String urlStr = "127.0.0.1:12200?key1";
+        thrown.expect(IllegalArgumentException.class);
+        thrown.expectMessage("Illegal format address string [" + urlStr
+                             + "], must have one EQUAL[=]! ");
+        parser.parse(urlStr);
+    }
+
+    @Test
+    public void parseAbnormal_ENDWITH_AND() {
+        String urlStr = "127.0.0.1:12200?key1=value1&";
+        thrown.expect(IllegalArgumentException.class);
+        thrown.expectMessage("Illegal format address string [" + urlStr
+                             + "], should not end with AND[&]! ");
+        parser.parse(urlStr);
+    }
+}
\ No newline at end of file
diff --git a/src/test/java/com/alipay/remoting/simpledemo/QuickStartServerAndClient.java b/src/test/java/com/alipay/remoting/simpledemo/QuickStartServerAndClient.java
index 08541b38..f520f94d 100644
--- a/src/test/java/com/alipay/remoting/simpledemo/QuickStartServerAndClient.java
+++ b/src/test/java/com/alipay/remoting/simpledemo/QuickStartServerAndClient.java
@@ -1,3 +1,19 @@
+/*
+ * 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 com.alipay.remoting.simpledemo;
 
 import com.alipay.remoting.exception.RemotingException;
@@ -6,14 +22,15 @@
 
 public class QuickStartServerAndClient {
     public static void main(String[] args) throws RemotingException, InterruptedException {
-        RpcServer rpcServer = new RpcServer(9876);
+        RpcServer rpcServer = new RpcServer("0:0:0:0:0:0:0:1", 9876);
         rpcServer.registerUserProcessor(new SimpleUserProcessor());
         rpcServer.startup();
 
         RpcClient rpcClient = new RpcClient();
         rpcClient.startup();
         for (int i = 0; i < 10; i++) {
-            SimpleResponse response = (SimpleResponse) rpcClient.invokeSync("127.0.0.1:9876", new SimpleRequest(i), 1000);
+            SimpleResponse response = (SimpleResponse) rpcClient.invokeSync("0:0:0:0:0:0:0:1:9876",
+                new SimpleRequest(i), 1000);
             System.out.println("i=" + i + " res=" + response.getRes());
             Thread.sleep(1000);
         }
diff --git a/src/test/java/com/alipay/remoting/simpledemo/SimpleRequest.java b/src/test/java/com/alipay/remoting/simpledemo/SimpleRequest.java
index 30dfbdda..169e89b5 100644
--- a/src/test/java/com/alipay/remoting/simpledemo/SimpleRequest.java
+++ b/src/test/java/com/alipay/remoting/simpledemo/SimpleRequest.java
@@ -1,3 +1,19 @@
+/*
+ * 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 com.alipay.remoting.simpledemo;
 
 import java.io.Serializable;
diff --git a/src/test/java/com/alipay/remoting/simpledemo/SimpleResponse.java b/src/test/java/com/alipay/remoting/simpledemo/SimpleResponse.java
index b8ccf193..085c6788 100644
--- a/src/test/java/com/alipay/remoting/simpledemo/SimpleResponse.java
+++ b/src/test/java/com/alipay/remoting/simpledemo/SimpleResponse.java
@@ -1,3 +1,19 @@
+/*
+ * 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 com.alipay.remoting.simpledemo;
 
 import java.io.Serializable;
diff --git a/src/test/java/com/alipay/remoting/simpledemo/SimpleUserProcessor.java b/src/test/java/com/alipay/remoting/simpledemo/SimpleUserProcessor.java
index 438ed005..c5e7fe2b 100644
--- a/src/test/java/com/alipay/remoting/simpledemo/SimpleUserProcessor.java
+++ b/src/test/java/com/alipay/remoting/simpledemo/SimpleUserProcessor.java
@@ -1,3 +1,19 @@
+/*
+ * 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 com.alipay.remoting.simpledemo;
 
 import com.alipay.remoting.AsyncContext;

From 643c976d4be46bc5aba5ce9d3e49151776f7c25e Mon Sep 17 00:00:00 2001
From: chuailiwu 
Date: Sat, 26 Feb 2022 22:23:14 +0800
Subject: [PATCH 04/12] add License

---
 .../simpledemo/QuickStartServerAndClient.java | 19 ++++++++++++++++++-
 .../remoting/simpledemo/SimpleRequest.java    | 16 ++++++++++++++++
 .../remoting/simpledemo/SimpleResponse.java   | 16 ++++++++++++++++
 .../simpledemo/SimpleUserProcessor.java       | 16 ++++++++++++++++
 4 files changed, 66 insertions(+), 1 deletion(-)

diff --git a/src/test/java/com/alipay/remoting/simpledemo/QuickStartServerAndClient.java b/src/test/java/com/alipay/remoting/simpledemo/QuickStartServerAndClient.java
index 08541b38..c915f344 100644
--- a/src/test/java/com/alipay/remoting/simpledemo/QuickStartServerAndClient.java
+++ b/src/test/java/com/alipay/remoting/simpledemo/QuickStartServerAndClient.java
@@ -1,3 +1,19 @@
+/*
+ * 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 com.alipay.remoting.simpledemo;
 
 import com.alipay.remoting.exception.RemotingException;
@@ -13,7 +29,8 @@ public static void main(String[] args) throws RemotingException, InterruptedExce
         RpcClient rpcClient = new RpcClient();
         rpcClient.startup();
         for (int i = 0; i < 10; i++) {
-            SimpleResponse response = (SimpleResponse) rpcClient.invokeSync("127.0.0.1:9876", new SimpleRequest(i), 1000);
+            SimpleResponse response = (SimpleResponse) rpcClient.invokeSync("127.0.0.1:9876",
+                new SimpleRequest(i), 1000);
             System.out.println("i=" + i + " res=" + response.getRes());
             Thread.sleep(1000);
         }
diff --git a/src/test/java/com/alipay/remoting/simpledemo/SimpleRequest.java b/src/test/java/com/alipay/remoting/simpledemo/SimpleRequest.java
index 30dfbdda..169e89b5 100644
--- a/src/test/java/com/alipay/remoting/simpledemo/SimpleRequest.java
+++ b/src/test/java/com/alipay/remoting/simpledemo/SimpleRequest.java
@@ -1,3 +1,19 @@
+/*
+ * 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 com.alipay.remoting.simpledemo;
 
 import java.io.Serializable;
diff --git a/src/test/java/com/alipay/remoting/simpledemo/SimpleResponse.java b/src/test/java/com/alipay/remoting/simpledemo/SimpleResponse.java
index b8ccf193..085c6788 100644
--- a/src/test/java/com/alipay/remoting/simpledemo/SimpleResponse.java
+++ b/src/test/java/com/alipay/remoting/simpledemo/SimpleResponse.java
@@ -1,3 +1,19 @@
+/*
+ * 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 com.alipay.remoting.simpledemo;
 
 import java.io.Serializable;
diff --git a/src/test/java/com/alipay/remoting/simpledemo/SimpleUserProcessor.java b/src/test/java/com/alipay/remoting/simpledemo/SimpleUserProcessor.java
index 438ed005..c5e7fe2b 100644
--- a/src/test/java/com/alipay/remoting/simpledemo/SimpleUserProcessor.java
+++ b/src/test/java/com/alipay/remoting/simpledemo/SimpleUserProcessor.java
@@ -1,3 +1,19 @@
+/*
+ * 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 com.alipay.remoting.simpledemo;
 
 import com.alipay.remoting.AsyncContext;

From 4be7c72694b6def63949214c2b4fc39bd41b252b Mon Sep 17 00:00:00 2001
From: chuailiwu 
Date: Tue, 1 Mar 2022 15:59:51 +0800
Subject: [PATCH 05/12] fix int convert to short

---
 .../com/alipay/remoting/rpc/RpcCommand.java   | 10 +++-
 .../alipay/remoting/rpc/RpcCommandTest.java   | 47 +++++++++++++++++++
 2 files changed, 55 insertions(+), 2 deletions(-)
 create mode 100644 src/test/java/com/alipay/remoting/rpc/RpcCommandTest.java

diff --git a/src/main/java/com/alipay/remoting/rpc/RpcCommand.java b/src/main/java/com/alipay/remoting/rpc/RpcCommand.java
index df6b207b..cdd7195b 100644
--- a/src/main/java/com/alipay/remoting/rpc/RpcCommand.java
+++ b/src/main/java/com/alipay/remoting/rpc/RpcCommand.java
@@ -259,8 +259,11 @@ public byte[] getHeader() {
 
     public void setHeader(byte[] header) {
         if (header != null) {
-            this.header = header;
+            if (header.length > Short.MAX_VALUE) {
+                throw new RuntimeException("header length exceed maximum, len=" + header.length);
+            }
             this.headerLength = (short) header.length;
+            this.header = header;
         }
     }
 
@@ -293,8 +296,11 @@ public byte[] getClazz() {
 
     public void setClazz(byte[] clazz) {
         if (clazz != null) {
-            this.clazz = clazz;
+            if (clazz.length > Short.MAX_VALUE) {
+                throw new RuntimeException("class length exceed maximum, len=" + clazz.length);
+            }
             this.clazzLength = (short) clazz.length;
+            this.clazz = clazz;
         }
     }
 
diff --git a/src/test/java/com/alipay/remoting/rpc/RpcCommandTest.java b/src/test/java/com/alipay/remoting/rpc/RpcCommandTest.java
new file mode 100644
index 00000000..8a514a0f
--- /dev/null
+++ b/src/test/java/com/alipay/remoting/rpc/RpcCommandTest.java
@@ -0,0 +1,47 @@
+package com.alipay.remoting.rpc;
+
+import com.alipay.remoting.rpc.protocol.RpcRequestCommand;
+import org.junit.Assert;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.rules.ExpectedException;
+
+
+public class RpcCommandTest {
+    @Rule
+    public ExpectedException thrown = ExpectedException.none();
+
+    @Test
+    public void setClazz_normal_len() {
+        RpcCommand rpcCommand = new RpcRequestCommand();
+        byte[] clazz = new byte[100];
+        rpcCommand.setClazz(clazz);
+        Assert.assertNotNull(rpcCommand.getClazz());
+    }
+
+    @Test
+    public void setClazz_exceed_maximum(){
+        RpcCommand rpcCommand = new RpcRequestCommand();
+        byte[] clazz = new byte[Short.MAX_VALUE + 1];
+        thrown.expect(RuntimeException.class);
+        thrown.expectMessage("class length exceed maximum, len=" + clazz.length);
+        rpcCommand.setClazz(clazz);
+    }
+
+    @Test
+    public void setHeader_normal_len() {
+        RpcCommand rpcCommand = new RpcRequestCommand();
+        byte[] header = new byte[100];
+        rpcCommand.setHeader(header);
+        Assert.assertNotNull(rpcCommand.getHeader());
+    }
+
+    @Test
+    public void setHeader_exceed_maximum(){
+        RpcCommand rpcCommand = new RpcRequestCommand();
+        byte[] header = new byte[Short.MAX_VALUE + 1];
+        thrown.expect(RuntimeException.class);
+        thrown.expectMessage("header length exceed maximum, len=" + header.length);
+        rpcCommand.setHeader(header);
+    }
+}
\ No newline at end of file

From c4764fc6ead54d03e62e1eb28dba1ccb88cf67e4 Mon Sep 17 00:00:00 2001
From: chuailiwu 
Date: Sat, 5 Mar 2022 18:43:21 +0800
Subject: [PATCH 06/12] add ut

---
 .../demo/BasicUsageDemoByJunitWithIpv6.java   | 287 ++++++++++++++++++
 .../simpledemo/QuickStartServerAndClient.java |   3 +-
 .../QuickStartServerAndClientWithIpv6.java    |  41 +++
 3 files changed, 329 insertions(+), 2 deletions(-)
 create mode 100644 src/test/java/com/alipay/remoting/demo/BasicUsageDemoByJunitWithIpv6.java
 create mode 100644 src/test/java/com/alipay/remoting/simpledemo/QuickStartServerAndClientWithIpv6.java

diff --git a/src/test/java/com/alipay/remoting/demo/BasicUsageDemoByJunitWithIpv6.java b/src/test/java/com/alipay/remoting/demo/BasicUsageDemoByJunitWithIpv6.java
new file mode 100644
index 00000000..25f4c31e
--- /dev/null
+++ b/src/test/java/com/alipay/remoting/demo/BasicUsageDemoByJunitWithIpv6.java
@@ -0,0 +1,287 @@
+/*
+ * 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 com.alipay.remoting.demo;
+
+import com.alipay.remoting.Connection;
+import com.alipay.remoting.ConnectionEventType;
+import com.alipay.remoting.InvokeCallback;
+import com.alipay.remoting.exception.RemotingException;
+import com.alipay.remoting.rpc.RpcClient;
+import com.alipay.remoting.rpc.RpcResponseFuture;
+import com.alipay.remoting.rpc.common.BoltServer;
+import com.alipay.remoting.rpc.common.CONNECTEventProcessor;
+import com.alipay.remoting.rpc.common.DISCONNECTEventProcessor;
+import com.alipay.remoting.rpc.common.PortScan;
+import com.alipay.remoting.rpc.common.RequestBody;
+import com.alipay.remoting.rpc.common.SimpleClientUserProcessor;
+import com.alipay.remoting.rpc.common.SimpleServerUserProcessor;
+import com.alipay.remoting.util.RemotingUtil;
+import org.junit.After;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.Executor;
+import java.util.concurrent.Executors;
+
+/**
+ * basic usage demo
+ * 
+ * basic usage of rpc client and rpc server with ipv6
+ * 
+ * @author xiaomin.cxm
+ * @version $Id: BasicUsageDemo.java, v 0.1 Apr 6, 2016 8:58:36 PM xiaomin.cxm Exp $
+ */
+public class BasicUsageDemoByJunitWithIpv6 {
+    static Logger             logger                    = LoggerFactory
+                                                            .getLogger(BasicUsageDemoByJunitWithIpv6.class);
+
+    BoltServer                server;
+    RpcClient                 client;
+
+    int                       port                      = PortScan.select();
+    String                    ip                        = "0:0:0:0:0:0:0:1";
+    String                    addr                      = "0:0:0:0:0:0:0:1:" + port;
+
+    int                       invokeTimes               = 5;
+
+    SimpleServerUserProcessor serverUserProcessor       = new SimpleServerUserProcessor();
+    SimpleClientUserProcessor clientUserProcessor       = new SimpleClientUserProcessor();
+    CONNECTEventProcessor     clientConnectProcessor    = new CONNECTEventProcessor();
+    CONNECTEventProcessor     serverConnectProcessor    = new CONNECTEventProcessor();
+    DISCONNECTEventProcessor  clientDisConnectProcessor = new DISCONNECTEventProcessor();
+    DISCONNECTEventProcessor  serverDisConnectProcessor = new DISCONNECTEventProcessor();
+
+    @Before
+    public void init() {
+        server = new BoltServer(port, true);
+        server.start();
+        server.addConnectionEventProcessor(ConnectionEventType.CONNECT, serverConnectProcessor);
+        server.addConnectionEventProcessor(ConnectionEventType.CLOSE, serverDisConnectProcessor);
+        server.registerUserProcessor(serverUserProcessor);
+
+        client = new RpcClient();
+        client.addConnectionEventProcessor(ConnectionEventType.CONNECT, clientConnectProcessor);
+        client.addConnectionEventProcessor(ConnectionEventType.CLOSE, clientDisConnectProcessor);
+        client.registerUserProcessor(clientUserProcessor);
+        client.init();
+    }
+
+    @After
+    public void stop() {
+        try {
+            server.stop();
+            Thread.sleep(100);
+        } catch (InterruptedException e) {
+            logger.error("Stop server failed!", e);
+        }
+    }
+
+    @Test
+    public void testOneway() throws InterruptedException {
+        RequestBody req = new RequestBody(2, "hello world oneway");
+        for (int i = 0; i < invokeTimes; i++) {
+            try {
+                client.oneway(addr, req);
+                Thread.sleep(100);
+            } catch (RemotingException e) {
+                String errMsg = "RemotingException caught in oneway!";
+                logger.error(errMsg, e);
+                Assert.fail(errMsg);
+            }
+        }
+
+        Assert.assertTrue(serverConnectProcessor.isConnected());
+        Assert.assertEquals(1, serverConnectProcessor.getConnectTimes());
+        Assert.assertEquals(invokeTimes, serverUserProcessor.getInvokeTimes());
+    }
+
+    @Test
+    public void testSync() throws InterruptedException {
+        RequestBody req = new RequestBody(1, "hello world sync");
+        for (int i = 0; i < invokeTimes; i++) {
+            try {
+                String res = (String) client.invokeSync(addr, req, 3000);
+                logger.warn("Result received in sync: " + res);
+                Assert.assertEquals(RequestBody.DEFAULT_SERVER_RETURN_STR, res);
+            } catch (RemotingException e) {
+                String errMsg = "RemotingException caught in sync!";
+                logger.error(errMsg, e);
+                Assert.fail(errMsg);
+            } catch (InterruptedException e) {
+                String errMsg = "InterruptedException caught in sync!";
+                logger.error(errMsg, e);
+                Assert.fail(errMsg);
+            }
+        }
+
+        Assert.assertTrue(serverConnectProcessor.isConnected());
+        Assert.assertEquals(1, serverConnectProcessor.getConnectTimes());
+        Assert.assertEquals(invokeTimes, serverUserProcessor.getInvokeTimes());
+    }
+
+    @Test
+    public void testFuture() throws InterruptedException {
+        RequestBody req = new RequestBody(2, "hello world future");
+        for (int i = 0; i < invokeTimes; i++) {
+            try {
+                RpcResponseFuture future = client.invokeWithFuture(addr, req, 3000);
+                String res = (String) future.get();
+                Assert.assertEquals(RequestBody.DEFAULT_SERVER_RETURN_STR, res);
+            } catch (RemotingException e) {
+                String errMsg = "RemotingException caught in future!";
+                logger.error(errMsg, e);
+                Assert.fail(errMsg);
+            } catch (InterruptedException e) {
+                String errMsg = "InterruptedException caught in future!";
+                logger.error(errMsg, e);
+                Assert.fail(errMsg);
+            }
+        }
+
+        Assert.assertTrue(serverConnectProcessor.isConnected());
+        Assert.assertEquals(1, serverConnectProcessor.getConnectTimes());
+        Assert.assertEquals(invokeTimes, serverUserProcessor.getInvokeTimes());
+    }
+
+    @Test
+    public void testCallback() throws InterruptedException {
+        RequestBody req = new RequestBody(1, "hello world callback");
+        final List rets = new ArrayList(1);
+        for (int i = 0; i < invokeTimes; i++) {
+            final CountDownLatch latch = new CountDownLatch(1);
+            try {
+                client.invokeWithCallback(addr, req, new InvokeCallback() {
+                    Executor executor = Executors.newCachedThreadPool();
+
+                    @Override
+                    public void onResponse(Object result) {
+                        logger.warn("Result received in callback: " + result);
+                        rets.add((String) result);
+                        latch.countDown();
+                    }
+
+                    @Override
+                    public void onException(Throwable e) {
+                        logger.error("Process exception in callback.", e);
+                        latch.countDown();
+                    }
+
+                    @Override
+                    public Executor getExecutor() {
+                        return executor;
+                    }
+
+                }, 1000);
+
+            } catch (RemotingException e) {
+                latch.countDown();
+                String errMsg = "RemotingException caught in callback!";
+                logger.error(errMsg, e);
+                Assert.fail(errMsg);
+            }
+            try {
+                latch.await();
+            } catch (InterruptedException e) {
+                String errMsg = "InterruptedException caught in callback!";
+                logger.error(errMsg, e);
+                Assert.fail(errMsg);
+            }
+            if (rets.size() == 0) {
+                Assert.fail("No result! Maybe exception caught!");
+            }
+            Assert.assertEquals(RequestBody.DEFAULT_SERVER_RETURN_STR, rets.get(0));
+            rets.clear();
+        }
+
+        Assert.assertTrue(serverConnectProcessor.isConnected());
+        Assert.assertEquals(1, serverConnectProcessor.getConnectTimes());
+        Assert.assertEquals(invokeTimes, serverUserProcessor.getInvokeTimes());
+    }
+
+    @Test
+    public void testServerSyncUsingConnection1() throws Exception {
+        for (int i = 0; i < invokeTimes; i++) {
+            RequestBody req1 = new RequestBody(1, RequestBody.DEFAULT_CLIENT_STR);
+            String serverres = (String) client.invokeSync(addr, req1, 1000);
+            Assert.assertEquals(serverres, RequestBody.DEFAULT_SERVER_RETURN_STR);
+
+            Assert.assertNotNull(serverConnectProcessor.getConnection());
+            Connection serverConn = serverConnectProcessor.getConnection();
+            RequestBody req = new RequestBody(1, RequestBody.DEFAULT_SERVER_STR);
+            String clientres = (String) server.getRpcServer().invokeSync(serverConn, req, 1000);
+            Assert.assertEquals(clientres, RequestBody.DEFAULT_CLIENT_RETURN_STR);
+        }
+
+        Assert.assertTrue(serverConnectProcessor.isConnected());
+        Assert.assertEquals(1, serverConnectProcessor.getConnectTimes());
+        Assert.assertEquals(invokeTimes, serverUserProcessor.getInvokeTimes());
+    }
+
+    @Test
+    public void testServerSyncUsingConnection() throws Exception {
+        Connection clientConn = client.createStandaloneConnection(ip, port, 1000);
+
+        for (int i = 0; i < invokeTimes; i++) {
+            RequestBody req1 = new RequestBody(1, RequestBody.DEFAULT_CLIENT_STR);
+            String serverres = (String) client.invokeSync(clientConn, req1, 1000);
+            Assert.assertEquals(serverres, RequestBody.DEFAULT_SERVER_RETURN_STR);
+
+            Assert.assertNotNull(serverConnectProcessor.getConnection());
+            Connection serverConn = serverConnectProcessor.getConnection();
+            RequestBody req = new RequestBody(1, RequestBody.DEFAULT_SERVER_STR);
+            String clientres = (String) server.getRpcServer().invokeSync(serverConn, req, 1000);
+            Assert.assertEquals(clientres, RequestBody.DEFAULT_CLIENT_RETURN_STR);
+        }
+
+        Assert.assertTrue(serverConnectProcessor.isConnected());
+        Assert.assertEquals(1, serverConnectProcessor.getConnectTimes());
+        Assert.assertEquals(invokeTimes, serverUserProcessor.getInvokeTimes());
+    }
+
+    @Test
+    public void testServerSyncUsingAddress() throws Exception {
+        Connection clientConn = client.createStandaloneConnection(ip, port, 1000);
+        String remote = RemotingUtil.parseRemoteAddress(clientConn.getChannel());
+        String local = RemotingUtil.parseLocalAddress(clientConn.getChannel());
+        logger.warn("Client say local:" + local);
+        logger.warn("Client say remote:" + remote);
+
+        for (int i = 0; i < invokeTimes; i++) {
+            RequestBody req1 = new RequestBody(1, RequestBody.DEFAULT_CLIENT_STR);
+            String serverres = (String) client.invokeSync(clientConn, req1, 1000);
+            Assert.assertEquals(serverres, RequestBody.DEFAULT_SERVER_RETURN_STR);
+
+            Assert.assertNotNull(serverConnectProcessor.getConnection());
+            // only when client invoked, the remote address can be get by UserProcessor
+            // otherwise, please use ConnectionEventProcessor
+            String remoteAddr = serverUserProcessor.getRemoteAddr();
+            RequestBody req = new RequestBody(1, RequestBody.DEFAULT_SERVER_STR);
+            String clientres = (String) server.getRpcServer().invokeSync(remoteAddr, req, 1000);
+            Assert.assertEquals(clientres, RequestBody.DEFAULT_CLIENT_RETURN_STR);
+        }
+
+        Assert.assertTrue(serverConnectProcessor.isConnected());
+        Assert.assertEquals(1, serverConnectProcessor.getConnectTimes());
+        Assert.assertEquals(invokeTimes, serverUserProcessor.getInvokeTimes());
+    }
+}
\ No newline at end of file
diff --git a/src/test/java/com/alipay/remoting/simpledemo/QuickStartServerAndClient.java b/src/test/java/com/alipay/remoting/simpledemo/QuickStartServerAndClient.java
index 962645a9..3511f9f5 100644
--- a/src/test/java/com/alipay/remoting/simpledemo/QuickStartServerAndClient.java
+++ b/src/test/java/com/alipay/remoting/simpledemo/QuickStartServerAndClient.java
@@ -22,14 +22,13 @@
 
 public class QuickStartServerAndClient {
     public static void main(String[] args) throws RemotingException, InterruptedException {
-        RpcServer rpcServer = new RpcServer("0:0:0:0:0:0:0:1", 9876);
+        RpcServer rpcServer = new RpcServer( 9876);
         rpcServer.registerUserProcessor(new SimpleUserProcessor());
         rpcServer.startup();
 
         RpcClient rpcClient = new RpcClient();
         rpcClient.startup();
         for (int i = 0; i < 10; i++) {
-
             SimpleResponse response = (SimpleResponse) rpcClient.invokeSync("127.0.0.1:9876",
                 new SimpleRequest(i), 1000);
             System.out.println("i=" + i + " res=" + response.getRes());
diff --git a/src/test/java/com/alipay/remoting/simpledemo/QuickStartServerAndClientWithIpv6.java b/src/test/java/com/alipay/remoting/simpledemo/QuickStartServerAndClientWithIpv6.java
new file mode 100644
index 00000000..5ef74b36
--- /dev/null
+++ b/src/test/java/com/alipay/remoting/simpledemo/QuickStartServerAndClientWithIpv6.java
@@ -0,0 +1,41 @@
+/*
+ * 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 com.alipay.remoting.simpledemo;
+
+import com.alipay.remoting.exception.RemotingException;
+import com.alipay.remoting.rpc.RpcClient;
+import com.alipay.remoting.rpc.RpcServer;
+
+public class QuickStartServerAndClientWithIpv6 {
+    public static void main(String[] args) throws RemotingException, InterruptedException {
+        RpcServer rpcServer = new RpcServer("0:0:0:0:0:0:0:1", 9875);
+        rpcServer.registerUserProcessor(new SimpleUserProcessor());
+        rpcServer.startup();
+
+        RpcClient rpcClient = new RpcClient();
+        rpcClient.startup();
+        for (int i = 0; i < 10; i++) {
+            SimpleResponse response = (SimpleResponse) rpcClient.invokeSync("0:0:0:0:0:0:0:1:9875",
+                new SimpleRequest(i), 1000);
+            System.out.println("i=" + i + " res=" + response.getRes());
+            Thread.sleep(1000);
+        }
+
+        rpcClient.shutdown();
+        rpcServer.shutdown();
+    }
+}

From 2ed8b273ffcc7feed7f52cbdd675704fe65f9783 Mon Sep 17 00:00:00 2001
From: chuailiwu 
Date: Sun, 6 Mar 2022 19:54:41 +0800
Subject: [PATCH 07/12] fix typo

---
 .../alipay/remoting/rpc/RpcCommandTest.java   | 21 ++++++++++++++++---
 .../simpledemo/QuickStartServerAndClient.java |  2 +-
 2 files changed, 19 insertions(+), 4 deletions(-)

diff --git a/src/test/java/com/alipay/remoting/rpc/RpcCommandTest.java b/src/test/java/com/alipay/remoting/rpc/RpcCommandTest.java
index 8a514a0f..196639e4 100644
--- a/src/test/java/com/alipay/remoting/rpc/RpcCommandTest.java
+++ b/src/test/java/com/alipay/remoting/rpc/RpcCommandTest.java
@@ -1,3 +1,19 @@
+/*
+ * 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 com.alipay.remoting.rpc;
 
 import com.alipay.remoting.rpc.protocol.RpcRequestCommand;
@@ -6,7 +22,6 @@
 import org.junit.Test;
 import org.junit.rules.ExpectedException;
 
-
 public class RpcCommandTest {
     @Rule
     public ExpectedException thrown = ExpectedException.none();
@@ -20,7 +35,7 @@ public void setClazz_normal_len() {
     }
 
     @Test
-    public void setClazz_exceed_maximum(){
+    public void setClazz_exceed_maximum() {
         RpcCommand rpcCommand = new RpcRequestCommand();
         byte[] clazz = new byte[Short.MAX_VALUE + 1];
         thrown.expect(RuntimeException.class);
@@ -37,7 +52,7 @@ public void setHeader_normal_len() {
     }
 
     @Test
-    public void setHeader_exceed_maximum(){
+    public void setHeader_exceed_maximum() {
         RpcCommand rpcCommand = new RpcRequestCommand();
         byte[] header = new byte[Short.MAX_VALUE + 1];
         thrown.expect(RuntimeException.class);
diff --git a/src/test/java/com/alipay/remoting/simpledemo/QuickStartServerAndClient.java b/src/test/java/com/alipay/remoting/simpledemo/QuickStartServerAndClient.java
index 3511f9f5..c915f344 100644
--- a/src/test/java/com/alipay/remoting/simpledemo/QuickStartServerAndClient.java
+++ b/src/test/java/com/alipay/remoting/simpledemo/QuickStartServerAndClient.java
@@ -22,7 +22,7 @@
 
 public class QuickStartServerAndClient {
     public static void main(String[] args) throws RemotingException, InterruptedException {
-        RpcServer rpcServer = new RpcServer( 9876);
+        RpcServer rpcServer = new RpcServer(9876);
         rpcServer.registerUserProcessor(new SimpleUserProcessor());
         rpcServer.startup();
 

From 7455f6c0da3e71276359141206054d5f8c49972b Mon Sep 17 00:00:00 2001
From: chuailiwu 
Date: Sun, 6 Mar 2022 20:12:05 +0800
Subject: [PATCH 08/12] rm unnecessary test

---
 .../demo/BasicUsageDemoByJunitWithIpv6.java   | 287 ------------------
 1 file changed, 287 deletions(-)
 delete mode 100644 src/test/java/com/alipay/remoting/demo/BasicUsageDemoByJunitWithIpv6.java

diff --git a/src/test/java/com/alipay/remoting/demo/BasicUsageDemoByJunitWithIpv6.java b/src/test/java/com/alipay/remoting/demo/BasicUsageDemoByJunitWithIpv6.java
deleted file mode 100644
index 25f4c31e..00000000
--- a/src/test/java/com/alipay/remoting/demo/BasicUsageDemoByJunitWithIpv6.java
+++ /dev/null
@@ -1,287 +0,0 @@
-/*
- * 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 com.alipay.remoting.demo;
-
-import com.alipay.remoting.Connection;
-import com.alipay.remoting.ConnectionEventType;
-import com.alipay.remoting.InvokeCallback;
-import com.alipay.remoting.exception.RemotingException;
-import com.alipay.remoting.rpc.RpcClient;
-import com.alipay.remoting.rpc.RpcResponseFuture;
-import com.alipay.remoting.rpc.common.BoltServer;
-import com.alipay.remoting.rpc.common.CONNECTEventProcessor;
-import com.alipay.remoting.rpc.common.DISCONNECTEventProcessor;
-import com.alipay.remoting.rpc.common.PortScan;
-import com.alipay.remoting.rpc.common.RequestBody;
-import com.alipay.remoting.rpc.common.SimpleClientUserProcessor;
-import com.alipay.remoting.rpc.common.SimpleServerUserProcessor;
-import com.alipay.remoting.util.RemotingUtil;
-import org.junit.After;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.Test;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.util.ArrayList;
-import java.util.List;
-import java.util.concurrent.CountDownLatch;
-import java.util.concurrent.Executor;
-import java.util.concurrent.Executors;
-
-/**
- * basic usage demo
- * 
- * basic usage of rpc client and rpc server with ipv6
- * 
- * @author xiaomin.cxm
- * @version $Id: BasicUsageDemo.java, v 0.1 Apr 6, 2016 8:58:36 PM xiaomin.cxm Exp $
- */
-public class BasicUsageDemoByJunitWithIpv6 {
-    static Logger             logger                    = LoggerFactory
-                                                            .getLogger(BasicUsageDemoByJunitWithIpv6.class);
-
-    BoltServer                server;
-    RpcClient                 client;
-
-    int                       port                      = PortScan.select();
-    String                    ip                        = "0:0:0:0:0:0:0:1";
-    String                    addr                      = "0:0:0:0:0:0:0:1:" + port;
-
-    int                       invokeTimes               = 5;
-
-    SimpleServerUserProcessor serverUserProcessor       = new SimpleServerUserProcessor();
-    SimpleClientUserProcessor clientUserProcessor       = new SimpleClientUserProcessor();
-    CONNECTEventProcessor     clientConnectProcessor    = new CONNECTEventProcessor();
-    CONNECTEventProcessor     serverConnectProcessor    = new CONNECTEventProcessor();
-    DISCONNECTEventProcessor  clientDisConnectProcessor = new DISCONNECTEventProcessor();
-    DISCONNECTEventProcessor  serverDisConnectProcessor = new DISCONNECTEventProcessor();
-
-    @Before
-    public void init() {
-        server = new BoltServer(port, true);
-        server.start();
-        server.addConnectionEventProcessor(ConnectionEventType.CONNECT, serverConnectProcessor);
-        server.addConnectionEventProcessor(ConnectionEventType.CLOSE, serverDisConnectProcessor);
-        server.registerUserProcessor(serverUserProcessor);
-
-        client = new RpcClient();
-        client.addConnectionEventProcessor(ConnectionEventType.CONNECT, clientConnectProcessor);
-        client.addConnectionEventProcessor(ConnectionEventType.CLOSE, clientDisConnectProcessor);
-        client.registerUserProcessor(clientUserProcessor);
-        client.init();
-    }
-
-    @After
-    public void stop() {
-        try {
-            server.stop();
-            Thread.sleep(100);
-        } catch (InterruptedException e) {
-            logger.error("Stop server failed!", e);
-        }
-    }
-
-    @Test
-    public void testOneway() throws InterruptedException {
-        RequestBody req = new RequestBody(2, "hello world oneway");
-        for (int i = 0; i < invokeTimes; i++) {
-            try {
-                client.oneway(addr, req);
-                Thread.sleep(100);
-            } catch (RemotingException e) {
-                String errMsg = "RemotingException caught in oneway!";
-                logger.error(errMsg, e);
-                Assert.fail(errMsg);
-            }
-        }
-
-        Assert.assertTrue(serverConnectProcessor.isConnected());
-        Assert.assertEquals(1, serverConnectProcessor.getConnectTimes());
-        Assert.assertEquals(invokeTimes, serverUserProcessor.getInvokeTimes());
-    }
-
-    @Test
-    public void testSync() throws InterruptedException {
-        RequestBody req = new RequestBody(1, "hello world sync");
-        for (int i = 0; i < invokeTimes; i++) {
-            try {
-                String res = (String) client.invokeSync(addr, req, 3000);
-                logger.warn("Result received in sync: " + res);
-                Assert.assertEquals(RequestBody.DEFAULT_SERVER_RETURN_STR, res);
-            } catch (RemotingException e) {
-                String errMsg = "RemotingException caught in sync!";
-                logger.error(errMsg, e);
-                Assert.fail(errMsg);
-            } catch (InterruptedException e) {
-                String errMsg = "InterruptedException caught in sync!";
-                logger.error(errMsg, e);
-                Assert.fail(errMsg);
-            }
-        }
-
-        Assert.assertTrue(serverConnectProcessor.isConnected());
-        Assert.assertEquals(1, serverConnectProcessor.getConnectTimes());
-        Assert.assertEquals(invokeTimes, serverUserProcessor.getInvokeTimes());
-    }
-
-    @Test
-    public void testFuture() throws InterruptedException {
-        RequestBody req = new RequestBody(2, "hello world future");
-        for (int i = 0; i < invokeTimes; i++) {
-            try {
-                RpcResponseFuture future = client.invokeWithFuture(addr, req, 3000);
-                String res = (String) future.get();
-                Assert.assertEquals(RequestBody.DEFAULT_SERVER_RETURN_STR, res);
-            } catch (RemotingException e) {
-                String errMsg = "RemotingException caught in future!";
-                logger.error(errMsg, e);
-                Assert.fail(errMsg);
-            } catch (InterruptedException e) {
-                String errMsg = "InterruptedException caught in future!";
-                logger.error(errMsg, e);
-                Assert.fail(errMsg);
-            }
-        }
-
-        Assert.assertTrue(serverConnectProcessor.isConnected());
-        Assert.assertEquals(1, serverConnectProcessor.getConnectTimes());
-        Assert.assertEquals(invokeTimes, serverUserProcessor.getInvokeTimes());
-    }
-
-    @Test
-    public void testCallback() throws InterruptedException {
-        RequestBody req = new RequestBody(1, "hello world callback");
-        final List rets = new ArrayList(1);
-        for (int i = 0; i < invokeTimes; i++) {
-            final CountDownLatch latch = new CountDownLatch(1);
-            try {
-                client.invokeWithCallback(addr, req, new InvokeCallback() {
-                    Executor executor = Executors.newCachedThreadPool();
-
-                    @Override
-                    public void onResponse(Object result) {
-                        logger.warn("Result received in callback: " + result);
-                        rets.add((String) result);
-                        latch.countDown();
-                    }
-
-                    @Override
-                    public void onException(Throwable e) {
-                        logger.error("Process exception in callback.", e);
-                        latch.countDown();
-                    }
-
-                    @Override
-                    public Executor getExecutor() {
-                        return executor;
-                    }
-
-                }, 1000);
-
-            } catch (RemotingException e) {
-                latch.countDown();
-                String errMsg = "RemotingException caught in callback!";
-                logger.error(errMsg, e);
-                Assert.fail(errMsg);
-            }
-            try {
-                latch.await();
-            } catch (InterruptedException e) {
-                String errMsg = "InterruptedException caught in callback!";
-                logger.error(errMsg, e);
-                Assert.fail(errMsg);
-            }
-            if (rets.size() == 0) {
-                Assert.fail("No result! Maybe exception caught!");
-            }
-            Assert.assertEquals(RequestBody.DEFAULT_SERVER_RETURN_STR, rets.get(0));
-            rets.clear();
-        }
-
-        Assert.assertTrue(serverConnectProcessor.isConnected());
-        Assert.assertEquals(1, serverConnectProcessor.getConnectTimes());
-        Assert.assertEquals(invokeTimes, serverUserProcessor.getInvokeTimes());
-    }
-
-    @Test
-    public void testServerSyncUsingConnection1() throws Exception {
-        for (int i = 0; i < invokeTimes; i++) {
-            RequestBody req1 = new RequestBody(1, RequestBody.DEFAULT_CLIENT_STR);
-            String serverres = (String) client.invokeSync(addr, req1, 1000);
-            Assert.assertEquals(serverres, RequestBody.DEFAULT_SERVER_RETURN_STR);
-
-            Assert.assertNotNull(serverConnectProcessor.getConnection());
-            Connection serverConn = serverConnectProcessor.getConnection();
-            RequestBody req = new RequestBody(1, RequestBody.DEFAULT_SERVER_STR);
-            String clientres = (String) server.getRpcServer().invokeSync(serverConn, req, 1000);
-            Assert.assertEquals(clientres, RequestBody.DEFAULT_CLIENT_RETURN_STR);
-        }
-
-        Assert.assertTrue(serverConnectProcessor.isConnected());
-        Assert.assertEquals(1, serverConnectProcessor.getConnectTimes());
-        Assert.assertEquals(invokeTimes, serverUserProcessor.getInvokeTimes());
-    }
-
-    @Test
-    public void testServerSyncUsingConnection() throws Exception {
-        Connection clientConn = client.createStandaloneConnection(ip, port, 1000);
-
-        for (int i = 0; i < invokeTimes; i++) {
-            RequestBody req1 = new RequestBody(1, RequestBody.DEFAULT_CLIENT_STR);
-            String serverres = (String) client.invokeSync(clientConn, req1, 1000);
-            Assert.assertEquals(serverres, RequestBody.DEFAULT_SERVER_RETURN_STR);
-
-            Assert.assertNotNull(serverConnectProcessor.getConnection());
-            Connection serverConn = serverConnectProcessor.getConnection();
-            RequestBody req = new RequestBody(1, RequestBody.DEFAULT_SERVER_STR);
-            String clientres = (String) server.getRpcServer().invokeSync(serverConn, req, 1000);
-            Assert.assertEquals(clientres, RequestBody.DEFAULT_CLIENT_RETURN_STR);
-        }
-
-        Assert.assertTrue(serverConnectProcessor.isConnected());
-        Assert.assertEquals(1, serverConnectProcessor.getConnectTimes());
-        Assert.assertEquals(invokeTimes, serverUserProcessor.getInvokeTimes());
-    }
-
-    @Test
-    public void testServerSyncUsingAddress() throws Exception {
-        Connection clientConn = client.createStandaloneConnection(ip, port, 1000);
-        String remote = RemotingUtil.parseRemoteAddress(clientConn.getChannel());
-        String local = RemotingUtil.parseLocalAddress(clientConn.getChannel());
-        logger.warn("Client say local:" + local);
-        logger.warn("Client say remote:" + remote);
-
-        for (int i = 0; i < invokeTimes; i++) {
-            RequestBody req1 = new RequestBody(1, RequestBody.DEFAULT_CLIENT_STR);
-            String serverres = (String) client.invokeSync(clientConn, req1, 1000);
-            Assert.assertEquals(serverres, RequestBody.DEFAULT_SERVER_RETURN_STR);
-
-            Assert.assertNotNull(serverConnectProcessor.getConnection());
-            // only when client invoked, the remote address can be get by UserProcessor
-            // otherwise, please use ConnectionEventProcessor
-            String remoteAddr = serverUserProcessor.getRemoteAddr();
-            RequestBody req = new RequestBody(1, RequestBody.DEFAULT_SERVER_STR);
-            String clientres = (String) server.getRpcServer().invokeSync(remoteAddr, req, 1000);
-            Assert.assertEquals(clientres, RequestBody.DEFAULT_CLIENT_RETURN_STR);
-        }
-
-        Assert.assertTrue(serverConnectProcessor.isConnected());
-        Assert.assertEquals(1, serverConnectProcessor.getConnectTimes());
-        Assert.assertEquals(invokeTimes, serverUserProcessor.getInvokeTimes());
-    }
-}
\ No newline at end of file

From 0983f09542372a1bf1cfa19448cc047c5ef063ff Mon Sep 17 00:00:00 2001
From: chuailiwu 
Date: Sun, 6 Mar 2022 20:46:25 +0800
Subject: [PATCH 09/12] add ipv6 rpc ut

---
 .../com/alipay/remoting/RpcWithIpv6Test.java  | 103 ++++++++++++++++++
 1 file changed, 103 insertions(+)
 create mode 100644 src/test/java/com/alipay/remoting/RpcWithIpv6Test.java

diff --git a/src/test/java/com/alipay/remoting/RpcWithIpv6Test.java b/src/test/java/com/alipay/remoting/RpcWithIpv6Test.java
new file mode 100644
index 00000000..ee9e40b1
--- /dev/null
+++ b/src/test/java/com/alipay/remoting/RpcWithIpv6Test.java
@@ -0,0 +1,103 @@
+/*
+ * 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 com.alipay.remoting;
+
+import com.alipay.remoting.exception.RemotingException;
+import com.alipay.remoting.rpc.RpcClient;
+import com.alipay.remoting.rpc.common.BoltServer;
+import com.alipay.remoting.rpc.common.CONNECTEventProcessor;
+import com.alipay.remoting.rpc.common.DISCONNECTEventProcessor;
+import com.alipay.remoting.rpc.common.PortScan;
+import com.alipay.remoting.rpc.common.RequestBody;
+import com.alipay.remoting.rpc.common.SimpleClientUserProcessor;
+import com.alipay.remoting.rpc.common.SimpleServerUserProcessor;
+import org.junit.After;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class RpcWithIpv6Test {
+    static Logger             logger                    = LoggerFactory
+                                                            .getLogger(RpcWithIpv6Test.class);
+
+    BoltServer                server;
+    RpcClient                 client;
+
+    int                       port                      = PortScan.select();
+    String                    ip                        = "0:0:0:0:0:0:0:1";
+    String                    addr                      = "0:0:0:0:0:0:0:1:" + port;
+
+    int                       invokeTimes               = 5;
+
+    SimpleServerUserProcessor serverUserProcessor       = new SimpleServerUserProcessor();
+    SimpleClientUserProcessor clientUserProcessor       = new SimpleClientUserProcessor();
+    CONNECTEventProcessor     clientConnectProcessor    = new CONNECTEventProcessor();
+    CONNECTEventProcessor     serverConnectProcessor    = new CONNECTEventProcessor();
+    DISCONNECTEventProcessor  clientDisConnectProcessor = new DISCONNECTEventProcessor();
+    DISCONNECTEventProcessor  serverDisConnectProcessor = new DISCONNECTEventProcessor();
+
+    @Before
+    public void init() {
+        server = new BoltServer(port, true);
+        server.start();
+        server.addConnectionEventProcessor(ConnectionEventType.CONNECT, serverConnectProcessor);
+        server.addConnectionEventProcessor(ConnectionEventType.CLOSE, serverDisConnectProcessor);
+        server.registerUserProcessor(serverUserProcessor);
+
+        client = new RpcClient();
+        client.addConnectionEventProcessor(ConnectionEventType.CONNECT, clientConnectProcessor);
+        client.addConnectionEventProcessor(ConnectionEventType.CLOSE, clientDisConnectProcessor);
+        client.registerUserProcessor(clientUserProcessor);
+        client.init();
+    }
+
+    @After
+    public void stop() {
+        try {
+            server.stop();
+            Thread.sleep(100);
+        } catch (InterruptedException e) {
+            logger.error("Stop server failed!", e);
+        }
+    }
+
+    @Test
+    public void test() throws InterruptedException {
+        RequestBody req = new RequestBody(1, "hello world");
+        for (int i = 0; i < invokeTimes; i++) {
+            try {
+                String res = (String) client.invokeSync(addr, req, 3000);
+                logger.warn("Result received: " + res);
+                Assert.assertEquals(RequestBody.DEFAULT_SERVER_RETURN_STR, res);
+            } catch (RemotingException e) {
+                String errMsg = "RemotingException caught!";
+                logger.error(errMsg, e);
+                Assert.fail(errMsg);
+            } catch (InterruptedException e) {
+                String errMsg = "InterruptedException caught!";
+                logger.error(errMsg, e);
+                Assert.fail(errMsg);
+            }
+        }
+
+        Assert.assertTrue(serverConnectProcessor.isConnected());
+        Assert.assertEquals(1, serverConnectProcessor.getConnectTimes());
+        Assert.assertEquals(invokeTimes, serverUserProcessor.getInvokeTimes());
+    }
+}
\ No newline at end of file

From 8e0549b9f9dbe20458cba14bfc302995037aefeb Mon Sep 17 00:00:00 2001
From: chuailiwu 
Date: Sat, 9 Apr 2022 21:07:30 +0800
Subject: [PATCH 10/12] fix bad connection not be removed timely

---
 .../java/com/alipay/remoting/DefaultConnectionManager.java    | 1 +
 .../alipay/remoting/connection/AbstractConnectionFactory.java | 4 ++++
 2 files changed, 5 insertions(+)

diff --git a/src/main/java/com/alipay/remoting/DefaultConnectionManager.java b/src/main/java/com/alipay/remoting/DefaultConnectionManager.java
index 08d501e6..01a52fac 100644
--- a/src/main/java/com/alipay/remoting/DefaultConnectionManager.java
+++ b/src/main/java/com/alipay/remoting/DefaultConnectionManager.java
@@ -710,6 +710,7 @@ public ConnectionPool call() throws Exception {
                         syncCreateNumWhenNotWarmup);
                 } catch (Exception e) {
                     pool.removeAllAndTryClose();
+                    connTasks.remove(url.getUniqueKey());
                     throw e;
                 }
             }
diff --git a/src/main/java/com/alipay/remoting/connection/AbstractConnectionFactory.java b/src/main/java/com/alipay/remoting/connection/AbstractConnectionFactory.java
index f26e4c22..8c8d6125 100644
--- a/src/main/java/com/alipay/remoting/connection/AbstractConnectionFactory.java
+++ b/src/main/java/com/alipay/remoting/connection/AbstractConnectionFactory.java
@@ -31,6 +31,7 @@
 import com.alipay.remoting.config.BoltServerOption;
 import com.alipay.remoting.config.Configuration;
 import com.alipay.remoting.ExtendedNettyChannelHandler;
+import com.alipay.remoting.exception.RemotingException;
 import org.slf4j.Logger;
 
 import com.alipay.remoting.Connection;
@@ -189,6 +190,7 @@ public Connection createConnection(Url url) throws Exception {
             channel.pipeline().fireUserEventTriggered(ConnectionEventType.CONNECT);
         } else {
             channel.pipeline().fireUserEventTriggered(ConnectionEventType.CONNECT_FAILED);
+            throw new RemotingException("create connection, but channel is inactive");
         }
         return conn;
     }
@@ -204,6 +206,7 @@ public Connection createConnection(String targetIP, int targetPort, int connectT
             channel.pipeline().fireUserEventTriggered(ConnectionEventType.CONNECT);
         } else {
             channel.pipeline().fireUserEventTriggered(ConnectionEventType.CONNECT_FAILED);
+            throw new RemotingException("create connection, but channel is inactive");
         }
         return conn;
     }
@@ -219,6 +222,7 @@ public Connection createConnection(String targetIP, int targetPort, byte version
             channel.pipeline().fireUserEventTriggered(ConnectionEventType.CONNECT);
         } else {
             channel.pipeline().fireUserEventTriggered(ConnectionEventType.CONNECT_FAILED);
+            throw new RemotingException("create connection, but channel is inactive");
         }
         return conn;
     }

From c7453b0949063e79c04f1c0e1659527b9831330d Mon Sep 17 00:00:00 2001
From: chuailiwu 
Date: Mon, 11 Apr 2022 15:53:54 +0800
Subject: [PATCH 11/12] add context

---
 .../connection/AbstractConnectionFactory.java         | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/src/main/java/com/alipay/remoting/connection/AbstractConnectionFactory.java b/src/main/java/com/alipay/remoting/connection/AbstractConnectionFactory.java
index 8c8d6125..407a6b1f 100644
--- a/src/main/java/com/alipay/remoting/connection/AbstractConnectionFactory.java
+++ b/src/main/java/com/alipay/remoting/connection/AbstractConnectionFactory.java
@@ -190,7 +190,8 @@ public Connection createConnection(Url url) throws Exception {
             channel.pipeline().fireUserEventTriggered(ConnectionEventType.CONNECT);
         } else {
             channel.pipeline().fireUserEventTriggered(ConnectionEventType.CONNECT_FAILED);
-            throw new RemotingException("create connection, but channel is inactive");
+            throw new RemotingException("create connection, but channel is inactive, url is "
+                                        + url.getOriginUrl());
         }
         return conn;
     }
@@ -206,7 +207,9 @@ public Connection createConnection(String targetIP, int targetPort, int connectT
             channel.pipeline().fireUserEventTriggered(ConnectionEventType.CONNECT);
         } else {
             channel.pipeline().fireUserEventTriggered(ConnectionEventType.CONNECT_FAILED);
-            throw new RemotingException("create connection, but channel is inactive");
+            throw new RemotingException(
+                "create connection, but channel is inactive, target address is " + targetIP + ":"
+                        + targetPort);
         }
         return conn;
     }
@@ -222,7 +225,9 @@ public Connection createConnection(String targetIP, int targetPort, byte version
             channel.pipeline().fireUserEventTriggered(ConnectionEventType.CONNECT);
         } else {
             channel.pipeline().fireUserEventTriggered(ConnectionEventType.CONNECT_FAILED);
-            throw new RemotingException("create connection, but channel is inactive");
+            throw new RemotingException(
+                "create connection, but channel is inactive, target address is " + targetIP + ":"
+                        + targetPort);
         }
         return conn;
     }

From 94d3a666c7e96721b64fcac38f34d7ee2b3d6c1f Mon Sep 17 00:00:00 2001
From: chuailiwu 
Date: Tue, 7 May 2024 20:19:47 +0800
Subject: [PATCH 12/12] upgrade hessian to 3.5.3

---
 pom.xml | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/pom.xml b/pom.xml
index 6474a5e4..f9c90b02 100644
--- a/pom.xml
+++ b/pom.xml
@@ -67,7 +67,7 @@
         2.6
         3.2.1
         3.4.4
-        3.3.6
+        3.5.3
         1.8
         4.13.1
         3.0