Skip to content

Commit

Permalink
Checks for iterator hasNext element (airbytehq#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 and jhammarstedt committed Oct 31, 2022
1 parent b0c163a commit 2dabf6b
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 2dabf6b

Please sign in to comment.