Skip to content

Commit

Permalink
fixed failing test
Browse files Browse the repository at this point in the history
  • Loading branch information
alexradzin committed Nov 1, 2023
1 parent 5d17ef9 commit cd9b0b2
Showing 1 changed file with 5 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import java.util.Optional;

import static java.lang.String.format;
import static java.util.Optional.ofNullable;
import static java.util.concurrent.TimeUnit.SECONDS;
import static net.jodah.expiringmap.ExpirationPolicy.CREATED;

Expand Down Expand Up @@ -47,8 +48,8 @@ public FireboltConnectionTokens getConnectionTokens(String host, FireboltPropert
}
} catch (FireboltException e) {
log.error("Failed to connect to Firebolt", e);
String msg = e.getErrorMessageFromServer() == null ? errorMessage : errorMessageFromServer;
throw new FireboltException(format(msg, e.getMessage()), e);
String msg = ofNullable(e.getErrorMessageFromServer()).map(m -> format(errorMessageFromServer, m)).orElse(format(errorMessage, e.getMessage()));
throw new FireboltException(msg, e);
} catch (Exception e) {
log.error("Failed to connect to Firebolt", e);
throw new FireboltException(format(errorMessage, e.getMessage()), e);
Expand Down Expand Up @@ -88,8 +89,8 @@ private static class ConnectParams {
public ConnectParams(String fireboltHost, String principal, String secret) throws NoSuchAlgorithmException {
this.fireboltHost = fireboltHost;
MessageDigest sha256Instance = MessageDigest.getInstance("SHA-256");
Optional.ofNullable(principal).map(String::getBytes).ifPresent(sha256Instance::update);
Optional.ofNullable(secret).map(String::getBytes).ifPresent(sha256Instance::update);
ofNullable(principal).map(String::getBytes).ifPresent(sha256Instance::update);
ofNullable(secret).map(String::getBytes).ifPresent(sha256Instance::update);
this.credentialsHash = DatatypeConverter.printHexBinary(sha256Instance.digest());
}
}
Expand Down

0 comments on commit cd9b0b2

Please sign in to comment.