mirror of
https://github.com/jenkinsci/jenkins.git
synced 2026-11-18 06:22:29 +00:00
FingerprintCleanupThread ought to write messages to its saved log file.
This commit is contained in:
1 parent
84d49ceef2
commit
45dec68e00
3 files changed
+10
-9
No files matched your search
@@ -3,8 +3,6 @@ package hudson.model;
|
||||
import hudson.security.ACL;
|
||||
import hudson.util.StreamTaskListener;
|
||||
import jenkins.model.Jenkins;
|
||||
import org.acegisecurity.context.SecurityContext;
|
||||
import org.acegisecurity.context.SecurityContextHolder;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
@@ -36,6 +34,7 @@ public abstract class AsyncPeriodicWork extends PeriodicWork {
|
||||
/**
|
||||
* Schedules this periodic work now in a new thread, if one isn't already running.
|
||||
*/
|
||||
@SuppressWarnings("deprecation") // in this case we really want to use PeriodicWork.logger since it reports the impl class
|
||||
public final void doRun() {
|
||||
try {
|
||||
if(thread!=null && thread.isAlive()) {
|
||||
|
||||
@@ -29,7 +29,6 @@ import jenkins.model.Jenkins;
|
||||
import java.io.File;
|
||||
import java.io.FileFilter;
|
||||
import java.io.IOException;
|
||||
import java.util.logging.Level;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
/**
|
||||
@@ -72,7 +71,7 @@ public final class FingerprintCleanupThread extends AsyncPeriodicWork {
|
||||
for(File file2 : files2) {
|
||||
File[] files3 = file2.listFiles(FINGERPRINTFILE_FILTER);
|
||||
for(File file3 : files3) {
|
||||
if(check(file3))
|
||||
if(check(file3, listener))
|
||||
numFiles++;
|
||||
}
|
||||
deleteIfEmpty(file2);
|
||||
@@ -81,7 +80,7 @@ public final class FingerprintCleanupThread extends AsyncPeriodicWork {
|
||||
}
|
||||
}
|
||||
|
||||
logger.log(Level.INFO, "Cleaned up "+numFiles+" records");
|
||||
listener.getLogger().println("Cleaned up "+numFiles+" records");
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -97,22 +96,22 @@ public final class FingerprintCleanupThread extends AsyncPeriodicWork {
|
||||
/**
|
||||
* Examines the file and returns true if a file was deleted.
|
||||
*/
|
||||
private boolean check(File fingerprintFile) {
|
||||
private boolean check(File fingerprintFile, TaskListener listener) {
|
||||
try {
|
||||
Fingerprint fp = Fingerprint.load(fingerprintFile);
|
||||
if (fp == null || !fp.isAlive()) {
|
||||
logger.fine("deleting obsolete " + fingerprintFile);
|
||||
listener.getLogger().println("deleting obsolete " + fingerprintFile);
|
||||
fingerprintFile.delete();
|
||||
return true;
|
||||
} else {
|
||||
// get the fingerprint in the official map so have the changes visible to Jenkins
|
||||
// otherwise the mutation made in FingerprintMap can override our trimming.
|
||||
logger.finer("possibly trimming " + fingerprintFile);
|
||||
listener.getLogger().println("possibly trimming " + fingerprintFile);
|
||||
fp = Jenkins.getInstance()._getFingerprint(fp.getHashString());
|
||||
return fp.trim();
|
||||
}
|
||||
} catch (IOException e) {
|
||||
logger.log(Level.WARNING, "Failed to process "+fingerprintFile, e);
|
||||
e.printStackTrace(listener.error("Failed to process " + fingerprintFile));
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -57,6 +57,9 @@ import static hudson.init.InitMilestone.JOB_LOADED;
|
||||
* @see AsyncPeriodicWork
|
||||
*/
|
||||
public abstract class PeriodicWork extends SafeTimerTask implements ExtensionPoint {
|
||||
|
||||
/** @deprecated Use your own logger, or send messages to the logger in {@link AsyncPeriodicWork#execute}. */
|
||||
@SuppressWarnings("NonConstantLogger")
|
||||
protected final Logger logger = Logger.getLogger(getClass().getName());
|
||||
|
||||
/**
|
||||
|
||||
Reference in new issue
Block a user