in provisioning/provisioning-device-client/src/main/java/com/microsoft/azure/sdk/iot/provisioning/device/transport/amqp/AmqpsConnection.java [229:285]
public void close() throws IOException
{
if (this.isOpen)
{
log.debug("Closing amqp connection");
this.amqpDeviceOperations.closeLinks();
// Close Proton
if (this.session != null)
{
this.session.close();
}
if (this.connection != null)
{
this.connection.close();
}
if (this.reactor != null)
{
this.reactor.stop();
}
try
{
synchronized (closeLock)
{
closeLock.waitLock(MAX_WAIT_TO_OPEN_CLOSE_CONNECTION);
}
}
catch (InterruptedException e)
{
throw new IOException("Waited too long for the connection to close.", e);
}
if (this.executorService != null)
{
this.executorService.shutdown();
try
{
// Wait a while for existing tasks to terminate
if (!this.executorService.awaitTermination(MAX_WAIT_TO_TERMINATE_EXECUTOR, TimeUnit.SECONDS))
{
this.executorService.shutdownNow(); // Cancel currently executing tasks
// Wait a while for tasks to respond to being cancelled
if (!this.executorService.awaitTermination(MAX_WAIT_TO_TERMINATE_EXECUTOR, TimeUnit.SECONDS))
{
log.info("Pool did not terminate");
}
}
}
catch (InterruptedException ie)
{
this.executorService.shutdownNow();
}
}
this.isOpen = false;
}
}