Skip to content

Commit

Permalink
PAYARA-3487 only log stacktrace if logger level set to FINE
Browse files Browse the repository at this point in the history
  • Loading branch information
Cousjava committed May 9, 2019
1 parent 6cac65a commit f1cbfc0
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,19 @@

package com.sun.enterprise.resource;

import com.sun.enterprise.resource.pool.ConnectionPool;
import com.sun.logging.LogDomains;
import java.util.logging.Level;
import java.util.logging.Logger;

public class ResourceState {
private boolean enlisted;
private boolean busy;
private long timestamp;
private TwiceBusyException busyException;

//This is the same logger as in ConnectionPool, used to check the log level
private Logger LOGGER = LogDomains.getLogger(ConnectionPool.class,LogDomains.RSR_LOGGER);

public boolean isEnlisted() {
return enlisted;
Expand All @@ -69,7 +77,7 @@ public boolean isBusy() {

public void setBusy(boolean busy) {
this.busy = busy;
if (!busy) {
if (!busy && LOGGER.isLoggable(Level.FINE)) {
busyException = new TwiceBusyException();
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1020,11 +1020,14 @@ public void resourceClosed(ResourceHandle h)

if (!state.isBusy()) {
//throw new IllegalStateException("state.isBusy() : false");
MultiException noBusyException = new MultiException(state.getBusyStackException());
noBusyException.addError(new IllegalStateException("state.isBusy() : false"));
_logger.log(Level.WARNING, "state.isBusy already set to false for " + h.getName() + "#" + h.getId(), noBusyException);
_logger.log(Level.WARNING, "state.isBusy already set to false for {0}#{1}", new Object[]{h.getName(), h.getId()});
if (_logger.isLoggable(Level.FINE)) {
MultiException noBusyException = new MultiException(state.getBusyStackException());
noBusyException.addError(new IllegalStateException("state.isBusy() : false"));
_logger.log(Level.WARNING, null, noBusyException);
}
}

setResourceStateToFree(h); // mark as not busy
state.touchTimestamp();

Expand Down

0 comments on commit f1cbfc0

Please sign in to comment.