ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From peterrei...@apache.org
Subject svn commit: r572363 - in /ant/core/trunk/src/main/org/apache/tools/ant: filters/ taskdefs/ taskdefs/condition/ taskdefs/optional/ types/mappers/ util/
Date Mon, 03 Sep 2007 15:29:46 GMT
Author: peterreilly
Date: Mon Sep  3 08:29:45 2007
New Revision: 572363

URL: http://svn.apache.org/viewvc?rev=572363&view=rev
Log:
revert readfully change, add in safeReadFully

Modified:
    ant/core/trunk/src/main/org/apache/tools/ant/filters/ExpandProperties.java
    ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/Concat.java
    ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/condition/ResourceContains.java
    ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/optional/ReplaceRegExp.java
    ant/core/trunk/src/main/org/apache/tools/ant/types/mappers/FilterMapper.java
    ant/core/trunk/src/main/org/apache/tools/ant/util/FileUtils.java
    ant/core/trunk/src/main/org/apache/tools/ant/util/ScriptRunnerBase.java

Modified: ant/core/trunk/src/main/org/apache/tools/ant/filters/ExpandProperties.java
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/ant/filters/ExpandProperties.java?rev=572363&r1=572362&r2=572363&view=diff
==============================================================================
--- ant/core/trunk/src/main/org/apache/tools/ant/filters/ExpandProperties.java (original)
+++ ant/core/trunk/src/main/org/apache/tools/ant/filters/ExpandProperties.java Mon Sep  3
08:29:45 2007
@@ -84,7 +84,7 @@
             }
         } else {
             queuedData = readFully();
-            if (queuedData.length() == 0) {
+            if (queuedData == null || queuedData.length() == 0) {
                 ch = -1;
             } else {
                 Project project = getProject();

Modified: ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/Concat.java
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/Concat.java?rev=572363&r1=572362&r2=572363&view=diff
==============================================================================
--- ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/Concat.java (original)
+++ ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/Concat.java Mon Sep  3 08:29:45
2007
@@ -140,7 +140,7 @@
                         new InputStreamReader(new FileInputStream(file),
                                               this.encoding));
                 }
-                value = FileUtils.readFully(reader);
+                value = FileUtils.safeReadFully(reader);
             } catch (IOException ex) {
                 throw new BuildException(ex);
             } finally {

Modified: ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/condition/ResourceContains.java
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/condition/ResourceContains.java?rev=572363&r1=572362&r2=572363&view=diff
==============================================================================
--- ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/condition/ResourceContains.java
(original)
+++ ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/condition/ResourceContains.java
Mon Sep  3 08:29:45 2007
@@ -149,7 +149,7 @@
         BufferedReader reader = null;
         try {
             reader = new BufferedReader(new InputStreamReader(resource.getInputStream()));
-            String contents = FileUtils.readFully(reader);
+            String contents = FileUtils.safeReadFully(reader);
             String sub = substring;
             if (!casesensitive) {
                 contents = contents.toLowerCase();

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=572363&r1=572362&r2=572363&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
Sep  3 08:29:45 2007
@@ -424,10 +424,7 @@
 
                 pw.flush();
             } else {
-                String buf = FileUtils.readFully(br);
-                if (buf == null) {
-                    buf = "";
-                }
+                String buf = FileUtils.safeReadFully(br);
 
                 String res = doReplace(regex, subs, buf, options);
 

Modified: ant/core/trunk/src/main/org/apache/tools/ant/types/mappers/FilterMapper.java
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/ant/types/mappers/FilterMapper.java?rev=572363&r1=572362&r2=572363&view=diff
==============================================================================
--- ant/core/trunk/src/main/org/apache/tools/ant/types/mappers/FilterMapper.java (original)
+++ ant/core/trunk/src/main/org/apache/tools/ant/types/mappers/FilterMapper.java Mon Sep 
3 08:29:45 2007
@@ -70,7 +70,7 @@
             Vector filterChains = new Vector();
             filterChains.add(this);
             helper.setFilterChains(filterChains);
-            String result = FileUtils.readFully(helper.getAssembledReader());
+            String result = FileUtils.safeReadFully(helper.getAssembledReader());
             if (result.length() == 0) {
                 return null;
             } else {

Modified: ant/core/trunk/src/main/org/apache/tools/ant/util/FileUtils.java
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/ant/util/FileUtils.java?rev=572363&r1=572362&r2=572363&view=diff
==============================================================================
--- ant/core/trunk/src/main/org/apache/tools/ant/util/FileUtils.java (original)
+++ ant/core/trunk/src/main/org/apache/tools/ant/util/FileUtils.java Mon Sep  3 08:29:45 2007
@@ -930,7 +930,18 @@
                 textBuffer.append(new String(buffer, 0, bufferLength));
             }
         }
-        return (textBuffer == null) ? "" : textBuffer.toString();
+        return (textBuffer == null) ? null : textBuffer.toString();
+    }
+
+    /**
+     * Safe read fully - do not return a null for an empty reader.
+     * @param reader the input to read from.
+     * @return the string.
+     * @throws IOException if unable to read from reader.
+     */
+    public static String safeReadFully(Reader reader) throws IOException {
+        String ret = readFully(reader);
+        return ret == null ? "" : ret;
     }
 
     /**

Modified: ant/core/trunk/src/main/org/apache/tools/ant/util/ScriptRunnerBase.java
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/ant/util/ScriptRunnerBase.java?rev=572363&r1=572362&r2=572363&view=diff
==============================================================================
--- ant/core/trunk/src/main/org/apache/tools/ant/util/ScriptRunnerBase.java (original)
+++ ant/core/trunk/src/main/org/apache/tools/ant/util/ScriptRunnerBase.java Mon Sep  3 08:29:45
2007
@@ -213,7 +213,7 @@
         BufferedReader in = null;
         try {
             in = new BufferedReader(reader);
-            script += FileUtils.readFully(in);
+            script += FileUtils.safeReadFully(in);
         } catch (IOException ex) {
             throw new BuildException("Failed to read " + name, ex);
         } finally {



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@ant.apache.org
For additional commands, e-mail: dev-help@ant.apache.org


Mime
View raw message