Storing JVM system properties in the Spring Environment as Properties can degrade performance due to synchronization
See original GitHub issuesystemProperties
PropertySource in Environment implemented with Properties ,But Properties is synchronous, which will reduce performance !!!
Issue Analytics
- State:
- Created 4 years ago
- Comments:7 (5 by maintainers)
Top Results From Across the Web
Java virtual machine custom properties - IBM
Java virtual machine custom properties. You can use the administrative console to change the values of Java™ virtual machine (JVM) custom properties.
Read more >Top 10 Most Common Spring Framework Mistakes - Toptal
If there is a reason why the global variable must remain modifiable, carefully employ synchronization and track your application's performance to confirm that ......
Read more >59. Properties & configuration - Spring
A separate Environment property source is set up for this document and it can be overridden by system properties, environment variables or the...
Read more >Scope of the Java System Properties - jvm - Stack Overflow
It turns out, when running the two programs using two separate java processes, the value for the property set in one JVM process...
Read more >JVM system properties | Fisheye Server 4.8
Administrators can configure the Java Virtual Machine (JVM) system properties described on this page to control low level aspects of Fisheye ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
The system properties are actually stored in a
PropertiesPropertySource
which by default delegates toSystem.getProperties()
as thesource
. That happens to be a synchronizedHashtable
which implementsMap
.So I guess the question is why
AbstractEnvironment.getSystemProperties()
delegates toSystem.getProperties()
by default, when it could always create aReadOnlySystemAttributesMap
.Of course, as you mentioned @rstoyanchev, we’d need to know when the synchronization of the system properties is problematic.
Indeed. I was thinking
ReadOnlySystemAttributesMap
made an upfront copy. Mea culpa.I agree. Something like
spring.env.system.properties.cache=true
could signal that JVM system properties should be retrieved once and cached in a read-only map. And the same would hold forspring.env.environment.variables.cache=true
(though naming is always a challenge).