Skip to content

Commit 24dd92c

Browse files
committed
Unset init flag in management
1 parent e483679 commit 24dd92c

File tree

2 files changed

+23
-6
lines changed

2 files changed

+23
-6
lines changed

src/main/java/com/rabbitmq/client/amqp/impl/AmqpManagement.java

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -226,13 +226,18 @@ public void close() {
226226
}
227227

228228
void init() {
229-
if (this.state() != OPEN) {
229+
String cName = this.connection.name();
230+
LOGGER.debug("Trying to initialize management for connection {}", cName);
231+
State state = this.state();
232+
if (state != OPEN) {
230233
if (!this.initializing) {
231234
try {
232235
initializationLock.lock();
233-
if (!this.initializing && this.state() != OPEN) {
236+
boolean initInProgress = this.initializing;
237+
state = this.state();
238+
if (!initInProgress && state != OPEN) {
234239
this.initializing = true;
235-
LOGGER.debug("Initializing management ({}).", this);
240+
LOGGER.debug("Initializing management for connection {} ({}).", cName, this);
236241
this.markUnavailable();
237242
try {
238243
if (this.receiveLoop != null) {
@@ -267,15 +272,27 @@ void init() {
267272
this.receiver.openFuture().get(this.rpcTimeout.toMillis(), MILLISECONDS);
268273
LOGGER.debug("Management receiver created ({}).", this);
269274
this.state(OPEN);
270-
this.initializing = false;
271275
} catch (Exception e) {
276+
LOGGER.info("Error during management {} initialization: {}", cName, e.getMessage());
272277
throw new AmqpException(e);
278+
} finally {
279+
this.initializing = false;
273280
}
281+
} else {
282+
LOGGER.debug(
283+
"Not initializing management {}: init in progress {}, state {}",
284+
cName,
285+
initInProgress,
286+
state);
274287
}
275288
} finally {
276289
initializationLock.unlock();
277290
}
291+
} else {
292+
LOGGER.debug("Not initializing management {} because it is already initializing", cName);
278293
}
294+
} else {
295+
LOGGER.debug("Not initializing management {} because state is {}", cName, state);
279296
}
280297
}
281298

src/test/resources/logback-test.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,15 @@
1010
<logger name="com.rabbitmq.client.amqp" level="warn" />
1111
<logger name="org.apache.qpid" level="error" />
1212
<logger name="com.rabbitmq.client.amqp.perf" level="info" />
13-
<logger name="com.rabbitmq.client.amqp.impl.ConnectionUtils" level="warn" />
13+
<logger name="com.rabbitmq.client.amqp.impl.ConnectionUtils" level="debug" />
1414
<logger name="com.rabbitmq.client.amqp.impl.AmqpConnection" level="debug" />
1515
<logger name="com.rabbitmq.client.amqp.impl.RecoveryClusterTest" level="info" />
1616
<logger name="com.rabbitmq.client.amqp.impl.RecordingTopologyListener" level="warn" />
1717
<logger name="com.rabbitmq.client.amqp.impl.ConnectionUtils" level="warn" />
1818
<logger name="com.rabbitmq.client.amqp.impl.AsyncRetry" level="debug" />
1919
<logger name="com.rabbitmq.client.amqp.impl.EntityRecovery" level="warn" />
2020
<logger name="com.rabbitmq.client.amqp.impl.EventLoop" level="warn" />
21-
<logger name="com.rabbitmq.client.amqp.impl.AmqpManagement" level="info" />
21+
<logger name="com.rabbitmq.client.amqp.impl.AmqpManagement" level="debug" />
2222
<logger name="com.rabbitmq.client.amqp.impl.AmqpPublisher" level="warn" />
2323
<logger name="com.rabbitmq.client.amqp.impl.AmqpConsumer" level="warn" />
2424
<logger name="com.rabbitmq.client.amqp.impl.RetryUtils" level="warn" />

0 commit comments

Comments
 (0)