/** * <p>Overrides finalize(). If called, it closes the connection.</p> * * <p>This was done at the request of <a href="mailto:rachel@enlarion.demon.co.uk">Rachel * Greenham</a> who hit a problem where multiple clients didn't close the connection, and once a * fortnight enough clients were open to kill the postgres server.</p> */ protected void finalize() throws Throwable { try { if (openStackTrace != null) { LOGGER.log(Level.WARNING, GT.tr("Finalizing a Connection that was never closed:"), openStackTrace); } close(); } finally { super.finalize(); } }
try { if (typeResolverConnection != null) { typeResolverConnection.close();
@Test @FixFor("DBZ-934") public void temporaryReplicationSlotsShouldGetDroppedAutomatically() throws Exception { try(ReplicationConnection replicationConnection = TestHelper.createForReplication("test", true)) { PgConnection pgConnection = getUnderlyingConnection(replicationConnection); // temporary replication slots are not supported by Postgres < 10 if (pgConnection.getServerMajorVersion() < 10) { return; } // simulate ungraceful shutdown by closing underlying database connection pgConnection.close(); try (PostgresConnection connection = TestHelper.create()) { assertFalse("postgres did not drop replication slot", connection.dropReplicationSlot("test")); } } }
try { if (typeResolverConnection != null) { typeResolverConnection.close();
@Test @FixFor("DBZ-934") public void temporaryReplicationSlotsShouldGetDroppedAutomatically() throws Exception { try(ReplicationConnection replicationConnection = TestHelper.createForReplication("test", true)) { PgConnection pgConnection = getUnderlyingConnection(replicationConnection); // temporary replication slots are not supported by Postgres < 10 if (pgConnection.getServerMajorVersion() < 10) { return; } // simulate ungraceful shutdown by closing underlying database connection pgConnection.close(); try (PostgresConnection connection = TestHelper.create()) { assertFalse("postgres did not drop replication slot", connection.dropReplicationSlot("test")); } } }