in qpid-jms-client/src/main/java/org/apache/qpid/jms/JmsConnection.java [187:267]
public void close() throws JMSException {
boolean interrupted = Thread.interrupted();
for (JmsSession session : sessions.values()) {
session.checkIsDeliveryThread();
session.checkIsCompletionThread();
}
try {
if (!closed.get() && !isFailed()) {
// do not fail if already closed as specified by the JMS specification.
doStop(false);
}
synchronized (this) {
if (closed.get()) {
return;
}
closing.set(true);
for (JmsSession session : sessions.values()) {
session.shutdown();
}
for (JmsConnectionConsumer connectionConsumer : connectionConsumers.values()) {
connectionConsumer.shutdown();
}
if (isConnected() && !isFailed()) {
ProviderFuture request = provider.newProviderFuture();
requests.put(request, request);
try {
provider.destroy(connectionInfo, request);
try {
request.sync();
} catch (Exception ex) {
// NOTE - Spec is a bit vague here, we don't fail if already closed but
// in this case we really aren't closed yet so there could be an
// argument that at this point an exception is still valid.
if (ex.getCause() instanceof InterruptedException) {
throw (InterruptedException) ex.getCause();
}
LOG.debug("Failed destroying Connection resource: {}", ex.getMessage());
}
} catch(ProviderException prodiverError) {
LOG.debug("Ignoring provider exception during connection close");
} finally {
requests.remove(request);
}
}
sessions.clear();
tempDestinations.clear();
connected.set(false);
started.set(false);
closing.set(false);
closed.set(true);
connectionInfo.getTracer().close();
}
} catch (Exception e) {
throw JmsExceptionSupport.create(e);
} finally {
try {
ThreadPoolUtils.shutdown(executor);
} catch (Throwable e) {
LOG.warn("Error shutting down thread pool: " + executor + ". This exception will be ignored.", e);
}
if (provider != null) {
provider.close();
provider = null;
}
if (interrupted) {
Thread.currentThread().interrupt();
}
}
}