Details
-
Improvement
-
Status: Resolved
-
Trivial
-
Resolution: Fixed
-
3.5.5
Description
Dear developer:
I think the following code in line 623 of the QuorumCnxManager class can be optimized:
ArrayBlockingQueue<ByteBuffer> bq = new ArrayBlockingQueue<ByteBuffer>( SEND_CAPACITY); ArrayBlockingQueue<ByteBuffer> oldq = queueSendMap.putIfAbsent(sid, bq); if (oldq != null) { addToSendQueue(oldq, b); } else { addToSendQueue(bq, b); }
The optimization is as follows:
ArrayBlockingQueue<ByteBuffer> bq = queueSendMap.computeIfAbsent(sid, serverId
-> new ArrayBlockingQueue<>(SEND_CAPACITY));
addToSendQueue(bq, b);