Skip to content

Commit

Permalink
optimize: Local variable 'map' is redundant and check queue offer ret…
Browse files Browse the repository at this point in the history
…urn value (apache#3188)
  • Loading branch information
everyhook1 committed Nov 11, 2020
1 parent 43f5890 commit 69f341a
Showing 1 changed file with 5 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,11 @@ public Object sendSyncRequest(Object msg) throws TimeoutException {
// put message into basketMap
BlockingQueue<RpcMessage> basket = CollectionUtils.computeIfAbsent(basketMap, serverAddress,
key -> new LinkedBlockingQueue<>());
basket.offer(rpcMessage);
if (!basket.offer(rpcMessage)) {
LOGGER.error("put message into basketMap offer failed, serverAddress:{},rpcMessage:{}",
serverAddress, rpcMessage);
return null;
}
if (LOGGER.isDebugEnabled()) {
LOGGER.debug("offer message: {}", rpcMessage.getBody());
}
Expand Down

0 comments on commit 69f341a

Please sign in to comment.