Repository: Log negative useCnt message together with stack trace

The message "close() called when useCnt is already zero" is logged with
level warning, and then if debug logging is enabled, the stack trace is
logged separately with level debug.

Log the message and the stack trace in the same call, so that they always
appear together in the output rather than potentially interleaved with
other log statements.

Change-Id: I1b5c1557ddc2d19f3f5b29baec96e62bc467d88a
Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
This commit is contained in:
David Pursehouse 2016-07-22 14:05:19 +09:00
parent 0d872a0837
commit b8d861bfd5
1 changed files with 3 additions and 2 deletions

View File

@ -880,10 +880,11 @@ public void close() {
} else if (newCount == -1) {
// should not happen, only log when useCnt became negative to
// minimize number of log entries
LOG.warn(JGitText.get().corruptUseCnt);
if (LOG.isDebugEnabled()) {
IllegalStateException e = new IllegalStateException();
LOG.debug("", e); //$NON-NLS-1$
LOG.debug(JGitText.get().corruptUseCnt, e);
} else {
LOG.warn(JGitText.get().corruptUseCnt);
}
if (RepositoryCache.isCached(this)) {
closedAt.set(System.currentTimeMillis());