Skip to content

Commit

Permalink
#33849 Fix potential NPEs (#34056)
Browse files Browse the repository at this point in the history
  • Loading branch information
ShadelessFox committed May 24, 2024
1 parent 19941f6 commit 0f1cd18
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,7 @@ public void setClientHomeId(String clientHomeId) {
this.clientHomeId = clientHomeId;
}

@Nullable
public String getHostName() {
return hostName;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ protected SSHClient createNewSession(
try {
client.connect(host.hostname(), host.port());

if (auth instanceof SSHAuthConfiguration.Password password) {
if (auth instanceof SSHAuthConfiguration.Password password && password.password() != null) {
client.authPassword(host.username(), password.password());
} else if (auth instanceof SSHAuthConfiguration.KeyFile key) {
if (CommonUtils.isEmpty(key.password())) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ private static SSHPortForwardConfiguration loadPortForwardConfiguration(

String sshRemoteHost = CommonUtils.toString(configuration.getProperty(SSHConstants.PROP_REMOTE_HOST));
if (CommonUtils.isEmpty(sshRemoteHost)) {
sshRemoteHost = connectionInfo.getHostName();
sshRemoteHost = CommonUtils.notEmpty(connectionInfo.getHostName());
}

int sshRemotePort = configuration.getIntProperty(SSHConstants.PROP_REMOTE_PORT);
Expand Down

0 comments on commit 0f1cd18

Please sign in to comment.