提交 8fd33392 authored 作者: Thomas Mueller's avatar Thomas Mueller

Apache Tomcat 7.x will now longer log a warning when unloading the web…

Apache Tomcat 7.x will now longer log a warning when unloading the web application, if using a connection pool.
上级 41288419
......@@ -18,7 +18,8 @@ Change Log
<h1>Change Log</h1>
<h2>Next Version (unreleased)</h2>
<ul><li>H2 Console: support the Midori browser (for Debian / Raspberry Pi)
<ul><li>Apache Tomcat 7.x will now longer log a warning when unloading the web application, if using a connection pool.
</li><li>H2 Console: support the Midori browser (for Debian / Raspberry Pi)
</li><li>When opening a remote session, don't open a temporary file if the trace level is set to zero
</li></ul>
......
......@@ -180,4 +180,21 @@ public class Driver implements java.sql.Driver {
DEFAULT_CONNECTION.set(c);
}
/**
* INTERNAL
*/
public static void setThreadContextClassLoader(Thread thread) {
// Apache Tomcat: use the classloader of the driver to avoid the
// following log message:
// org.apache.catalina.loader.WebappClassLoader clearReferencesThreads
// SEVERE: The web application appears to have started a thread named
// ... but has failed to stop it.
// This is very likely to create a memory leak.
try {
thread.setContextClassLoader(Driver.class.getClassLoader());
} catch (Throwable t) {
// ignore
}
}
}
......@@ -15,6 +15,7 @@ import java.net.ServerSocket;
import java.net.Socket;
import java.net.UnknownHostException;
import java.util.Properties;
import org.h2.Driver;
import org.h2.constant.ErrorCode;
import org.h2.engine.Constants;
import org.h2.engine.SessionRemote;
......@@ -347,6 +348,7 @@ public class FileLock implements Runnable {
throw getExceptionFatal("Concurrent update", null);
}
watchdog = new Thread(this, "H2 File Lock Watchdog " + fileName);
Driver.setThreadContextClassLoader(watchdog);
watchdog.setDaemon(true);
watchdog.setPriority(Thread.MAX_PRIORITY - 1);
watchdog.start();
......
......@@ -8,6 +8,7 @@ package org.h2.store;
import java.lang.ref.WeakReference;
import java.security.AccessControlException;
import org.h2.Driver;
import org.h2.engine.Constants;
import org.h2.engine.Database;
import org.h2.message.Trace;
......@@ -61,6 +62,7 @@ public class WriterThread implements Runnable {
try {
WriterThread writer = new WriterThread(database, writeDelay);
writer.thread = new Thread(writer, "H2 Log Writer " + database.getShortName());
Driver.setThreadContextClassLoader(writer.thread);
writer.thread.setDaemon(true);
return writer;
} catch (AccessControlException e) {
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论