|
|
|
@ -768,73 +768,80 @@ public class CommandAsyncService implements CommandAsyncExecutor {
|
|
|
|
|
((RedisClientResult)res).setRedisClient(addr);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (isRedissonReferenceSupportEnabled() && (res instanceof List || res instanceof ListScanResult)) {
|
|
|
|
|
List r = res instanceof ListScanResult ? ((ListScanResult)res).getValues() : (List) res;
|
|
|
|
|
for (int i = 0; i < r.size(); i++) {
|
|
|
|
|
if (r.get(i) instanceof RedissonReference) {
|
|
|
|
|
try {
|
|
|
|
|
r.set(i ,(redisson != null
|
|
|
|
|
? RedissonObjectFactory.<R>fromReference(redisson, (RedissonReference) r.get(i))
|
|
|
|
|
: RedissonObjectFactory.<R>fromReference(redissonReactive, (RedissonReference) r.get(i))));
|
|
|
|
|
} catch (Exception exception) {//skip and carry on to next one.
|
|
|
|
|
}
|
|
|
|
|
} else if (r.get(i) instanceof ScoredEntry && ((ScoredEntry) r.get(i)).getValue() instanceof RedissonReference) {
|
|
|
|
|
try {
|
|
|
|
|
ScoredEntry se = ((ScoredEntry) r.get(i));
|
|
|
|
|
r.set(i ,new ScoredEntry(se.getScore(), redisson != null
|
|
|
|
|
? RedissonObjectFactory.<R>fromReference(redisson, (RedissonReference) se.getValue())
|
|
|
|
|
: RedissonObjectFactory.<R>fromReference(redissonReactive, (RedissonReference) se.getValue())));
|
|
|
|
|
} catch (Exception exception) {//skip and carry on to next one.
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (isRedissonReferenceSupportEnabled()) {
|
|
|
|
|
handleReference(details.getMainPromise(), res);
|
|
|
|
|
} else {
|
|
|
|
|
details.getMainPromise().trySuccess(res);
|
|
|
|
|
} else if (isRedissonReferenceSupportEnabled() && (res instanceof MapScanResult)) {
|
|
|
|
|
Map<ScanObjectEntry, ScanObjectEntry> map = ((MapScanResult)res).getMap();
|
|
|
|
|
HashMap<ScanObjectEntry, ScanObjectEntry> toAdd = null;
|
|
|
|
|
for (Map.Entry<ScanObjectEntry, ScanObjectEntry> e : (Set<Map.Entry<ScanObjectEntry, ScanObjectEntry>>) map.entrySet()) {
|
|
|
|
|
if (e.getValue().getObj() instanceof RedissonReference) {
|
|
|
|
|
try {
|
|
|
|
|
e.setValue(new ScanObjectEntry(e.getValue().getBuf(), redisson != null
|
|
|
|
|
? RedissonObjectFactory.<R>fromReference(redisson, (RedissonReference) e.getValue().getObj())
|
|
|
|
|
: RedissonObjectFactory.<R>fromReference(redissonReactive, (RedissonReference) e.getValue().getObj())));
|
|
|
|
|
} catch (Exception exception) {//skip and carry on to next one.
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
details.getMainPromise().tryFailure(future.cause());
|
|
|
|
|
}
|
|
|
|
|
AsyncDetails.release(details);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private <R, V> void handleReference(RPromise<R> mainPromise, R res) {
|
|
|
|
|
if (res instanceof List || res instanceof ListScanResult) {
|
|
|
|
|
List r = res instanceof ListScanResult ? ((ListScanResult)res).getValues() : (List) res;
|
|
|
|
|
for (int i = 0; i < r.size(); i++) {
|
|
|
|
|
if (r.get(i) instanceof RedissonReference) {
|
|
|
|
|
try {
|
|
|
|
|
r.set(i ,(redisson != null
|
|
|
|
|
? RedissonObjectFactory.<R>fromReference(redisson, (RedissonReference) r.get(i))
|
|
|
|
|
: RedissonObjectFactory.<R>fromReference(redissonReactive, (RedissonReference) r.get(i))));
|
|
|
|
|
} catch (Exception exception) {//skip and carry on to next one.
|
|
|
|
|
}
|
|
|
|
|
if (e.getKey().getObj() instanceof RedissonReference) {
|
|
|
|
|
if (toAdd == null) {
|
|
|
|
|
toAdd = new HashMap<ScanObjectEntry, ScanObjectEntry>();
|
|
|
|
|
}
|
|
|
|
|
toAdd.put(e.getKey(), e.getValue());
|
|
|
|
|
} else if (r.get(i) instanceof ScoredEntry && ((ScoredEntry) r.get(i)).getValue() instanceof RedissonReference) {
|
|
|
|
|
try {
|
|
|
|
|
ScoredEntry se = ((ScoredEntry) r.get(i));
|
|
|
|
|
r.set(i ,new ScoredEntry(se.getScore(), redisson != null
|
|
|
|
|
? RedissonObjectFactory.<R>fromReference(redisson, (RedissonReference) se.getValue())
|
|
|
|
|
: RedissonObjectFactory.<R>fromReference(redissonReactive, (RedissonReference) se.getValue())));
|
|
|
|
|
} catch (Exception exception) {//skip and carry on to next one.
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (toAdd != null) {
|
|
|
|
|
for (Map.Entry<ScanObjectEntry, ScanObjectEntry> e : (Set<Map.Entry<ScanObjectEntry, ScanObjectEntry>>) toAdd.entrySet()) {
|
|
|
|
|
try {
|
|
|
|
|
map.put(new ScanObjectEntry(e.getValue().getBuf(), (redisson != null
|
|
|
|
|
? RedissonObjectFactory.<R>fromReference(redisson, (RedissonReference) e.getKey().getObj())
|
|
|
|
|
: RedissonObjectFactory.<R>fromReference(redissonReactive, (RedissonReference) e.getKey().getObj()))), map.remove(e.getKey()));
|
|
|
|
|
} catch (Exception exception) {//skip and carry on to next one.
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
mainPromise.trySuccess(res);
|
|
|
|
|
} else if (res instanceof MapScanResult) {
|
|
|
|
|
Map<ScanObjectEntry, ScanObjectEntry> map = ((MapScanResult)res).getMap();
|
|
|
|
|
HashMap<ScanObjectEntry, ScanObjectEntry> toAdd = null;
|
|
|
|
|
for (Map.Entry<ScanObjectEntry, ScanObjectEntry> e : map.entrySet()) {
|
|
|
|
|
if (e.getValue().getObj() instanceof RedissonReference) {
|
|
|
|
|
try {
|
|
|
|
|
e.setValue(new ScanObjectEntry(e.getValue().getBuf(), redisson != null
|
|
|
|
|
? RedissonObjectFactory.<R>fromReference(redisson, (RedissonReference) e.getValue().getObj())
|
|
|
|
|
: RedissonObjectFactory.<R>fromReference(redissonReactive, (RedissonReference) e.getValue().getObj())));
|
|
|
|
|
} catch (Exception exception) {//skip and carry on to next one.
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
details.getMainPromise().trySuccess(res);
|
|
|
|
|
} else if (isRedissonReferenceSupportEnabled() && (res instanceof MapScanResult)) {
|
|
|
|
|
} else if (isRedissonReferenceSupportEnabled() && res instanceof RedissonReference) {
|
|
|
|
|
try {
|
|
|
|
|
details.getMainPromise().trySuccess(redisson != null
|
|
|
|
|
? RedissonObjectFactory.<R>fromReference(redisson, (RedissonReference) res)
|
|
|
|
|
: RedissonObjectFactory.<R>fromReference(redissonReactive, (RedissonReference) res));
|
|
|
|
|
} catch (Exception exception) {
|
|
|
|
|
details.getMainPromise().trySuccess(res);//fallback
|
|
|
|
|
if (e.getKey().getObj() instanceof RedissonReference) {
|
|
|
|
|
if (toAdd == null) {
|
|
|
|
|
toAdd = new HashMap<ScanObjectEntry, ScanObjectEntry>();
|
|
|
|
|
}
|
|
|
|
|
toAdd.put(e.getKey(), e.getValue());
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
details.getMainPromise().trySuccess(res);
|
|
|
|
|
}
|
|
|
|
|
if (toAdd != null) {
|
|
|
|
|
for (Map.Entry<ScanObjectEntry, ScanObjectEntry> e : toAdd.entrySet()) {
|
|
|
|
|
try {
|
|
|
|
|
map.put(new ScanObjectEntry(e.getValue().getBuf(), (redisson != null
|
|
|
|
|
? RedissonObjectFactory.<R>fromReference(redisson, (RedissonReference) e.getKey().getObj())
|
|
|
|
|
: RedissonObjectFactory.<R>fromReference(redissonReactive, (RedissonReference) e.getKey().getObj()))), map.remove(e.getKey()));
|
|
|
|
|
} catch (Exception exception) {//skip and carry on to next one.
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
mainPromise.trySuccess(res);
|
|
|
|
|
} else if (res instanceof RedissonReference) {
|
|
|
|
|
try {
|
|
|
|
|
mainPromise.trySuccess(redisson != null
|
|
|
|
|
? RedissonObjectFactory.<R>fromReference(redisson, (RedissonReference) res)
|
|
|
|
|
: RedissonObjectFactory.<R>fromReference(redissonReactive, (RedissonReference) res));
|
|
|
|
|
} catch (Exception exception) {
|
|
|
|
|
mainPromise.trySuccess(res);//fallback
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
details.getMainPromise().tryFailure(future.cause());
|
|
|
|
|
mainPromise.trySuccess(res);
|
|
|
|
|
}
|
|
|
|
|
AsyncDetails.release(details);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|