Skip to content

MessageSourceResourceBundle.containsKey throws NullPointerException [SPR-10136] #14769

@spring-projects-issues

Description

@spring-projects-issues

Adrien Bonnin opened SPR-10136 and commented

When I try to use containsKey method on a MessageSourceResourceBundle instance I got the following NullPointerException :

Exception in thread "main" java.lang.NullPointerException
at java.util.ResourceBundle.handleKeySet(ResourceBundle.java:1787)
at java.util.ResourceBundle.containsKey(ResourceBundle.java:1741)
at net.toto.main(Main.java:36)

Here is a sample code :

Locale locale = Locale.getDefault();

ResourceBundleMessageSource bundle = new ResourceBundleMessageSource();
bundle.setBasename("bundles.Main");
System.out.println(bundle.getMessage("settings", new Object[0], locale));

MessageSourceResourceBundle bundle2 = new MessageSourceResourceBundle(bundle, locale);
System.out.println(bundle2.getString("settings"));

bundle2.containsKey("settings"); // NullPointerException


Affects: 3.1.2

Backported to: 3.1.4

Metadata

Metadata

Assignees

Labels

in: coreIssues in core modules (aop, beans, core, context, expression)status: backportedAn issue that has been backported to maintenance branchestype: bugA general bug

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions