Skip to content

Commit 8e855a3

Browse files
committed
renamed Mutex => Lock
1 parent d061fe3 commit 8e855a3

File tree

2 files changed

+43
-43
lines changed

2 files changed

+43
-43
lines changed

src/main/java/com/rabbitmq/client/impl/AMQChannel.java

Lines changed: 32 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,8 @@ public abstract class AMQChannel extends ShutdownNotifierComponent {
5656
* so that clients can themselves use the channel to synchronize
5757
* on.
5858
*/
59-
protected final ReentrantLock _channelMutex = new ReentrantLock();
60-
protected final Condition _channelMutexCondition = _channelMutex.newCondition();
59+
protected final ReentrantLock _channelLock = new ReentrantLock();
60+
protected final Condition _channelLockCondition = _channelLock.newCondition();
6161

6262
/** The connection this channel is associated with. */
6363
private final AMQConnection _connection;
@@ -194,7 +194,7 @@ public void handleCompleteInboundCommand(AMQCommand command) throws IOException
194194
// so it must be a response to an earlier RPC.
195195

196196
if (_checkRpcResponseType) {
197-
_channelMutex.lock();
197+
_channelLock.lock();
198198
try {
199199
// check if this reply command is intended for the current waiting request before calling nextOutstandingRpc()
200200
if (_activeRpc != null && !_activeRpc.canHandleReply(command)) {
@@ -204,7 +204,7 @@ public void handleCompleteInboundCommand(AMQCommand command) throws IOException
204204
return;
205205
}
206206
} finally {
207-
_channelMutex.unlock();
207+
_channelLock.unlock();
208208
}
209209
}
210210
final RpcWrapper nextOutstandingRpc = nextOutstandingRpc();
@@ -226,12 +226,12 @@ public void enqueueAsyncRpc(Method method, CompletableFuture<Command> future) {
226226
}
227227

228228
private void doEnqueueRpc(Supplier<RpcWrapper> rpcWrapperSupplier) {
229-
_channelMutex.lock();
229+
_channelLock.lock();
230230
try {
231231
boolean waitClearedInterruptStatus = false;
232232
while (_activeRpc != null) {
233233
try {
234-
_channelMutexCondition.await();
234+
_channelLockCondition.await();
235235
} catch (InterruptedException e) { //NOSONAR
236236
waitClearedInterruptStatus = true;
237237
// No Sonar: we re-interrupt the thread later
@@ -242,30 +242,30 @@ private void doEnqueueRpc(Supplier<RpcWrapper> rpcWrapperSupplier) {
242242
}
243243
_activeRpc = rpcWrapperSupplier.get();
244244
} finally {
245-
_channelMutex.unlock();
245+
_channelLock.unlock();
246246
}
247247
}
248248

249249
public boolean isOutstandingRpc()
250250
{
251-
_channelMutex.lock();
251+
_channelLock.lock();
252252
try {
253253
return (_activeRpc != null);
254254
} finally {
255-
_channelMutex.unlock();
255+
_channelLock.unlock();
256256
}
257257
}
258258

259259
public RpcWrapper nextOutstandingRpc()
260260
{
261-
_channelMutex.lock();
261+
_channelLock.lock();
262262
try {
263263
RpcWrapper result = _activeRpc;
264264
_activeRpc = null;
265-
_channelMutexCondition.signalAll();
265+
_channelLockCondition.signalAll();
266266
return result;
267267
} finally {
268-
_channelMutex.unlock();
268+
_channelLock.unlock();
269269
}
270270
}
271271

@@ -359,48 +359,48 @@ private AMQCommand privateRpc(Method m, int timeout)
359359
public void rpc(Method m, RpcContinuation k)
360360
throws IOException
361361
{
362-
_channelMutex.lock();
362+
_channelLock.lock();
363363
try {
364364
ensureIsOpen();
365365
quiescingRpc(m, k);
366366
} finally {
367-
_channelMutex.unlock();
367+
_channelLock.unlock();
368368
}
369369
}
370370

371371
public void quiescingRpc(Method m, RpcContinuation k)
372372
throws IOException
373373
{
374-
_channelMutex.lock();
374+
_channelLock.lock();
375375
try {
376376
enqueueRpc(k);
377377
quiescingTransmit(m);
378378
} finally {
379-
_channelMutex.unlock();
379+
_channelLock.unlock();
380380
}
381381
}
382382

383383
public void asyncRpc(Method m, CompletableFuture<Command> future)
384384
throws IOException
385385
{
386-
_channelMutex.lock();
386+
_channelLock.lock();
387387
try {
388388
ensureIsOpen();
389389
quiescingAsyncRpc(m, future);
390390
} finally {
391-
_channelMutex.unlock();
391+
_channelLock.unlock();
392392
}
393393
}
394394

395395
public void quiescingAsyncRpc(Method m, CompletableFuture<Command> future)
396396
throws IOException
397397
{
398-
_channelMutex.lock();
398+
_channelLock.lock();
399399
try {
400400
enqueueAsyncRpc(m, future);
401401
quiescingTransmit(m);
402402
} finally {
403-
_channelMutex.unlock();
403+
_channelLock.unlock();
404404
}
405405
}
406406

@@ -429,16 +429,16 @@ public void processShutdownSignal(ShutdownSignalException signal,
429429
boolean ignoreClosed,
430430
boolean notifyRpc) {
431431
try {
432-
_channelMutex.lock();
432+
_channelLock.lock();
433433
try {
434434
if (!setShutdownCauseIfOpen(signal)) {
435435
if (!ignoreClosed)
436436
throw new AlreadyClosedException(getCloseReason());
437437
}
438438

439-
_channelMutexCondition.signalAll();
439+
_channelLockCondition.signalAll();
440440
} finally {
441-
_channelMutex.unlock();
441+
_channelLock.unlock();
442442
}
443443
} finally {
444444
if (notifyRpc)
@@ -454,40 +454,40 @@ public void notifyOutstandingRpc(ShutdownSignalException signal) {
454454
}
455455

456456
public void transmit(Method m) throws IOException {
457-
_channelMutex.lock();
457+
_channelLock.lock();
458458
try {
459459
transmit(new AMQCommand(m));
460460
} finally {
461-
_channelMutex.unlock();
461+
_channelLock.unlock();
462462
}
463463
}
464464

465465
public void transmit(AMQCommand c) throws IOException {
466-
_channelMutex.lock();
466+
_channelLock.lock();
467467
try {
468468
ensureIsOpen();
469469
quiescingTransmit(c);
470470
} finally {
471-
_channelMutex.unlock();
471+
_channelLock.unlock();
472472
}
473473
}
474474

475475
public void quiescingTransmit(Method m) throws IOException {
476-
_channelMutex.lock();
476+
_channelLock.lock();
477477
try {
478478
quiescingTransmit(new AMQCommand(m));
479479
} finally {
480-
_channelMutex.unlock();
480+
_channelLock.unlock();
481481
}
482482
}
483483

484484
public void quiescingTransmit(AMQCommand c) throws IOException {
485-
_channelMutex.lock();
485+
_channelLock.lock();
486486
try {
487487
if (c.getMethod().hasContent()) {
488488
while (_blockContent) {
489489
try {
490-
_channelMutexCondition.await();
490+
_channelLockCondition.await();
491491
} catch (InterruptedException ignored) {
492492
Thread.currentThread().interrupt();
493493
}
@@ -501,7 +501,7 @@ public void quiescingTransmit(AMQCommand c) throws IOException {
501501
this._trafficListener.write(c);
502502
c.transmit(this);
503503
} finally {
504-
_channelMutex.unlock();
504+
_channelLock.unlock();
505505
}
506506
}
507507

src/main/java/com/rabbitmq/client/impl/ChannelN.java

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -361,13 +361,13 @@ private void releaseChannel() {
361361
return true;
362362
} else if (method instanceof Channel.Flow) {
363363
Channel.Flow channelFlow = (Channel.Flow) method;
364-
_channelMutex.lock();
364+
_channelLock.lock();
365365
try {
366366
_blockContent = !channelFlow.getActive();
367367
transmit(new Channel.FlowOk(!_blockContent));
368-
_channelMutexCondition.signalAll();
368+
_channelLockCondition.signalAll();
369369
} finally {
370-
_channelMutex.unlock();
370+
_channelLock.unlock();
371371
}
372372
return true;
373373
} else if (method instanceof Basic.Ack) {
@@ -527,7 +527,7 @@ private void asyncShutdown(Command command) throws IOException {
527527
false,
528528
command.getMethod(),
529529
this);
530-
_channelMutex.lock();
530+
_channelLock.lock();
531531
try {
532532
try {
533533
processShutdownSignal(signal, true, false);
@@ -538,7 +538,7 @@ private void asyncShutdown(Command command) throws IOException {
538538
}
539539
}
540540
finally {
541-
_channelMutex.unlock();
541+
_channelLock.unlock();
542542
}
543543
notifyListeners();
544544
}
@@ -619,12 +619,12 @@ public AMQCommand transformReply(AMQCommand command) {
619619
try {
620620
// Synchronize the block below to avoid race conditions in case
621621
// connection wants to send Connection-CloseOK
622-
_channelMutex.lock();
622+
_channelLock.lock();
623623
try {
624624
startProcessShutdownSignal(signal, !initiatedByApplication, true);
625625
quiescingRpc(reason, k);
626626
} finally {
627-
_channelMutex.unlock();
627+
_channelLock.unlock();
628628
}
629629

630630
// Now that we're in quiescing state, channel.close was sent and
@@ -1612,22 +1612,22 @@ public CompletableFuture<Command> asyncCompletableRpc(Method method) throws IOEx
16121612

16131613
@Override
16141614
public void enqueueRpc(RpcContinuation k) {
1615-
_channelMutex.lock();
1615+
_channelLock.lock();
16161616
try {
16171617
super.enqueueRpc(k);
16181618
dispatcher.setUnlimited(true);
16191619
} finally {
1620-
_channelMutex.unlock();
1620+
_channelLock.unlock();
16211621
}
16221622
}
16231623

16241624
@Override
16251625
protected void markRpcFinished() {
1626-
_channelMutex.lock();
1626+
_channelLock.lock();
16271627
try {
16281628
dispatcher.setUnlimited(false);
16291629
} finally {
1630-
_channelMutex.unlock();
1630+
_channelLock.unlock();
16311631
}
16321632
}
16331633

0 commit comments

Comments
 (0)