ItEr30S17ValidacionEProbasFuncionais: Catching exception when launching cleaning thread. Workaround for bug #21
This commit is contained in:
parent
1e37a59719
commit
cc2f5e342e
1 changed files with 17 additions and 2 deletions
|
|
@ -36,6 +36,8 @@ import javax.servlet.http.HttpServletRequest;
|
|||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import org.apache.commons.lang.Validate;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
|
||||
/**
|
||||
* Servlet that allows to register custom responses. It must be declared at
|
||||
|
|
@ -46,6 +48,8 @@ public class CallbackServlet extends HttpServlet {
|
|||
|
||||
private static final String MAPPING = "/callback/";
|
||||
|
||||
private static final Log LOG = LogFactory.getLog(CallbackServlet.class);
|
||||
|
||||
private static final long CLEANING_PERIOD_MILLIS = 1000 * 60 * 10; // ten
|
||||
// minutes
|
||||
|
||||
|
|
@ -139,12 +143,23 @@ public class CallbackServlet extends HttpServlet {
|
|||
synchronized (CallbackServlet.class) {
|
||||
if (contextPath == null) {
|
||||
contextPath = config.getServletContext().getContextPath();
|
||||
cleaningTimer.schedule(cleaningTask(), CLEANING_PERIOD_MILLIS,
|
||||
CLEANING_PERIOD_MILLIS);
|
||||
scheduleTimer();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void scheduleTimer() {
|
||||
try {
|
||||
cleaningTimer.schedule(cleaningTask(), CLEANING_PERIOD_MILLIS,
|
||||
CLEANING_PERIOD_MILLIS);
|
||||
} catch (Throwable e) {
|
||||
LOG
|
||||
.error(
|
||||
"can't start cleaning timer. A memory leak will be caused!",
|
||||
e);
|
||||
}
|
||||
}
|
||||
|
||||
private TimerTask cleaningTask() {
|
||||
return new TimerTask() {
|
||||
@Override
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue