[releng] bazel: Enable errorprone on o.e.j.ssh.apache

Fix the few issues reported. (None serious.)

Change-Id: I8d72ef7d425ab61f4c27b657c92fc021850730d6
Signed-off-by: Thomas Wolf <thomas.wolf@paranor.ch>
This commit is contained in:
Thomas Wolf 2021-11-02 19:20:59 +01:00 committed by Matthias Sohn
parent 4184ff0953
commit c04884fc91
7 changed files with 28 additions and 9 deletions

View File

@ -439,7 +439,7 @@ public boolean hasNext() {
@Override
public KeyPair next() {
if (hasElement == null && !hasNext()
if ((hasElement == null && !hasNext())
|| !hasElement.booleanValue()) {
throw new NoSuchElementException();
}

View File

@ -95,8 +95,8 @@ public final void close() {
@Override
public final void start() throws Exception {
if (user != null && !user.isEmpty()
|| password != null && password.length > 0) {
if ((user != null && !user.isEmpty())
|| (password != null && password.length > 0)) {
return;
}
askCredentials();

View File

@ -31,7 +31,7 @@ public abstract class AbstractClientProxyConnector
.toMillis(30L);
/** Guards {@link #done} and {@link #bufferedCommands}. */
private Object lock = new Object();
private final Object lock = new Object();
private boolean done;

View File

@ -113,8 +113,8 @@ public void sendClientProxyMetadata(ClientSession sshSession)
IoSession session = sshSession.getIoSession();
session.addCloseFutureListener(f -> close());
StringBuilder msg = connect();
if (proxyUser != null && !proxyUser.isEmpty()
|| proxyPassword != null && proxyPassword.length > 0) {
if ((proxyUser != null && !proxyUser.isEmpty())
|| (proxyPassword != null && proxyPassword.length > 0)) {
authenticator = basic;
basic.setParams(null);
basic.start();
@ -232,7 +232,8 @@ private void handleMessage(IoSession session, List<String> reply)
} catch (HttpParser.ParseException e) {
throw new IOException(
format(SshdText.get().proxyHttpUnexpectedReply,
proxyAddress, reply.get(0)));
proxyAddress, reply.get(0)),
e);
}
}

View File

@ -31,6 +31,23 @@ public static class ParseException extends Exception {
private static final long serialVersionUID = -1634090143702048640L;
/**
* Creates a new {@link ParseException} without cause.
*/
public ParseException() {
super();
}
/**
* Creates a new {@link ParseException} with the given {@code cause}.
*
* @param cause
* {@link Throwable} that caused this exception, or
* {@code null} if none
*/
public ParseException(Throwable cause) {
super(cause);
}
}
private HttpParser() {
@ -64,7 +81,7 @@ public static StatusLine parseStatusLine(String line)
resultCode = Integer.parseUnsignedInt(
line.substring(firstBlank + 1, secondBlank));
} catch (NumberFormatException e) {
throw new ParseException();
throw new ParseException(e);
}
// Again, accept even if the reason is missing
String reason = ""; //$NON-NLS-1$

View File

@ -94,7 +94,7 @@ private enum SocksAuthenticationMethod {
// JSON(9),
NONE_ACCEPTABLE(0xFF);
private byte value;
private final byte value;
SocksAuthenticationMethod(int value) {
this.value = (byte) value;

View File

@ -120,6 +120,7 @@ package_group(
"//org.eclipse.jgit.packaging/...",
"//org.eclipse.jgit.pgm.test/...",
"//org.eclipse.jgit.pgm/...",
"//org.eclipse.jgit.ssh.apache/...",
"//org.eclipse.jgit.test/...",
"//org.eclipse.jgit.ui/...",
"//org.eclipse.jgit/...",