Skip to content

Commit

Permalink
fix: Check for empty config properties instead of null
Browse files Browse the repository at this point in the history
  • Loading branch information
jruaux committed Dec 19, 2023
1 parent e2f3cc8 commit 57ec756
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/main/java/com/redis/trino/RediSearchSession.java
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@
import java.util.concurrent.TimeUnit;
import java.util.stream.Collectors;

import org.apache.bval.util.StringUtils;

import com.google.common.cache.Cache;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableSet;
Expand Down Expand Up @@ -153,20 +155,20 @@ private ProtocolVersion protocolVersion(RediSearchConfig config) {

public SslOptions sslOptions(RediSearchConfig config) {
Builder ssl = SslOptions.builder();
if (config.getKeyPath() != null) {
if (StringUtils.isNotBlank(config.getKeyPath())) {
ssl.keyManager(new File(config.getCertPath()), new File(config.getKeyPath()),
config.getKeyPassword().toCharArray());
}
if (config.getCaCertPath() != null) {
if (StringUtils.isNotBlank(config.getCaCertPath())) {
ssl.trustManager(new File(config.getCaCertPath()));
}
return ssl.build();
}

private RedisURI redisURI(RediSearchConfig config) {
RedisURI.Builder uri = RedisURI.builder(RedisURI.create(config.getUri()));
if (config.getPassword() != null) {
if (config.getUsername() != null) {
if (StringUtils.isNotBlank(config.getPassword())) {
if (StringUtils.isNotBlank(config.getUsername())) {
uri.withAuthentication(config.getUsername(), config.getPassword());
} else {
uri.withPassword(config.getPassword().toCharArray());
Expand Down

0 comments on commit 57ec756

Please sign in to comment.