Skip to content

Commit 9491d2c

Browse files
committed
Merge remote-tracking branch 'dubbo_remote/master' into upgrade_junt_to_junit5
2 parents 76d44d8 + 2cbc83f commit 9491d2c

File tree

41 files changed

+200
-54
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+200
-54
lines changed

dubbo-remoting/dubbo-remoting-api/src/main/java/org/apache/dubbo/remoting/exchange/support/header/ReconnectTimerTask.java

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -38,24 +38,26 @@ public class ReconnectTimerTask extends AbstractTimerTask {
3838

3939
@Override
4040
protected void doTask(Channel channel) {
41-
try {
42-
Long lastRead = lastRead(channel);
43-
Long now = now();
44-
if (lastRead != null && now - lastRead > heartbeatTimeout) {
45-
logger.warn("Close channel " + channel + ", because heartbeat read idle time out: "
46-
+ heartbeatTimeout + "ms");
47-
if (channel instanceof Client) {
48-
try {
49-
((Client) channel).reconnect();
50-
} catch (Exception e) {
51-
//do nothing
52-
}
53-
} else {
41+
Long lastRead = lastRead(channel);
42+
Long now = now();
43+
if (lastRead != null && now - lastRead > heartbeatTimeout) {
44+
if (channel instanceof Client) {
45+
try {
46+
logger.warn("Reconnect to remote channel " + channel.getRemoteAddress() + ", because heartbeat read idle time out: "
47+
+ heartbeatTimeout + "ms");
48+
((Client) channel).reconnect();
49+
} catch (Throwable t) {
50+
// do nothing
51+
}
52+
} else {
53+
try {
54+
logger.warn("Close channel " + channel + ", because heartbeat read idle time out: "
55+
+ heartbeatTimeout + "ms");
5456
channel.close();
57+
} catch (Throwable t) {
58+
logger.warn("Exception when close channel " + channel, t);
5559
}
5660
}
57-
} catch (Throwable t) {
58-
logger.warn("Exception when reconnect to remote channel " + channel.getRemoteAddress(), t);
5961
}
6062
}
6163
}

dubbo-rpc/dubbo-rpc-api/src/main/java/org/apache/dubbo/rpc/AbstractResult.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616
*/
1717
package org.apache.dubbo.rpc;
1818

19+
import org.apache.dubbo.common.utils.StringUtils;
20+
1921
import java.util.HashMap;
2022
import java.util.Map;
2123

@@ -58,7 +60,7 @@ public String getAttachment(String key) {
5860
@Override
5961
public String getAttachment(String key, String defaultValue) {
6062
String result = attachments.get(key);
61-
if (result == null || result.length() == 0) {
63+
if (StringUtils.isEmpty(result)) {
6264
result = defaultValue;
6365
}
6466
return result;

dubbo-rpc/dubbo-rpc-api/src/main/java/org/apache/dubbo/rpc/RpcContext.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
import org.apache.dubbo.common.URL;
2121
import org.apache.dubbo.common.threadlocal.InternalThreadLocal;
2222
import org.apache.dubbo.common.utils.NetUtils;
23+
import org.apache.dubbo.common.utils.StringUtils;
2324

2425
import java.net.InetSocketAddress;
2526
import java.util.ArrayList;
@@ -364,7 +365,7 @@ public String getLocalAddressString() {
364365
*/
365366
public String getLocalHostName() {
366367
String host = localAddress == null ? null : localAddress.getHostName();
367-
if (host == null || host.length() == 0) {
368+
if (StringUtils.isEmpty(host)) {
368369
return getLocalHost();
369370
}
370371
return host;

dubbo-rpc/dubbo-rpc-api/src/main/java/org/apache/dubbo/rpc/RpcException.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,10 @@
3434
public static final int SERIALIZATION_EXCEPTION = 5;
3535
public static final int NO_INVOKER_AVAILABLE_AFTER_FILTER = 6;
3636
private static final long serialVersionUID = 7815426752583648734L;
37-
private int code; // RpcException cannot be extended, use error code for exception type to keep compatibility
37+
/**
38+
* RpcException cannot be extended, use error code for exception type to keep compatibility
39+
*/
40+
private int code;
3841

3942
public RpcException() {
4043
super();

dubbo-rpc/dubbo-rpc-api/src/main/java/org/apache/dubbo/rpc/RpcInvocation.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818

1919
import org.apache.dubbo.common.Constants;
2020
import org.apache.dubbo.common.URL;
21+
import org.apache.dubbo.common.utils.StringUtils;
2122

2223
import java.io.Serializable;
2324
import java.lang.reflect.Method;
@@ -198,7 +199,7 @@ public String getAttachment(String key, String defaultValue) {
198199
return defaultValue;
199200
}
200201
String value = attachments.get(key);
201-
if (value == null || value.length() == 0) {
202+
if (StringUtils.isEmpty(value)) {
202203
return defaultValue;
203204
}
204205
return value;

dubbo-rpc/dubbo-rpc-api/src/main/java/org/apache/dubbo/rpc/service/GenericService.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ public interface GenericService {
3131
* @param parameterTypes Parameter types
3232
* @param args Arguments
3333
* @return invocation return value
34-
* @throws Throwable potential exception thrown from the invocation
34+
* @throws GenericException potential exception thrown from the invocation
3535
*/
3636
Object $invoke(String method, String[] parameterTypes, Object[] args) throws GenericException;
3737

dubbo-serialization/dubbo-serialization-api/src/main/java/org/apache/dubbo/common/serialize/Cleanable.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,13 @@
1616
*/
1717
package org.apache.dubbo.common.serialize;
1818

19+
/**
20+
* Interface defines that the object is cleanable.
21+
*/
1922
public interface Cleanable {
2023

24+
/**
25+
* Implementations must implement this cleanup method
26+
*/
2127
void cleanup();
2228
}

dubbo-serialization/dubbo-serialization-api/src/main/java/org/apache/dubbo/common/serialize/DataInput.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
import java.io.IOException;
2020

2121
/**
22-
* Data input.
22+
* Basic data type input interface.
2323
*/
2424
public interface DataInput {
2525

dubbo-serialization/dubbo-serialization-api/src/main/java/org/apache/dubbo/common/serialize/DataOutput.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
import java.io.IOException;
2020

2121
/**
22-
* Data output.
22+
* Basic data type output interface.
2323
*/
2424
public interface DataOutput {
2525

@@ -98,9 +98,9 @@ public interface DataOutput {
9898
/**
9999
* Write byte array.
100100
*
101-
* @param v value.
102-
* @param off offset.
103-
* @param len length.
101+
* @param v value.
102+
* @param off the start offset in the data.
103+
* @param len the number of bytes that are written.
104104
* @throws IOException
105105
*/
106106
void writeBytes(byte[] v, int off, int len) throws IOException;

dubbo-serialization/dubbo-serialization-api/src/main/java/org/apache/dubbo/common/serialize/ObjectInput.java

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -20,30 +20,37 @@
2020
import java.lang.reflect.Type;
2121

2222
/**
23-
* Object input.
23+
* Object input interface.
2424
*/
2525
public interface ObjectInput extends DataInput {
2626

2727
/**
28-
* read object.
28+
* read object
2929
*
30-
* @return object.
30+
* @return object
31+
* @throws IOException if an I/O error occurs
32+
* @throws ClassNotFoundException if an ClassNotFoundException occurs
3133
*/
3234
Object readObject() throws IOException, ClassNotFoundException;
3335

3436
/**
35-
* read object.
37+
* read object
3638
*
37-
* @param cls object type.
38-
* @return object.
39+
* @param cls object class
40+
* @return object
41+
* @throws IOException if an I/O error occurs
42+
* @throws ClassNotFoundException if an ClassNotFoundException occurs
3943
*/
4044
<T> T readObject(Class<T> cls) throws IOException, ClassNotFoundException;
4145

4246
/**
43-
* read object.
47+
* read object
4448
*
45-
* @param cls object type.
46-
* @return object.
49+
* @param cls object class
50+
* @param type object type
51+
* @return object
52+
* @throws IOException if an I/O error occurs
53+
* @throws ClassNotFoundException if an ClassNotFoundException occurs
4754
*/
4855
<T> T readObject(Class<T> cls, Type type) throws IOException, ClassNotFoundException;
4956

0 commit comments

Comments
 (0)