Merge branch 'apache-3.1' into apache-3.2

# Conflicts:
#	dubbo-remoting/dubbo-remoting-api/src/test/java/org/apache/dubbo/remoting/exchange/RequestTest.java
This commit is contained in:
Albumen Kevin 2023-07-06 17:57:11 +08:00
commit e026b5bb59
3 changed files with 6 additions and 3 deletions

View File

@ -18,6 +18,7 @@ package org.apache.dubbo.remoting.exchange;
import org.apache.dubbo.common.utils.StringUtils;
import java.util.concurrent.ThreadLocalRandom;
import java.util.concurrent.atomic.AtomicLong;
import static org.apache.dubbo.common.constants.CommonConstants.HEARTBEAT_EVENT;
@ -27,7 +28,7 @@ import static org.apache.dubbo.common.constants.CommonConstants.HEARTBEAT_EVENT;
*/
public class Request {
private static final AtomicLong INVOKE_ID = new AtomicLong(0);
private static final AtomicLong INVOKE_ID = new AtomicLong(ThreadLocalRandom.current().nextLong());
private final long mId;

View File

@ -23,6 +23,8 @@ class RequestTest {
@Test
void test() {
Request requestStart = new Request();
Request request = new Request();
request.setTwoWay(true);
request.setBroken(true);
@ -36,7 +38,7 @@ class RequestTest {
Assertions.assertTrue(request.isEvent());
Assertions.assertEquals(request.getVersion(), "1.0.0");
Assertions.assertEquals(request.getData(), "data");
Assertions.assertTrue(request.getId() >= 0);
Assertions.assertEquals(requestStart.getId() + 1, request.getId());
Assertions.assertEquals(1024, request.getPayload());
request.setHeartbeat(true);

View File

@ -73,7 +73,7 @@ public interface ObjectInput extends DataInput {
default Throwable readThrowable() throws IOException, ClassNotFoundException {
Object obj = readObject();
if (!(obj instanceof Throwable)) {
throw new IOException("Response data error, expect Throwable, but get " + obj);
throw new IOException("Response data error, expect Throwable, but get " + obj.getClass());
}
return (Throwable) obj;
}