use of com.intellij.cvsSupport2.javacvsImpl.io.InputStreamWrapper in project intellij-community by JetBrains.
the class ExtConnection method check.
@SuppressWarnings({ "IOResourceOpenedButNotSafelyClosed" })
private void check(ICvsCommandStopper stopper, String expectedResult) throws IOException, AuthenticationException {
InputStreamWrapper streamWrapper = new InputStreamWrapper(myInputStream, stopper, new ReadWriteStatistics());
try {
StringBuilder buffer = new StringBuilder();
while (true) {
int i = streamWrapper.read();
if (i == -1 || i == '\n' || i == ' ' || i == '\r')
break;
buffer.append((char) i);
}
String read = buffer.toString().trim();
if (!expectedResult.equals(read)) {
if (StringUtil.startsWithConcatenation(read, myUserName, "@", myHost)) {
throw new AuthenticationException(CvsBundle.message("exception.text.ext.server.rejected.access"), null);
} else {
if (myErrorText.length() > 0) {
throw new AuthenticationException(myErrorText.toString(), null);
} else {
throw new AuthenticationException(CvsBundle.message("exception.text.ext.cannot.establish.external.connection"), null);
}
}
}
} finally {
streamWrapper.close();
}
}
Aggregations