git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@572363 13f79535-47bb-0310-9956-ffa450edef68master
| @@ -84,7 +84,7 @@ public final class ExpandProperties | |||||
| } | } | ||||
| } else { | } else { | ||||
| queuedData = readFully(); | queuedData = readFully(); | ||||
| if (queuedData.length() == 0) { | |||||
| if (queuedData == null || queuedData.length() == 0) { | |||||
| ch = -1; | ch = -1; | ||||
| } else { | } else { | ||||
| Project project = getProject(); | Project project = getProject(); | ||||
| @@ -140,7 +140,7 @@ public class Concat extends Task implements ResourceCollection { | |||||
| new InputStreamReader(new FileInputStream(file), | new InputStreamReader(new FileInputStream(file), | ||||
| this.encoding)); | this.encoding)); | ||||
| } | } | ||||
| value = FileUtils.readFully(reader); | |||||
| value = FileUtils.safeReadFully(reader); | |||||
| } catch (IOException ex) { | } catch (IOException ex) { | ||||
| throw new BuildException(ex); | throw new BuildException(ex); | ||||
| } finally { | } finally { | ||||
| @@ -149,7 +149,7 @@ public class ResourceContains implements Condition { | |||||
| BufferedReader reader = null; | BufferedReader reader = null; | ||||
| try { | try { | ||||
| reader = new BufferedReader(new InputStreamReader(resource.getInputStream())); | reader = new BufferedReader(new InputStreamReader(resource.getInputStream())); | ||||
| String contents = FileUtils.readFully(reader); | |||||
| String contents = FileUtils.safeReadFully(reader); | |||||
| String sub = substring; | String sub = substring; | ||||
| if (!casesensitive) { | if (!casesensitive) { | ||||
| contents = contents.toLowerCase(); | contents = contents.toLowerCase(); | ||||
| @@ -424,10 +424,7 @@ public class ReplaceRegExp extends Task { | |||||
| pw.flush(); | pw.flush(); | ||||
| } else { | } else { | ||||
| String buf = FileUtils.readFully(br); | |||||
| if (buf == null) { | |||||
| buf = ""; | |||||
| } | |||||
| String buf = FileUtils.safeReadFully(br); | |||||
| String res = doReplace(regex, subs, buf, options); | String res = doReplace(regex, subs, buf, options); | ||||
| @@ -70,7 +70,7 @@ public class FilterMapper extends FilterChain implements FileNameMapper { | |||||
| Vector filterChains = new Vector(); | Vector filterChains = new Vector(); | ||||
| filterChains.add(this); | filterChains.add(this); | ||||
| helper.setFilterChains(filterChains); | helper.setFilterChains(filterChains); | ||||
| String result = FileUtils.readFully(helper.getAssembledReader()); | |||||
| String result = FileUtils.safeReadFully(helper.getAssembledReader()); | |||||
| if (result.length() == 0) { | if (result.length() == 0) { | ||||
| return null; | return null; | ||||
| } else { | } else { | ||||
| @@ -930,7 +930,18 @@ public class FileUtils { | |||||
| textBuffer.append(new String(buffer, 0, bufferLength)); | 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; | |||||
| } | } | ||||
| /** | /** | ||||
| @@ -213,7 +213,7 @@ public abstract class ScriptRunnerBase { | |||||
| BufferedReader in = null; | BufferedReader in = null; | ||||
| try { | try { | ||||
| in = new BufferedReader(reader); | in = new BufferedReader(reader); | ||||
| script += FileUtils.readFully(in); | |||||
| script += FileUtils.safeReadFully(in); | |||||
| } catch (IOException ex) { | } catch (IOException ex) { | ||||
| throw new BuildException("Failed to read " + name, ex); | throw new BuildException("Failed to read " + name, ex); | ||||
| } finally { | } finally { | ||||