提交 8b823110 编写于 作者: J Jesse Glick

[FIXED JENKINS-16319] Stream ordering problem prevented SecretRewriter from working on Windows.

上级 c2459e78
......@@ -66,6 +66,9 @@ Upcoming changes</a>
Improved logging and error output from SSHD in Jenkins.
<li class=rfe>
Linking to the <code>/threadDump</code> page from <code>/systemInfo</code> so it is discoverable.
<li class='major bug'>
Rekeying operation (from SECURITY-49 fix in 1.498) failed on Windows.
(<a href="https://issues.jenkins-ci.org/browse/JENKINS-16319">issue 16319</a>)
<li class=bug>
Links should preserve used protocol
(<a href="https://issues.jenkins-ci.org/browse/JENKINS-16368">issue 16368</a>)
......
......@@ -76,15 +76,15 @@ public class SecretRewriter {
* if the rewrite doesn't happen, no copying.
*/
public boolean rewrite(File f, File backup) throws InvalidKeyException, IOException {
FileInputStream fin = new FileInputStream(f);
AtomicFileWriter w = new AtomicFileWriter(f, "UTF-8");
try {
BufferedReader r = new BufferedReader(new InputStreamReader(fin, "UTF-8"));
AtomicFileWriter w = new AtomicFileWriter(f, "UTF-8");
try {
PrintWriter out = new PrintWriter(new BufferedWriter(w));
PrintWriter out = new PrintWriter(new BufferedWriter(w));
boolean modified = false; // did we actually change anything?
boolean modified = false; // did we actually change anything?
try {
FileInputStream fin = new FileInputStream(f);
try {
BufferedReader r = new BufferedReader(new InputStreamReader(fin, "UTF-8"));
String line;
StringBuilder buf = new StringBuilder();
......@@ -110,22 +110,22 @@ public class SecretRewriter {
out.println(buf.toString());
}
} finally {
out.close();
fin.close();
}
} finally {
out.close();
}
if (modified) {
if (backup!=null) {
backup.getParentFile().mkdirs();
FileUtils.copyFile(f,backup);
}
w.commit();
if (modified) {
if (backup!=null) {
backup.getParentFile().mkdirs();
FileUtils.copyFile(f,backup);
}
return modified;
} finally {
w.abort();
w.commit();
}
return modified;
} finally {
fin.close();
w.abort();
}
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册