You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@ant.apache.org by jg...@apache.org on 2012/03/05 17:51:13 UTC
svn commit: r1297127 -
/ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/optional/ReplaceRegExp.java
Author: jglick
Date: Mon Mar 5 16:51:13 2012
New Revision: 1297127
URL: http://svn.apache.org/viewvc?rev=1297127&view=rev
Log:
Refined fix of #52743 to close output stream before renaming temp file.
Windows-only failure in Ant-Build-Matrix.
Modified:
ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/optional/ReplaceRegExp.java
Modified: ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/optional/ReplaceRegExp.java
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/optional/ReplaceRegExp.java?rev=1297127&r1=1297126&r2=1297127&view=diff
==============================================================================
--- ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/optional/ReplaceRegExp.java (original)
+++ ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/optional/ReplaceRegExp.java Mon Mar 5 16:51:13 2012
@@ -352,6 +352,8 @@ public class ReplaceRegExp extends Task
throws IOException {
File temp = FILE_UTILS.createTempFile("replace", ".txt", null, true, true);
try {
+ boolean changes = false;
+
InputStream is = new FileInputStream(f);
try {
Reader r = encoding != null ? new InputStreamReader(is, encoding) : new InputStreamReader(is);
@@ -362,8 +364,6 @@ public class ReplaceRegExp extends Task
BufferedReader br = new BufferedReader(r);
BufferedWriter bw = new BufferedWriter(w);
- boolean changes = false;
-
log("Replacing pattern '" + regex.getPattern(getProject())
+ "' with '" + subs.getExpression(getProject())
+ "' in '" + f.getPath() + "'" + (byline ? " by line" : "")
@@ -455,6 +455,12 @@ public class ReplaceRegExp extends Task
bw.flush();
+ } finally {
+ os.close();
+ }
+ } finally {
+ is.close();
+ }
if (changes) {
log("File has changed; saving the updated file", Project.MSG_VERBOSE);
try {
@@ -471,12 +477,6 @@ public class ReplaceRegExp extends Task
} else {
log("No change made", Project.MSG_DEBUG);
}
- } finally {
- os.close();
- }
- } finally {
- is.close();
- }
} finally {
if (temp != null) {
temp.delete();