Skip to content

Commit

Permalink
Checks for iterator hasNext element (#18041)
Browse files Browse the repository at this point in the history
* Checks for iterator hasNext element

* Fix linter with newline
  • Loading branch information
ryankfu authored Oct 17, 2022
1 parent e51756b commit ef3e84c
Showing 1 changed file with 7 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ public SshTunnel(final JsonNode config,
URL urlObject = null;
try {
urlObject = new URL(remoteServiceUrl);
} catch (MalformedURLException e) {
} catch (final MalformedURLException e) {
AirbyteTraceMessageUtility.emitConfigErrorTrace(e,
String.format("Provided value for remote service URL is not valid: %s", remoteServiceUrl));
}
Expand Down Expand Up @@ -184,7 +184,8 @@ public JsonNode getConfigInTunnel() throws Exception {
Jsons.replaceNestedInt(clone, portKey, tunnelLocalPort);
}
if (endPointKey != null) {
URL tunnelEndPointURL = new URL(remoteServiceProtocol, SshdSocketAddress.LOCALHOST_ADDRESS.getHostName(), tunnelLocalPort, remoteServicePath);
final URL tunnelEndPointURL =
new URL(remoteServiceProtocol, SshdSocketAddress.LOCALHOST_ADDRESS.getHostName(), tunnelLocalPort, remoteServicePath);
Jsons.replaceNestedString(clone, Arrays.asList(endPointKey), tunnelEndPointURL.toString());
}
return clone;
Expand Down Expand Up @@ -306,7 +307,10 @@ KeyPair getPrivateKeyPair() throws IOException, GeneralSecurityException {
.getKeyPairResourceParser()
.loadKeyPairs(null, null, null, new StringReader(validatedKey));

return (keyPairs == null) ? null : keyPairs.iterator().next();
if (keyPairs != null && keyPairs.iterator().hasNext()) {
return keyPairs.iterator().next();
}
return null;
}

private String validateKey() {
Expand Down

0 comments on commit ef3e84c

Please sign in to comment.