diff --git a/redisson/src/main/java/org/redisson/command/CommandAsyncService.java b/redisson/src/main/java/org/redisson/command/CommandAsyncService.java index ebeaebc4b..35d1cb7a8 100644 --- a/redisson/src/main/java/org/redisson/command/CommandAsyncService.java +++ b/redisson/src/main/java/org/redisson/command/CommandAsyncService.java @@ -464,7 +464,22 @@ public class CommandAsyncService implements CommandAsyncExecutor { return; } - final RPromise attemptPromise = connectionManager.newPromise(); + + final AsyncDetails details = AsyncDetails.acquire(); + if (isRedissonReferenceSupportEnabled()) { + try { + for (int i = 0; i < params.length; i++) { + RedissonReference reference = redisson != null + ? RedissonObjectFactory.toReference(redisson, params[i]) + : RedissonObjectFactory.toReference(redissonReactive, params[i]); + params[i] = reference == null ? params[i] : reference; + } + } catch (Exception e) { + connectionManager.getShutdownLatch().release(); + mainPromise.tryFailure(e); + return; + } + } final RFuture connectionFuture; if (readOnlyMode) { @@ -473,15 +488,7 @@ public class CommandAsyncService implements CommandAsyncExecutor { connectionFuture = connectionManager.connectionWriteOp(source, command); } - final AsyncDetails details = AsyncDetails.acquire(); - if (isRedissonReferenceSupportEnabled()) { - for (int i = 0; i < params.length; i++) { - RedissonReference reference = redisson != null - ? RedissonObjectFactory.toReference(redisson, params[i]) - : RedissonObjectFactory.toReference(redissonReactive, params[i]); - params[i] = reference == null ? params[i] : reference; - } - } + final RPromise attemptPromise = connectionManager.newPromise(); details.init(connectionFuture, attemptPromise, readOnlyMode, source, codec, command, params, mainPromise, attempt); diff --git a/redisson/src/test/java/org/redisson/RedissonLiveObjectServiceTest.java b/redisson/src/test/java/org/redisson/RedissonLiveObjectServiceTest.java index 4ed51fd4b..1659d6e6c 100644 --- a/redisson/src/test/java/org/redisson/RedissonLiveObjectServiceTest.java +++ b/redisson/src/test/java/org/redisson/RedissonLiveObjectServiceTest.java @@ -43,6 +43,7 @@ import org.redisson.api.annotation.RCascade; import org.redisson.api.annotation.REntity; import org.redisson.api.annotation.RFieldAccessor; import org.redisson.api.annotation.RId; +import org.redisson.client.RedisException; import org.redisson.liveobject.resolver.DefaultNamingScheme; import org.redisson.liveobject.resolver.LongGenerator; import org.redisson.liveobject.resolver.UUIDGenerator; @@ -1339,7 +1340,7 @@ public class RedissonLiveObjectServiceTest extends BaseTest { assertThat(se.getItem("2")).isEqualTo(2); } - @Test(expected = IllegalArgumentException.class) + @Test(expected = RedisException.class) public void testObjectShouldNotBeAttached() { Customer customer = new Customer("12"); customer = redisson.getLiveObjectService().persist(customer);