Skip to content

ResourceBundleMessageSource should avoid ResourceBundle.Control on Jigsaw [SPR-16776] #21316

@spring-projects-issues

Description

@spring-projects-issues

Leonardo Zanivan opened SPR-16776 and commented

ResourceBundleMessageSource broken when using Java 9 module system.

Using a custom ResourceBundle.Control isn't supported by Java 9 Module system.

Strack trace:

java.lang.UnsupportedOperationException: ResourceBundle.Control not supported in named modulesjava.lang.UnsupportedOperationException: ResourceBundle.Control not supported in named modules at java.base/java.util.ResourceBundle.checkNamedModule(ResourceBundle.java:1547) at java.base/java.util.ResourceBundle.getBundle(ResourceBundle.java:1508) at spring.context@5.0.5.RELEASE/org.springframework.context.support.ResourceBundleMessageSource.doGetBundle(ResourceBundleMessageSource.java:223) at spring.context@5.0.5.RELEASE/org.springframework.context.support.ResourceBundleMessageSource.getResourceBundle(ResourceBundleMessageSource.java:189) at spring.context@5.0.5.RELEASE/org.springframework.context.support.ResourceBundleMessageSource.resolveCodeWithoutArguments(ResourceBundleMessageSource.java:132) at spring.context@5.0.5.RELEASE/org.springframework.context.support.AbstractMessageSource.getMessageInternal(AbstractMessageSource.java:212) at spring.context@5.0.5.RELEASE/org.springframework.context.support.AbstractMessageSource.getMessage(AbstractMessageSource.java:169) at spring.context@5.0.5.RELEASE/org.springframework.context.support.AbstractApplicationContext.getMessage(AbstractApplicationContext.java:1276) at spring.webmvc@5.0.5.RELEASE/org.springframework.web.servlet.support.RequestContext.getMessage(RequestContext.java:725)

The error is caused by the following line which is using a custom ResourceBundle.Control.

https://github.com/spring-projects/spring-framework/blob/master/spring-context/src/main/java/org/springframework/context/support/ResourceBundleMessageSource.java#L223

Steps to reproduce:

Petclinic is the sample ported application to Spring Boot 2.0.1 and Java 9 module system.

  1. Clone:

https://github.com/panga/spring-petclinic-java9modules

  1. Build with JDK 10:
mvn clean package
  1. Run application with module-path:
mvn exec:exec

Note: mvn spring-boot:run goal will execute in classpath mode, thus the erros doesn't happen.

  1. Open browser with url:

http://localhost:8080/owners?lastName=test

  1. Verify the stack trace in the console.

Affects: 5.0.5

Issue Links:

Metadata

Metadata

Assignees

Labels

in: coreIssues in core modules (aop, beans, core, context, expression)type: bugA general bug

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions