Skip to content

fix: AlloyDB should not load when Postgres starter is used #2848

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
May 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions spring-cloud-gcp-autoconfigure/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -302,6 +302,7 @@
<dependency>
<groupId>com.google.cloud</groupId>
<artifactId>alloydb-jdbc-connector</artifactId>
<optional>true</optional>
</dependency>

<!-- Config -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,11 +85,11 @@ && isOnClasspath(JDBC_DRIVER_CLASS)) {
environment
.getPropertySources()
.addFirst(new MapPropertySource("ALLOYDB_DATA_SOURCE_URL", primaryMap));
}

// support usage metrics
ConnectorRegistry.addArtifactId(
"spring-cloud-gcp-alloydb/" + this.getClass().getPackage().getImplementationVersion());
// support usage metrics
ConnectorRegistry.addArtifactId(
"spring-cloud-gcp-alloydb/" + this.getClass().getPackage().getImplementationVersion());
}
}

private String getJdbcUrl(AlloyDbProperties properties) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
import org.springframework.http.ResponseEntity;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.test.context.junit.jupiter.SpringExtension;
import org.springframework.util.ClassUtils;

/** Simple integration test to verify the SQL sample application with Postgres. */
@EnabledIfSystemProperty(named = "it.cloudsql", matches = "true")
Expand Down Expand Up @@ -69,4 +70,10 @@ void testSqlRowsAccess() {
"[[email protected], Jonas, Goncalves]",
"[[email protected], Ljubomir, Fejsa]");
}

@Test
void testNoAllyDbLoaded() {
assertThat(ClassUtils.isPresent("com.google.cloud.alloydb.SocketFactory", null))
.isFalse();
}
}
Loading