Skip to content

Commit 0cb34a7

Browse files
Update the empty credential condition for Mongo and Postgres (#175)
1 parent d6384e9 commit 0cb34a7

File tree

3 files changed

+6
-2
lines changed

3 files changed

+6
-2
lines changed

document-store/src/main/java/org/hypertrace/core/documentstore/model/config/ConnectionCredentials.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,4 +26,8 @@ public class ConnectionCredentials {
2626
public Optional<String> authDatabase() {
2727
return Optional.ofNullable(authDatabase);
2828
}
29+
30+
public boolean isEmpty() {
31+
return username.isBlank() && password.isBlank();
32+
}
2933
}

document-store/src/main/java/org/hypertrace/core/documentstore/model/config/mongo/MongoConnectionConfig.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ private static String getDatabaseOrDefault(@Nullable final String database) {
9595
@Nullable
9696
private static ConnectionCredentials getCredentialsOrDefault(
9797
@Nullable final ConnectionCredentials credentials, @Nullable final String database) {
98-
if (credentials == null || ConnectionCredentials.builder().build().equals(credentials)) {
98+
if (credentials == null || credentials.isEmpty()) {
9999
return null;
100100
}
101101

document-store/src/main/java/org/hypertrace/core/documentstore/model/config/postgres/PostgresConnectionConfig.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ public Properties buildProperties() {
6464
final Properties properties = new Properties();
6565
final ConnectionCredentials credentials = credentials();
6666

67-
if (credentials != null) {
67+
if (credentials != null && !credentials.isEmpty()) {
6868
properties.setProperty(PGProperty.USER.getName(), credentials.username());
6969
properties.setProperty(PGProperty.PASSWORD.getName(), credentials.password());
7070
}

0 commit comments

Comments
 (0)