diff --git a/redisson/src/main/java/org/redisson/remote/AsyncRemoteProxy.java b/redisson/src/main/java/org/redisson/remote/AsyncRemoteProxy.java index 2f927ee26..c81c43cee 100644 --- a/redisson/src/main/java/org/redisson/remote/AsyncRemoteProxy.java +++ b/redisson/src/main/java/org/redisson/remote/AsyncRemoteProxy.java @@ -91,14 +91,12 @@ public class AsyncRemoteProxy extends BaseRemoteProxy { InvocationHandler handler = new InvocationHandler() { @Override public Object invoke(Object proxy, Method method, Object[] args) throws Throwable { - String requestId = remoteService.generateRequestId(args); - if (method.getName().equals("toString")) { - return getClass().getSimpleName() + "-" + remoteInterface.getSimpleName() + "-proxy-" + requestId; + return proxy.getClass().getName() + "-" + remoteInterface.getName(); } else if (method.getName().equals("equals")) { return proxy == args[0]; } else if (method.getName().equals("hashCode")) { - return (getClass().getSimpleName() + "-" + remoteInterface.getSimpleName() + "-proxy-" + requestId).hashCode(); + return (proxy.getClass().getName() + "-" + remoteInterface.getName()).hashCode(); } if (!optionsCopy.isResultExpected() && !(method.getReturnType().equals(Void.class) @@ -106,11 +104,9 @@ public class AsyncRemoteProxy extends BaseRemoteProxy { throw new IllegalArgumentException("The noResult option only supports void return value"); } + String requestId = remoteService.generateRequestId(args); String requestQueueName = getRequestQueueName(syncInterface); - Long ackTimeout = optionsCopy.getAckTimeoutInMillis(); - - RemoteServiceRequest request = new RemoteServiceRequest(executorId, requestId, method.getName(), remoteService.getMethodSignature(method), args, optionsCopy, System.currentTimeMillis()); diff --git a/redisson/src/main/java/org/redisson/remote/SyncRemoteProxy.java b/redisson/src/main/java/org/redisson/remote/SyncRemoteProxy.java index e23dca171..91c1d5385 100644 --- a/redisson/src/main/java/org/redisson/remote/SyncRemoteProxy.java +++ b/redisson/src/main/java/org/redisson/remote/SyncRemoteProxy.java @@ -46,20 +46,20 @@ public class SyncRemoteProxy extends BaseRemoteProxy { InvocationHandler handler = new InvocationHandler() { @Override public Object invoke(Object proxy, Method method, Object[] args) throws Throwable { - String requestId = remoteService.generateRequestId(args); - if (method.getName().equals("toString")) { - return getClass().getSimpleName() + "-" + remoteInterface.getSimpleName() + "-proxy-" + requestId; + return proxy.getClass().getName() + "-" + remoteInterface.getName(); } else if (method.getName().equals("equals")) { return proxy == args[0]; } else if (method.getName().equals("hashCode")) { - return (getClass().getSimpleName() + "-" + remoteInterface.getSimpleName() + "-proxy-" + requestId).hashCode(); + return (proxy.getClass().getName() + "-" + remoteInterface.getName()).hashCode(); } if (!optionsCopy.isResultExpected() - && !(method.getReturnType().equals(Void.class) || method.getReturnType().equals(Void.TYPE))) + && !(method.getReturnType().equals(Void.class) || method.getReturnType().equals(Void.TYPE))) { throw new IllegalArgumentException("The noResult option only supports void return value"); + } + String requestId = remoteService.generateRequestId(args); String requestQueueName = getRequestQueueName(remoteInterface); RemoteServiceRequest request = new RemoteServiceRequest(executorId, requestId, method.getName(), remoteService.getMethodSignature(method), args, optionsCopy, System.currentTimeMillis()); diff --git a/redisson/src/test/java/org/redisson/RedissonRemoteServiceTest.java b/redisson/src/test/java/org/redisson/RedissonRemoteServiceTest.java index dd1d36add..91f7ddb09 100644 --- a/redisson/src/test/java/org/redisson/RedissonRemoteServiceTest.java +++ b/redisson/src/test/java/org/redisson/RedissonRemoteServiceTest.java @@ -669,25 +669,9 @@ public class RedissonRemoteServiceTest extends BaseTest { RedissonClient client = createInstance(); try { RemoteInterface service = client.getRemoteService().get(RemoteInterface.class); - - try { - System.out.println(service.toString()); - } catch (Exception e) { - Assertions.fail("calling toString on the client service proxy should not make a remote call"); - } - - try { - assertThat(service.hashCode() == service.hashCode()).isTrue(); - } catch (Exception e) { - Assertions.fail("calling hashCode on the client service proxy should not make a remote call"); - } - - try { - assertThat(service.equals(service)).isTrue(); - } catch (Exception e) { - Assertions.fail("calling equals on the client service proxy should not make a remote call"); - } - + assertThat(service.toString()).contains(RemoteInterface.class.getName()); + assertThat(service.hashCode()).isEqualTo(service.hashCode()); + assertThat(service).isEqualTo(service); } finally { client.shutdown(); }