Skip to content

Register Base64ProtocolResolver as protocol resolver by default #41433

New issue

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

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

Already on GitHub? # to your account

Closed
vpavic opened this issue Jul 9, 2024 · 5 comments
Closed

Register Base64ProtocolResolver as protocol resolver by default #41433

vpavic opened this issue Jul 9, 2024 · 5 comments
Assignees
Labels
type: enhancement A general enhancement
Milestone

Comments

@vpavic
Copy link
Contributor

vpavic commented Jul 9, 2024

In most of our projects these days, we use the following approach to be able to bind base64 encoded files as configuration properties of org.springframework.core.io.Resource type:

@SpringBootApplication
public class MyApplication {

	public static void main(String[] args) {
		SpringApplication application = new SpringApplication(MyApplication.class);
		application.addInitializers(context -> context.addProtocolResolver(new Base64ProtocolResolver()));
		application.run(args);
	}

}

Where Base64ProtocolResolver is basically line for line identical implementation to the one recently introduced in #36033.

Upgrading to Spring Boot 3.3, expectation was we would be able to remove our homegrown Base64ProtocolResolver and boilerplate code from the application main class, but this is not possible because newly introduced Base64ProtocolResolver isn't registered with application context as protocol resolver. Additionally, Spring Boot provided Base64ProtocolResolver is (understandably) package private so it can't be reused.

Would it be possible to register Base64ProtocolResolver as protocol resolver by default?

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Jul 9, 2024
@philwebb philwebb changed the title Register Base64ProtocolResolver as protocol resolver by default Register Base64ProtocolResolver as protocol resolver by default Jul 9, 2024
@philwebb
Copy link
Member

philwebb commented Jul 9, 2024

I think we should do something similar to ApplicationResourceLoader and apply all protocol protocol resolvers we find via SpringFactoriesLoader.

@philwebb
Copy link
Member

philwebb commented Jul 9, 2024

Flagging to see if the team thing we should consider this a bug or and enhancement. I'm leaning enhancement to be on the safe side.

@philwebb philwebb added the for: team-attention An issue we'd like other members of the team to review label Jul 9, 2024
@scottfrederick
Copy link
Contributor

I think it should be an enhancement also.

This should fix the problem noted here, where a configuration property class with a field of type Resource does not resolve properly with a base64: resource.

@philwebb philwebb added type: enhancement A general enhancement and removed for: team-attention An issue we'd like other members of the team to review status: waiting-for-triage An issue we've not yet triaged labels Jul 9, 2024
@philwebb philwebb added this to the 3.4.x milestone Jul 9, 2024
@scottfrederick scottfrederick self-assigned this Jul 9, 2024
@scottfrederick scottfrederick modified the milestones: 3.4.x, 3.4.0-M1 Jul 10, 2024
@vpavic
Copy link
Contributor Author

vpavic commented Nov 25, 2024

Could you mention this in 3.4 release notes?

@philwebb
Copy link
Member

philwebb commented Dec 3, 2024

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
type: enhancement A general enhancement
Projects
None yet
Development

No branches or pull requests

4 participants