Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Ignore non-String keys in PropertiesPropertySource.getPropertyNames() #32742

Closed
tyt-gtdg opened this issue May 1, 2024 · 5 comments
Closed
Assignees
Labels
in: core Issues in core modules (aop, beans, core, context, expression) status: backported An issue that has been backported to maintenance branches type: bug A general bug
Milestone

Comments

@tyt-gtdg
Copy link

tyt-gtdg commented May 1, 2024

System.getProperties().put(1,1);

2024-05-01 11:16:16.216 ERROR - [http-nio-55588-exec-2]  o.a.c.c.C.[.[.[/].[dispatcherServlet] : Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [org.apache.shiro.authc.AuthenticationException: error token] with root cause

java.lang.ArrayStoreException: java.lang.Integer
	at java.util.AbstractCollection.toArray(AbstractCollection.java:196) ~[na:1.8.0_301]
	at java.util.Collections$SynchronizedCollection.toArray(Collections.java:2029) ~[na:1.8.0_301]
	at org.springframework.util.StringUtils.toStringArray(StringUtils.java:924) ~[spring-core-5.2.10.RELEASE.jar:5.2.10.RELEASE]
	at org.springframework.core.env.MapPropertySource.getPropertyNames(MapPropertySource.java:60) ~[spring-core-5.2.10.RELEASE.jar:5.2.10.RELEASE]
	at org.springframework.core.env.PropertiesPropertySource.getPropertyNames(PropertiesPropertySource.java:51) ~[spring-core-5.2.10.RELEASE.jar:5.2.10.RELEASE]
	at org.springframework.cloud.netflix.archaius.ConfigurableEnvironmentConfiguration.getKeys(ConfigurableEnvironmentConfiguration.java:75) ~[spring-cloud-netflix-archaius-2.2.5.RELEASE.jar:2.2.5.RELEASE]
	at org.apache.commons.configuration.AbstractConfiguration.getKeys(AbstractConfiguration.java:574) ~[commons-configuration-1.8.jar:1.8]
	at com.netflix.config.ConcurrentCompositeConfiguration.getKeys(ConcurrentCompositeConfiguration.java:600) ~[archaius-core-0.7.6.jar:0.7.6]
	at org.apache.commons.configuration.SubsetConfiguration.getKeys(SubsetConfiguration.java:192) ~[commons-configuration-1.8.jar:1.8]
	at com.netflix.client.config.DefaultClientConfigImpl.loadProperties(DefaultClientConfigImpl.java:580) ~[ribbon-core-2.3.0.jar:2.3.0]
@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged or decided on label May 1, 2024
@snicoll
Copy link
Member

snicoll commented May 1, 2024

@tyt-gtdg thanks for the report, but a line of code is not an actionable bug report. If you want support, please take the time to provide more details as your assumption is hiding more details that we need to investigate.

A sample application that reproduces the problem is ideal. You can attach a zip to this issue or push the code to a separate GitHub repository.

@snicoll snicoll added the status: waiting-for-feedback We need additional information before we can continue label May 1, 2024
@sbrannen
Copy link
Member

sbrannen commented May 1, 2024

In addition, please note that Spring Framework 5.2.10.RELEASE is no longer supported.

In light of that, please upgrade to a supported version to see if the issue still exists.

@jhoeller
Copy link
Contributor

jhoeller commented May 1, 2024

@tyt-gtdg I suppose you'd expect Spring's PropertiesPropertySource to verify that it only contains Strings, or specifically for getPropertyNames to ignore non-String keys? Since we just wrap a target Map/Properties instance there, we cannot reject it - but we can make getPropertyNames leniently ignore non-String keys, just like java.util.Properties.stringPropertyNames() does.

@jhoeller jhoeller changed the title No type checking is done on the collection elements Ignore non-String keys in PropertiesPropertySource.getPropertyNames() May 1, 2024
@jhoeller jhoeller added in: core Issues in core modules (aop, beans, core, context, expression) type: enhancement A general enhancement and removed status: waiting-for-feedback We need additional information before we can continue status: waiting-for-triage An issue we've not yet triaged or decided on labels May 1, 2024
@jhoeller jhoeller self-assigned this May 1, 2024
@jhoeller jhoeller added this to the 6.1.7 milestone May 1, 2024
@jhoeller jhoeller added type: bug A general bug for: backport-to-6.0.x and removed type: enhancement A general enhancement labels May 1, 2024
@github-actions github-actions bot added status: backported An issue that has been backported to maintenance branches and removed for: backport-to-6.0.x labels May 1, 2024
jhoeller added a commit that referenced this issue May 1, 2024
jhoeller added a commit that referenced this issue May 1, 2024
@tyt-gtdg
Copy link
Author

tyt-gtdg commented May 9, 2024

@tyt-gtdg thanks for the report, but a line of code is not an actionable bug report. If you want support, please take the time to provide more details as your assumption is hiding more details that we need to investigate.

A sample application that reproduces the problem is ideal. You can attach a zip to this issue or push the code to a separate GitHub repository.

static { System.getProperties().put(1,1); } public static void main(String[] args) { SpringApplication.run(SystemServerApplication.class, args); }
If you start it the way above, You will see boot failure.

at org.springframework.util.StringUtils.toStringArray(StringUtils.java:954)

Collection genericity String

@jhoeller
Copy link
Contributor

@tyt-gtdg indeed, and this should be fixed in the meantime. Feel free to give a recent 6.1.7 snapshot a try...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: core Issues in core modules (aop, beans, core, context, expression) status: backported An issue that has been backported to maintenance branches type: bug A general bug
Projects
None yet
Development

No branches or pull requests

5 participants