Browse Source

revert readfully change, add in safeReadFully

git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@572363 13f79535-47bb-0310-9956-ffa450edef68
master
Peter Reilly 18 years ago
parent
commit
529a3f8250
7 changed files with 18 additions and 10 deletions
  1. +1
    -1
      src/main/org/apache/tools/ant/filters/ExpandProperties.java
  2. +1
    -1
      src/main/org/apache/tools/ant/taskdefs/Concat.java
  3. +1
    -1
      src/main/org/apache/tools/ant/taskdefs/condition/ResourceContains.java
  4. +1
    -4
      src/main/org/apache/tools/ant/taskdefs/optional/ReplaceRegExp.java
  5. +1
    -1
      src/main/org/apache/tools/ant/types/mappers/FilterMapper.java
  6. +12
    -1
      src/main/org/apache/tools/ant/util/FileUtils.java
  7. +1
    -1
      src/main/org/apache/tools/ant/util/ScriptRunnerBase.java

+ 1
- 1
src/main/org/apache/tools/ant/filters/ExpandProperties.java View File

@@ -84,7 +84,7 @@ public final class ExpandProperties
}
} else {
queuedData = readFully();
if (queuedData.length() == 0) {
if (queuedData == null || queuedData.length() == 0) {
ch = -1;
} else {
Project project = getProject();


+ 1
- 1
src/main/org/apache/tools/ant/taskdefs/Concat.java View File

@@ -140,7 +140,7 @@ public class Concat extends Task implements ResourceCollection {
new InputStreamReader(new FileInputStream(file),
this.encoding));
}
value = FileUtils.readFully(reader);
value = FileUtils.safeReadFully(reader);
} catch (IOException ex) {
throw new BuildException(ex);
} finally {


+ 1
- 1
src/main/org/apache/tools/ant/taskdefs/condition/ResourceContains.java View File

@@ -149,7 +149,7 @@ public class ResourceContains implements Condition {
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();


+ 1
- 4
src/main/org/apache/tools/ant/taskdefs/optional/ReplaceRegExp.java View File

@@ -424,10 +424,7 @@ public class ReplaceRegExp extends Task {

pw.flush();
} else {
String buf = FileUtils.readFully(br);
if (buf == null) {
buf = "";
}
String buf = FileUtils.safeReadFully(br);

String res = doReplace(regex, subs, buf, options);



+ 1
- 1
src/main/org/apache/tools/ant/types/mappers/FilterMapper.java View File

@@ -70,7 +70,7 @@ public class FilterMapper extends FilterChain implements FileNameMapper {
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 {


+ 12
- 1
src/main/org/apache/tools/ant/util/FileUtils.java View File

@@ -930,7 +930,18 @@ public class FileUtils {
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;
}

/**


+ 1
- 1
src/main/org/apache/tools/ant/util/ScriptRunnerBase.java View File

@@ -213,7 +213,7 @@ public abstract class ScriptRunnerBase {
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 {


Loading…
Cancel
Save