mirror of
https://github.com/jenkinsci/jenkins.git
synced 2026-11-13 20:12:14 +00:00
[JENKINS-42934] Avoid using new FileInputStream / new FileOutputStream
This commit is contained in:
1 parent
4948d6c556
commit
f0cd7ae8ff
41 files changed
+188
-159
No files matched your search
@@ -24,6 +24,9 @@
|
||||
package hudson;
|
||||
|
||||
import hudson.security.ACLContext;
|
||||
import java.io.OutputStream;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.StandardOpenOption;
|
||||
import jenkins.util.SystemProperties;
|
||||
import com.thoughtworks.xstream.converters.reflection.PureJavaReflectionProvider;
|
||||
import com.thoughtworks.xstream.core.JVM;
|
||||
@@ -273,14 +276,10 @@ public class WebAppMain implements ServletContextListener {
|
||||
* @see BootFailure
|
||||
*/
|
||||
private void recordBootAttempt(File home) {
|
||||
FileOutputStream o=null;
|
||||
try {
|
||||
o = new FileOutputStream(BootFailure.getBootFailureFile(home), true);
|
||||
try (OutputStream o=Files.newOutputStream(BootFailure.getBootFailureFile(home).toPath(), StandardOpenOption.CREATE, StandardOpenOption.APPEND)) {
|
||||
o.write((new Date().toString() + System.getProperty("line.separator", "\n")).toString().getBytes());
|
||||
} catch (IOException e) {
|
||||
LOGGER.log(WARNING, "Failed to record boot attempts",e);
|
||||
} finally {
|
||||
IOUtils.closeQuietly(o);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user