Skip to content

Commit

Permalink
version 1.5.5 (#158)
Browse files Browse the repository at this point in the history
* upgrade version to 1.5.5 and fix reconnect bug
  • Loading branch information
dbl-x authored May 20, 2019
1 parent 0ad7b46 commit 124fbf4
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 2 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>com.alipay.sofa</groupId>
<artifactId>bolt</artifactId>
<version>1.5.4</version>
<version>1.5.5</version>
<packaging>jar</packaging>

<name>${project.groupId}:${project.artifactId}</name>
Expand Down
6 changes: 6 additions & 0 deletions src/main/java/com/alipay/remoting/rpc/RpcClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -809,6 +809,9 @@ public boolean checkConnection(String addr) {
*/
public void closeConnection(String addr) {
Url url = this.addressParser.parse(addr);
if (switches().isOn(GlobalSwitch.CONN_RECONNECT_SWITCH) && reconnectManager != null) {
reconnectManager.addCancelUrl(url);
}
this.connectionManager.remove(url.getUniqueKey());
}

Expand All @@ -818,6 +821,9 @@ public void closeConnection(String addr) {
* @param url
*/
public void closeConnection(Url url) {
if (switches().isOn(GlobalSwitch.CONN_RECONNECT_SWITCH) && reconnectManager != null) {
reconnectManager.addCancelUrl(url);
}
this.connectionManager.remove(url.getUniqueKey());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,11 +105,30 @@ public void testReconnectionByUserSetting() throws InterruptedException, Remotin
Assert.assertEquals(0, clientDisConnectProcessor.getDisConnectTimes());
Assert.assertEquals(1, clientConnectProcessor.getConnectTimes());
connection.close();
Thread.sleep(1000);
Thread.sleep(2000);
Assert.assertEquals(1, clientDisConnectProcessor.getDisConnectTimes());
Assert.assertEquals(2, clientConnectProcessor.getConnectTimes());
}

@Test
public void testCancelReConnection() throws InterruptedException, RemotingException {
doInit(false, true);
client.enableReconnectSwitch();

String addr = "127.0.0.1:2014?zone=RZONE&_CONNECTIONNUM=1";
Url url = addressParser.parse(addr);

client.getConnection(url, 1000);
Assert.assertEquals(0, clientDisConnectProcessor.getDisConnectTimes());
Assert.assertEquals(1, clientConnectProcessor.getConnectTimes());

client.closeConnection(url);

Thread.sleep(1000);
Assert.assertEquals(1, clientDisConnectProcessor.getDisConnectTimes());
Assert.assertEquals(1, clientConnectProcessor.getConnectTimes());
}

private void doInit(boolean enableSystem, boolean enableUser) {
if (enableSystem) {
System.setProperty(Configs.CONN_RECONNECT_SWITCH, "true");
Expand Down

0 comments on commit 124fbf4

Please sign in to comment.