Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Checks for iterator hasNext element #18041

Merged
merged 2 commits into from
Oct 17, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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