Skip to content

Commit

Permalink
Dev 1.5.3 (#129) (#130)
Browse files Browse the repository at this point in the history
* Make getAfterRun un-block avoid deadlock. (#107)

* update readme

* Timeout object no longer references RemotingCommand

* remove strongly of sofahessian

* update readme

* remove reference of request

* remove ci jdk1.6
  • Loading branch information
dbl-x committed Mar 5, 2019
1 parent 210fe16 commit f81103f
Show file tree
Hide file tree
Showing 7 changed files with 27 additions and 40 deletions.
Binary file added .DS_Store
Binary file not shown.
6 changes: 0 additions & 6 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,15 +1,9 @@
#.travis.yml
language: java

addons:
apt:
packages:
- openjdk-6-jdk

jdk:
- oraclejdk8
- openjdk7
- openjdk6

before_install:
- echo "Downloading Maven 3.2.5"
Expand Down
10 changes: 8 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
[![Build Status](https://travis-ci.org/alipay/sofa-bolt.svg?branch=master)](https://travis-ci.org/alipay/sofa-bolt)
[![Coverage Status](https://codecov.io/gh/alipay/sofa-bolt/branch/master/graph/badge.svg)](https://codecov.io/gh/alipay/sofa-bolt)
![license](https://img.shields.io/badge/license-Apache--2.0-green.svg)
![version](https://img.shields.io/badge/bolt-1.5.2-blue.svg)
![version](https://img.shields.io/badge/bolt-1.5.3-blue.svg)

# 1. 介绍
SOFABolt 是蚂蚁金融服务集团开发的一套基于 Netty 实现的网络通信框架。
Expand Down Expand Up @@ -56,7 +56,13 @@ Bolt 名字取自迪士尼动画-闪电狗,是一个基于 Netty 最佳实践
# 5. 版权协议
对 SOFABolt 代码的修改和变更,需要遵守[版权协议](./LICENSE)

# 6. 有用的链接
# 6. 多语言

* [node](https://github.com/alipay/sofa-bolt-node)
* [python](https://github.com/alipay/sofa-bolt-python)
* [cpp](https://github.com/alipay/sofa-bolt-cpp)

# 7. 有用的链接
* [ISSUES](https://github.com/alipay/sofa-bolt/issues)
* [用户手册](https://github.com/alipay/sofa-bolt/wiki/SOFA-Bolt-Handbook)
* [中文介绍文章: 蚂蚁通信框架实践](http://mp.weixin.qq.com/s/JRsbK1Un2av9GKmJ8DK7IQ)
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.2</version>
<version>1.5.3</version>
<packaging>jar</packaging>

<name>${project.groupId}:${project.artifactId}</name>
Expand Down
35 changes: 16 additions & 19 deletions src/main/java/com/alipay/remoting/BaseRemoting.java
Original file line number Diff line number Diff line change
Expand Up @@ -60,34 +60,32 @@ protected RemotingCommand invokeSync(final Connection conn, final RemotingComman
InterruptedException {
final InvokeFuture future = createInvokeFuture(request, request.getInvokeContext());
conn.addInvokeFuture(future);
final int requestId = request.getId();
try {
conn.getChannel().writeAndFlush(request).addListener(new ChannelFutureListener() {

@Override
public void operationComplete(ChannelFuture f) throws Exception {
if (!f.isSuccess()) {
conn.removeInvokeFuture(request.getId());
conn.removeInvokeFuture(requestId);
future.putResponse(commandFactory.createSendFailedResponse(
conn.getRemoteAddress(), f.cause()));
logger.error("Invoke send failed, id={}", request.getId(), f.cause());
logger.error("Invoke send failed, id={}", requestId, f.cause());
}
}

});
} catch (Exception e) {
conn.removeInvokeFuture(request.getId());
if (future != null) {
future.putResponse(commandFactory.createSendFailedResponse(conn.getRemoteAddress(),
e));
}
logger.error("Exception caught when sending invocation, id={}", request.getId(), e);
conn.removeInvokeFuture(requestId);
future.putResponse(commandFactory.createSendFailedResponse(conn.getRemoteAddress(), e));
logger.error("Exception caught when sending invocation, id={}", requestId, e);
}
RemotingCommand response = future.waitResponse(timeoutMillis);

if (response == null) {
conn.removeInvokeFuture(request.getId());
conn.removeInvokeFuture(requestId);
response = this.commandFactory.createTimeoutResponse(conn.getRemoteAddress());
logger.warn("Wait response, request id={} timeout!", request.getId());
logger.warn("Wait response, request id={} timeout!", requestId);
}

return response;
Expand All @@ -107,13 +105,12 @@ protected void invokeWithCallback(final Connection conn, final RemotingCommand r
final InvokeFuture future = createInvokeFuture(conn, request, request.getInvokeContext(),
invokeCallback);
conn.addInvokeFuture(future);

final int requestId = request.getId();
try {
//add timeout
Timeout timeout = TimerHolder.getTimer().newTimeout(new TimerTask() {
@Override
public void run(Timeout timeout) throws Exception {
InvokeFuture future = conn.removeInvokeFuture(request.getId());
InvokeFuture future = conn.removeInvokeFuture(requestId);
if (future != null) {
future.putResponse(commandFactory.createTimeoutResponse(conn
.getRemoteAddress()));
Expand All @@ -128,7 +125,7 @@ public void run(Timeout timeout) throws Exception {
@Override
public void operationComplete(ChannelFuture cf) throws Exception {
if (!cf.isSuccess()) {
InvokeFuture f = conn.removeInvokeFuture(request.getId());
InvokeFuture f = conn.removeInvokeFuture(requestId);
if (f != null) {
f.cancelTimeout();
f.putResponse(commandFactory.createSendFailedResponse(
Expand All @@ -142,7 +139,7 @@ public void operationComplete(ChannelFuture cf) throws Exception {

});
} catch (Exception e) {
InvokeFuture f = conn.removeInvokeFuture(request.getId());
InvokeFuture f = conn.removeInvokeFuture(requestId);
if (f != null) {
f.cancelTimeout();
f.putResponse(commandFactory.createSendFailedResponse(conn.getRemoteAddress(), e));
Expand All @@ -166,12 +163,12 @@ protected InvokeFuture invokeWithFuture(final Connection conn, final RemotingCom

final InvokeFuture future = createInvokeFuture(request, request.getInvokeContext());
conn.addInvokeFuture(future);
final int requestId = request.getId();
try {
//add timeout
Timeout timeout = TimerHolder.getTimer().newTimeout(new TimerTask() {
@Override
public void run(Timeout timeout) throws Exception {
InvokeFuture future = conn.removeInvokeFuture(request.getId());
InvokeFuture future = conn.removeInvokeFuture(requestId);
if (future != null) {
future.putResponse(commandFactory.createTimeoutResponse(conn
.getRemoteAddress()));
Expand All @@ -186,7 +183,7 @@ public void run(Timeout timeout) throws Exception {
@Override
public void operationComplete(ChannelFuture cf) throws Exception {
if (!cf.isSuccess()) {
InvokeFuture f = conn.removeInvokeFuture(request.getId());
InvokeFuture f = conn.removeInvokeFuture(requestId);
if (f != null) {
f.cancelTimeout();
f.putResponse(commandFactory.createSendFailedResponse(
Expand All @@ -199,7 +196,7 @@ public void operationComplete(ChannelFuture cf) throws Exception {

});
} catch (Exception e) {
InvokeFuture f = conn.removeInvokeFuture(request.getId());
InvokeFuture f = conn.removeInvokeFuture(requestId);
if (f != null) {
f.cancelTimeout();
f.putResponse(commandFactory.createSendFailedResponse(conn.getRemoteAddress(), e));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@
import java.io.ByteArrayOutputStream;
import java.io.IOException;

import com.alipay.hessian.ClassNameResolver;
import com.alipay.hessian.internal.InternalNameBlackListFilter;
import com.alipay.remoting.exception.CodecException;
import com.caucho.hessian.io.Hessian2Input;
import com.caucho.hessian.io.Hessian2Output;
Expand All @@ -37,13 +35,6 @@ public class HessianSerializer implements Serializer {

private SerializerFactory serializerFactory = new SerializerFactory();

public HessianSerializer() {
//initialize with default black list in hessian
ClassNameResolver resolver = new ClassNameResolver();
resolver.addFilter(new InternalNameBlackListFilter(8192));
serializerFactory.setClassNameResolver(resolver);
}

/**
* @see com.alipay.remoting.serialization.Serializer#serialize(java.lang.Object)
*/
Expand All @@ -59,8 +50,7 @@ public byte[] serialize(Object obj) throws CodecException {
throw new CodecException("IOException occurred when Hessian serializer encode!", e);
}

byte[] bytes = byteArray.toByteArray();
return bytes;
return byteArray.toByteArray();
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ public void testConnectionMonitorByUserSetting() throws InterruptedException, Re
client.getConnection(url, 1000);
}

Thread.sleep(2200);
Thread.sleep(2150);
Assert.assertTrue(1 <= clientDisConnectProcessor.getDisConnectTimes());
Assert.assertEquals(9, clientConnectProcessor.getConnectTimes());
Thread.sleep(200);
Expand Down

0 comments on commit f81103f

Please sign in to comment.