[JENKINS-35184] Servlet API dependent bits in a inner-class (#2551)

* [JENKINS-35184] Servlet API dependent bits in a inner-class

This is in order to avoid loading ServletContextListener class
from slaves classloader.

* [JENKINS-35184] Don't use SystemProperties while initializing remote agents

This rolls back the previous commit and introduces a new way to construct
RingBufferLogHandler which avoids relying on SystemProperties to get the
default size.

* [JENKINS-35184] Mark SystemProperties as OnMaster only class

Adding `OnMaster` annotation does not prevent the class from being
loaded on remote agent but it gives a hint that this class should not
be used on a remote agent.

* [JENKINS-35184] Set SLAVE_LOG_HANDLER at the very beginning

In the previous code cleaning existing log handlers, SLAVE_LOG_HANDLER
is always null, as static fields are scoped by classloader.
This commit is contained in:
Yoann Dubreuil authored and Nicolas De loof committed 2016-09-21 10:39:52 +02:00
1 parent f191a3d395
commit 27d9b73ef4
4 files changed
+29 -7

No files matched your search

+5 -1
View File
@@ -77,7 +77,11 @@ import static java.util.logging.Level.*;
* @author Kohsuke Kawaguchi
*/
public class WebAppMain implements ServletContextListener {
private final RingBufferLogHandler handler = new RingBufferLogHandler() {
// use RingBufferLogHandler class name to configure for backward compatibility
private static final int DEFAULT_RING_BUFFER_SIZE = SystemProperties.getInteger(RingBufferLogHandler.class.getName() + ".defaultSize", 256);
private final RingBufferLogHandler handler = new RingBufferLogHandler(DEFAULT_RING_BUFFER_SIZE) {
@Override public synchronized void publish(LogRecord record) {
if (record.getLevel().intValue() >= Level.INFO.intValue()) {
super.publish(record);