mirror of
https://github.com/jenkinsci/jenkins.git
synced 2026-11-10 02:26:18 +00:00
Make Computer#getLogDir thread-safe (#4730)
This commit is contained in:
1 parent
6e11d6124b
commit
4c16f2cd95
1 file changed
+8
-4
@@ -195,6 +195,8 @@ public /*transient*/ abstract class Computer extends Actionable implements Acces
|
||||
|
||||
protected final Object statusChangeLock = new Object();
|
||||
|
||||
private final Object logDirLock = new String("logDirLock");
|
||||
|
||||
/**
|
||||
* Keeps track of stack traces to track the termination requests for this computer.
|
||||
*
|
||||
@@ -303,10 +305,12 @@ public /*transient*/ abstract class Computer extends Actionable implements Acces
|
||||
*/
|
||||
protected @NonNull File getLogDir() {
|
||||
File dir = new File(Jenkins.get().getRootDir(),"logs/slaves/"+nodeName);
|
||||
try {
|
||||
IOUtils.mkdirs(dir);
|
||||
} catch (IOException x) {
|
||||
LOGGER.log(Level.SEVERE, "Failed to create agent log directory " + dir, x);
|
||||
synchronized (logDirLock) {
|
||||
try {
|
||||
IOUtils.mkdirs(dir);
|
||||
} catch (IOException x) {
|
||||
LOGGER.log(Level.SEVERE, "Failed to create agent log directory " + dir, x);
|
||||
}
|
||||
}
|
||||
return dir;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user