Skip to content

S3 Resource handler addResourceLocations error with Spring Framework 6.2.19+ #1636

Description

@dafriz

Type: Bug

Component:
S3

Describe the bug
Using Spring Cloud AWS 3.4.2 when updating from Spring Framework 6.2.18 to 6.2.19 the following no longer works for io.awspring.cloud.s3.S3Resource

@Override
public void addResourceHandlers(ResourceHandlerRegistry registry) {
        registry.addResourceHandler("path/**")
                .addResourceLocations("s3://bucket/path/")
)

As Spring Framework enforces a slash on end ( spring-projects/spring-framework@fb0c78a )

resolveResourceLocations() was patched to call assertResourceLocation() for every resolved resource — so string-based locations get the same validation. s3:// location encounters problem: Spring Cloud AWS's Location.resolveObjectName() strips the trailing slash ("path/" → "path"), so S3Resource.getURL() builds a path-style URL https://s3.amazonaws.com/path without a trailing slash, and url.getPath() fails the assertion.

Metadata

Metadata

Assignees

Labels

component: s3S3 integration related issue

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions