Exception est = new Exception(); est.fillInStackTrace(); StringWriter message = new StringWriter(); PrintWriter pw = new PrintWriter(message); est.printStackTrace(pw); pw.close(); closeSituation = message.toString(); int index = closeSituation.indexOf("at junit.framework.TestCase.runBare"); closeSituation = (index < 0 ? closeSituation : closeSituation.substring(0, index));
    public synchronized void close() throws ObjectStoreException {        if (conn == null) {            // This writer is already closed            throw new ObjectStoreException("This ObjectStoreWriter is already closed");        }        if (connInUse) {            conn = null;            throw new ObjectStoreException("Closed ObjectStoreWriter while it is being used. Note"                    + " this writer will be automatically closed when the current operation"                    + " finishes");        } else {            try {                if (isInTransactionWithConnection(conn)) {                    abortTransactionWithConnection(conn);                    LOG.error("ObjectStoreWriterInterMineImpl closed in unfinished transaction"                            + " - transaction aborted");                }            } catch (Exception e) {                LOG.error("Exception caught when destroying transaction while closing"                        + " ObjectStoreWriter", e);            }            try {                batch.close(conn);            } catch (Exception e) {                LOG.error("Exception caught when closing Batch while closing ObjectStoreWriter", e);            }            try {                os.releaseConnection(conn);            } catch (Exception e) {                // ignore            }            conn = null;            connInUse = true;            notifyAll();        }    }