in clearcase-server/src/jetbrains/buildServer/buildTriggers/vcs/clearcase/process/InteractiveProcess.java [102:154]
private InputStream readFromProcessInput(@NotNull final String[] params) throws IOException, VcsException {
if (myInput == null || myError == null) {
return new ByteArrayInputStream("".getBytes());
}
final int readTimeoutSeconds = getReadTimeoutSeconds();
final long deadline = System.currentTimeMillis() + readTimeoutSeconds * 1000;
while (true) {
if (myInput.available() > 0) break;
if (myError.available() > 0) {
final String errorMesage = readError();
if (errorMesage.trim().length() > 0) {
throw new VcsException(errorMesage);
}
}
checkTimeoutAndSleep(deadline, readTimeoutSeconds, params);
}
final BufferedReader reader = new BufferedReader(new InputStreamReader(myInput));
final StringBuilder buffer = new StringBuilder();
String line;
while ((line = reader.readLine()) != null) {
if (isEndOfCommandOutput(line, params)) {
final String theRest = getLastOutput();
if (theRest != null) {
buffer.append(theRest).append("\n");
}
break;
}
buffer.append(line).append("\n");
}
final String response = buffer.toString();
if (LOG.isDebugEnabled()) {
if (params.length == 0 || !"update".equals(params[0]) || TeamCityProperties.getBoolean("clearcase.log.update")) {
LOG.debug("output line read:\n" + response);
} else {
LOG.debug("output was omitted due to its size");
}
}
final ByteArrayInputStream out = new ByteArrayInputStream(response.getBytes());
return new InputStream() {
@Override
public int read() throws IOException {
return out.read();// fileInput.read();
}
@Override
public void close() throws IOException {
out.close();
}
};
}