From d25e52d637cff0b8fc971738d514522074ba4e6e Mon Sep 17 00:00:00 2001 From: Simon Marty Date: Fri, 25 Aug 2023 10:04:22 -0700 Subject: [PATCH] Always append slash after Postgres db endpoint (#209) --- .../sql/AWSSecretsManagerPostgreSQLDriver.java | 5 ++++- .../sql/AWSSecretsManagerPostgreSQLDriverTest.java | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/amazonaws/secretsmanager/sql/AWSSecretsManagerPostgreSQLDriver.java b/src/main/java/com/amazonaws/secretsmanager/sql/AWSSecretsManagerPostgreSQLDriver.java index bfd2d6d..8af0071 100644 --- a/src/main/java/com/amazonaws/secretsmanager/sql/AWSSecretsManagerPostgreSQLDriver.java +++ b/src/main/java/com/amazonaws/secretsmanager/sql/AWSSecretsManagerPostgreSQLDriver.java @@ -116,8 +116,11 @@ public String constructUrlFromEndpointPortDatabase(String endpoint, String port, if (!StringUtils.isNullOrEmpty(port)) { url += ":" + port; } + + url += "/"; + if (!StringUtils.isNullOrEmpty(dbname)) { - url += "/" + dbname; + url += dbname; } return url; } diff --git a/src/test/java/com/amazonaws/secretsmanager/sql/AWSSecretsManagerPostgreSQLDriverTest.java b/src/test/java/com/amazonaws/secretsmanager/sql/AWSSecretsManagerPostgreSQLDriverTest.java index d6239dd..a7ecf4b 100644 --- a/src/test/java/com/amazonaws/secretsmanager/sql/AWSSecretsManagerPostgreSQLDriverTest.java +++ b/src/test/java/com/amazonaws/secretsmanager/sql/AWSSecretsManagerPostgreSQLDriverTest.java @@ -93,7 +93,7 @@ public void test_constructUrlNullPort() { @Test public void test_constructUrlNullDatabase() { String url = sut.constructUrlFromEndpointPortDatabase("test-endpoint", "1234", null); - assertEquals(url, "jdbc:postgresql://test-endpoint:1234"); + assertEquals(url, "jdbc:postgresql://test-endpoint:1234/"); } @Test