diff --git a/ant_tasks/source/java/ch/systemsx/cisd/ant/task/subversion/SVNUtilities.java b/ant_tasks/source/java/ch/systemsx/cisd/ant/task/subversion/SVNUtilities.java index 54799161ac4a3a1cc4a2824255ca4a07f76b5751..c748b0298c22080cfc94ac3a4d2d27910ded3768 100644 --- a/ant_tasks/source/java/ch/systemsx/cisd/ant/task/subversion/SVNUtilities.java +++ b/ant_tasks/source/java/ch/systemsx/cisd/ant/task/subversion/SVNUtilities.java @@ -16,23 +16,19 @@ package ch.systemsx.cisd.ant.task.subversion; -import java.io.BufferedReader; import java.io.File; import java.io.IOException; -import java.io.InputStream; -import java.io.InputStreamReader; import java.util.ArrayList; import java.util.Arrays; import java.util.List; -import java.util.concurrent.Semaphore; import java.util.regex.Matcher; import java.util.regex.Pattern; import ch.systemsx.cisd.ant.common.StringUtils; -import ch.systemsx.cisd.common.exceptions.EnvironmentFailureException; import ch.systemsx.cisd.common.exceptions.UserFailureException; import ch.systemsx.cisd.common.logging.ISimpleLogger; import ch.systemsx.cisd.common.logging.LogLevel; +import ch.systemsx.cisd.common.process.InputStreamReaderGobbler; import ch.systemsx.cisd.common.utilities.OSUtilities; /** @@ -107,56 +103,6 @@ class SVNUtilities } - private static final class StreamReaderGobbler - { - private final Semaphore waitForReadingFinishedSemaphore = new Semaphore(1); - - private final List<String> lines = new ArrayList<String>(); - - StreamReaderGobbler(final InputStream stream) throws InterruptedException - { - waitForReadingFinishedSemaphore.acquire(); - final Thread t = new Thread() - { - @Override - public void run() - { - try - { - final BufferedReader reader = - new BufferedReader(new InputStreamReader(stream)); - String line; - while ((line = reader.readLine()) != null) - { - lines.add(line); - } - } catch (IOException ex) - { - throw new EnvironmentFailureException("Couldn't gobble stream content", - ex); - } finally - { - waitForReadingFinishedSemaphore.release(); - } - } - }; - t.start(); - } - - List<String> getLines() throws InterruptedException - { - waitForReadingFinishedSemaphore.acquire(); - try - { - return lines; - } finally - { - waitForReadingFinishedSemaphore.release(); - } - } - - } - /** * @return The top-level directory (first level of the hierarchy) of <var>path</var>. */ @@ -284,10 +230,10 @@ class SVNUtilities try { final Process process = builder.start(); - StreamReaderGobbler inputStreamGobbler = - new StreamReaderGobbler(process.getInputStream()); - StreamReaderGobbler errorStreamGobbler = - new StreamReaderGobbler(process.getErrorStream()); + InputStreamReaderGobbler inputStreamGobbler = + new InputStreamReaderGobbler(process.getInputStream()); + InputStreamReaderGobbler errorStreamGobbler = + new InputStreamReaderGobbler(process.getErrorStream()); final int exitValue = process.waitFor(); List<String> lines = inputStreamGobbler.getLines(); if (0 != exitValue) @@ -336,8 +282,8 @@ class SVNUtilities try { final Process process = builder.start(); - StreamReaderGobbler inputStreamGobbler = - new StreamReaderGobbler(process.getInputStream()); + InputStreamReaderGobbler inputStreamGobbler = + new InputStreamReaderGobbler(process.getInputStream()); final int exitValue = process.waitFor(); List<String> lines = inputStreamGobbler.getLines(); if (0 != exitValue)