Skip to content

fix(storage): preserve port in spring.cloud.gcp.storage.host (#4343)#4393

Open
kioie wants to merge 1 commit intoGoogleCloudPlatform:mainfrom
kioie:fix/4343-storage-host-port
Open

fix(storage): preserve port in spring.cloud.gcp.storage.host (#4343)#4393
kioie wants to merge 1 commit intoGoogleCloudPlatform:mainfrom
kioie:fix/4343-storage-host-port

Conversation

@kioie
Copy link
Copy Markdown
Contributor

@kioie kioie commented Mar 30, 2026

Description

Fixes #4343

Problem:
When configuring spring.cloud.gcp.storage.host with a custom port (such as for a local emulator or fake-gcs-server Testcontainers setup), the port number was being silently removed by GcpStorageAutoConfiguration. Specifically, verifyAndFetchHost() used URL.getHost() which only returns the hostname portion. This resulted in http://localhost:54321 being incorrectly transformed to http://localhost/, causing Connection refused errors during integration tests.

Solution:
Replaced url.getHost() with url.getAuthority() in GcpStorageAutoConfiguration.java. url.getAuthority() properly returns host:port when a port is present, and behaves identically to url.getHost() when no port is configured, guaranteeing no breaking regressions for existing configurations.

Contribution Checklist

  • Issue Linked: This PR addresses an existing issue (Bug Report: spring.cloud.gcp.storage.host Drops Port Number #4343) that has been labeled with "Accepting Contributions".
  • Clear Description: The PR description clearly states the problem and the proposed solution.
  • Unit Tests: Added a new unit test (testHostWithPort()) in GcpStorageAutoConfigurationTests.java to explicitly test and prevent regressions of hosts configured with ports.
  • Tests Passed: Verified that all existing and new unit tests pass successfully (./mvnw -pl spring-cloud-gcp-autoconfigure test -Dtest=GcpStorageAutoConfigurationTests).
  • Code Formatting: Ensured the code conforms to the Google Java Style Guide (verified via the validate-google-style checkstyle plugin check running without errors).
  • CLA Signed: (I have signed the Contributor License Agreement).

@kioie kioie requested a review from a team as a code owner March 30, 2026 18:15
@cursor cursor Bot deleted the fix/4343-storage-host-port branch April 3, 2026 15:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bug Report: spring.cloud.gcp.storage.host Drops Port Number

1 participant