/** * Called by the StatsShutdownHook on shutdown */ @Override public synchronized void shutdown() { if (conn != null) { LOG.error("Shutting down open ObjectStoreWriterInterMineImpl with sequence = " + sequenceNumber + " and Database " + os.getDatabase().getURL() + ", createSituation = " + createSituation); try { close(); } catch (ObjectStoreException e) { LOG.error("Exception caught while shutting down ObjectStoreWriterInterMineImpl: " + e); } } }
/** * Overrides Object.finalize - release the connection back to the objectstore. */ @Override protected synchronized void doFinalise() { if (conn != null) { LOG.error("Garbage collecting open ObjectStoreWriterInterMineImpl with sequence = " + sequenceNumber + " and Database " + os.getDatabase().getURL() + ", createSituation: " + createSituation); try { close(); } catch (ObjectStoreException e) { LOG.error("Exception while garbage-collecting ObjectStoreWriterInterMineImpl: " + e); } } }
/** * Called by the StatsShutdownHook on shutdown */ @Override public synchronized void shutdown() { if (conn != null) { LOG.error("Shutting down open ObjectStoreWriterInterMineImpl with sequence = " + sequenceNumber + " and Database " + os.getDatabase().getURL() + ", createSituation = " + createSituation); try { close(); } catch (ObjectStoreException e) { LOG.error("Exception caught while shutting down ObjectStoreWriterInterMineImpl: " + e); } } }
/** * Overrides Object.finalize - release the connection back to the objectstore. */ @Override protected synchronized void doFinalise() { if (conn != null) { LOG.error("Garbage collecting open ObjectStoreWriterInterMineImpl with sequence = " + sequenceNumber + " and Database " + os.getDatabase().getURL() + ", createSituation: " + createSituation); try { close(); } catch (ObjectStoreException e) { LOG.error("Exception while garbage-collecting ObjectStoreWriterInterMineImpl: " + e); } } }
public void run() { try { ObjectStoreWriterInterMineImpl w = (ObjectStoreWriterInterMineImpl)ObjectStoreWriterFactory.getObjectStoreWriter("osw.unittest"); Connection c = w.getConnection(); try { w.close(); fail("Expected an ObjectStoreException"); } catch (ObjectStoreException e) { Assert.assertEquals("Closed ObjectStoreWriter while it is being used. Note this writer will be automatically closed when the current operation finishes", e.getMessage()); } w.releaseConnection(c); signalFinished(null); } catch (Throwable e) { System.out.println("Error in ShutdownThread: " + e); signalFinished(e); } } }
writer.close();