@Test public void connectionIsClosedOnDestroy() throws IOException { JmxConnectionProvider server = mock(JmxConnectionProvider.class); JMXConnection connection = mock(JMXConnection.class); when(connection.isAlive()).thenReturn(true); factory.destroyObject(server, connection); verify(connection).setMarkedAsDestroyed(); verify(connection, timeout(2000)).close(); }
@Override public void destroyObject(@Nonnull JmxConnectionProvider key, @Nonnull final JMXConnection jmxConnection) throws IOException { if (!jmxConnection.isAlive()) { return; } jmxConnection.setMarkedAsDestroyed(); executor.submit(new Runnable() { public void run() { jmxConnection.close(); } }); }
MBeanServerConnectionFactory extends BaseKeyedPoolableObjectFactory<JmxConnectionProvider, JMXConnection> { @Override public void destroyObject(@Nonnull JmxConnectionProvider key, @Nonnull final JMXConnection jmxConnection) throws IOException { if (!jmxConnection.isAlive()) { return; } jmxConnection.setMarkedAsDestroyed(); executor.submit(new Runnable() { public void run() { jmxConnection.close(); } }); } }
MBeanServerConnectionFactory extends BaseKeyedPoolableObjectFactory<JmxConnectionProvider, JMXConnection> { @Override public void destroyObject(@Nonnull JmxConnectionProvider key, @Nonnull final JMXConnection jmxConnection) throws IOException { if (!jmxConnection.isAlive()) { return; } jmxConnection.setMarkedAsDestroyed(); executor.submit(new Runnable() { public void run() { jmxConnection.close(); } }); } MBeanServerConnectionFactory(); }
MBeanServerConnectionFactory extends BaseKeyedPoolableObjectFactory<JmxConnectionProvider, JMXConnection> { @Override public void destroyObject(@Nonnull JmxConnectionProvider key, @Nonnull final JMXConnection jmxConnection) throws IOException { if (!jmxConnection.isAlive()) { return; } jmxConnection.setMarkedAsDestroyed(); executor.submit(new Runnable() { public void run() { jmxConnection.close(); } }); } MBeanServerConnectionFactory(); @Override @Nonnull JMXConnection makeObject(@Nonnull JmxConnectionProvider server); @Override void destroyObject(@Nonnull JmxConnectionProvider key, @Nonnull final JMXConnection jmxConnection); @Override boolean validateObject(@Nonnull JmxConnectionProvider key, @Nonnull JMXConnection jmxConnection); }
MBeanServerConnectionFactory extends BaseKeyedPoolableObjectFactory<JmxConnectionProvider, JMXConnection> { @Override public void destroyObject(@Nonnull JmxConnectionProvider key, @Nonnull final JMXConnection jmxConnection) throws IOException { if (!jmxConnection.isAlive()) { return; } jmxConnection.setMarkedAsDestroyed(); executor.submit(new Runnable() { public void run() { jmxConnection.close(); } }); } MBeanServerConnectionFactory(); @Override @Nonnull JMXConnection makeObject(@Nonnull JmxConnectionProvider server); @Override void destroyObject(@Nonnull JmxConnectionProvider key, @Nonnull final JMXConnection jmxConnection); @Override boolean validateObject(@Nonnull JmxConnectionProvider key, @Nonnull JMXConnection jmxConnection);  }