Skip to content

Commit

Permalink
[FIXED JENKINS-27669] Force classes used by CustomHandler.publish to …
Browse files Browse the repository at this point in the history
…be loaded before we actually receive any log records.
  • Loading branch information
jglick committed May 6, 2015
1 parent db3e7f4 commit 43f0f84
Showing 1 changed file with 20 additions and 4 deletions.
24 changes: 20 additions & 4 deletions src/main/java/com/cloudbees/jenkins/support/impl/JenkinsLogs.java
Expand Up @@ -2,6 +2,7 @@

import com.cloudbees.jenkins.support.SupportLogFormatter;
import com.cloudbees.jenkins.support.SupportPlugin;
import static com.cloudbees.jenkins.support.SupportPlugin.*;
import com.cloudbees.jenkins.support.api.Component;
import com.cloudbees.jenkins.support.api.Container;
import com.cloudbees.jenkins.support.api.FileContent;
Expand All @@ -23,20 +24,20 @@
import hudson.security.Permission;
import hudson.slaves.Cloud;
import hudson.slaves.SlaveComputer;
import hudson.util.CopyOnWriteList;
import hudson.util.DaemonThreadFactory;
import hudson.util.ExceptionCatchingThreadFactory;
import hudson.util.RingBufferLogHandler;
import hudson.util.io.ReopenableFileOutputStream;
import hudson.util.io.ReopenableRotatingFileOutputStream;
import jenkins.model.Jenkins;

import java.io.File;
import java.io.FileFilter;
import java.io.IOException;
import java.io.InterruptedIOException;
import java.io.PrintWriter;
import java.lang.reflect.Field;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
Expand All @@ -56,8 +57,7 @@
import java.util.logging.Logger;
import java.util.logging.StreamHandler;
import java.util.regex.Pattern;

import static com.cloudbees.jenkins.support.SupportPlugin.*;
import jenkins.model.Jenkins;

/**
* Log files from the different nodes
Expand Down Expand Up @@ -503,6 +503,22 @@ private final class CustomHandler extends Handler {

private final Map<String,LogFile> logFiles = new HashMap<String,LogFile>();

/** JENKINS-27669: try to preload classes that will be needed by {@link #publish} */
CustomHandler() {
Arrays.hashCode(new Class<?>[] {
Map.Entry.class,
LogRecorder.class,
LogRecorder.Target.class,
LogFile.class,
ReopenableFileOutputStream.class,
ReopenableRotatingFileOutputStream.class,
StreamHandler.class,
SupportLogFormatter.class,
LogFlusher.class,
CopyOnWriteList.class,
});
}

@Override public void publish(LogRecord record) {
for (Map.Entry<String,LogRecorder> entry : logRecorders.entrySet()) {
for (LogRecorder.Target target : entry.getValue().targets) {
Expand Down

0 comments on commit 43f0f84

Please sign in to comment.