Skip to content

Commit

Permalink
Checks for iterator hasNext element
Browse files Browse the repository at this point in the history
  • Loading branch information
ryankfu committed Oct 17, 2022
1 parent e079761 commit 0145c30
Showing 1 changed file with 6 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,7 @@ 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 +306,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 0145c30

Please sign in to comment.