mirror of
https://github.com/jenkinsci/jenkins.git
synced 2026-11-15 13:02:19 +00:00
[FIXED JENKINS-16634] Do not fail to write a log file just because something deleted the parent directory.
(cherry picked from commit afe17a4bda)
This commit is contained in:
1 parent
cf78e48b44
commit
9a34d9f8b2
3 files changed
+30
-6
No files matched your search
+27
-6
@@ -9,16 +9,20 @@ import org.junit.Test;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.PrintWriter;
|
||||
import org.apache.commons.io.FileUtils;
|
||||
import org.junit.Rule;
|
||||
import org.junit.rules.TemporaryFolder;
|
||||
import org.jvnet.hudson.test.Issue;
|
||||
|
||||
/**
|
||||
* @author Kohsuke Kawaguchi
|
||||
*/
|
||||
public class ReopenableRotatingFileOutputStreamTest {
|
||||
public class RewindableRotatingFileOutputStreamTest {
|
||||
|
||||
@Rule
|
||||
public TemporaryFolder tmp = new TemporaryFolder();
|
||||
|
||||
@Test
|
||||
public void rotation() throws IOException, InterruptedException {
|
||||
File base = File.createTempFile("test", "log");
|
||||
ReopenableRotatingFileOutputStream os = new ReopenableRotatingFileOutputStream(base,3);
|
||||
File base = tmp.newFile("test.log");
|
||||
RewindableRotatingFileOutputStream os = new RewindableRotatingFileOutputStream(base,3);
|
||||
PrintWriter w = new PrintWriter(os,true);
|
||||
for (int i=0; i<=4; i++) {
|
||||
w.println("Content"+i);
|
||||
@@ -35,4 +39,21 @@ public class ReopenableRotatingFileOutputStreamTest {
|
||||
|
||||
os.deleteAll();
|
||||
}
|
||||
|
||||
@Issue("JENKINS-16634")
|
||||
@Test
|
||||
public void deletedFolder() throws Exception {
|
||||
File dir = tmp.newFolder("dir");
|
||||
File base = new File(dir, "x.log");
|
||||
RewindableRotatingFileOutputStream os = new RewindableRotatingFileOutputStream(base, 3);
|
||||
for (int i = 0; i < 2; i++) {
|
||||
FileUtils.deleteDirectory(dir);
|
||||
os.write('.');
|
||||
FileUtils.deleteDirectory(dir);
|
||||
os.write('.');
|
||||
FileUtils.deleteDirectory(dir);
|
||||
os.rewind();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Reference in new issue
Block a user