question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Storing JVM system properties in the Spring Environment as Properties can degrade performance due to synchronization

See original GitHub issue

systemProperties PropertySource in Environment implemented with Properties ,But Properties is synchronous, which will reduce performance !!!

Issue Analytics

  • State:open
  • Created 4 years ago
  • Comments:7 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
sbrannencommented, Mar 19, 2020

The system properties are actually stored in a PropertiesPropertySource which by default delegates to System.getProperties() as the source. That happens to be a synchronized Hashtable which implements Map.

So I guess the question is why AbstractEnvironment.getSystemProperties() delegates to System.getProperties() by default, when it could always create a ReadOnlySystemAttributesMap.

Of course, as you mentioned @rstoyanchev, we’d need to know when the synchronization of the system properties is problematic.

0reactions
sbrannencommented, Jul 21, 2020

Even our ReadOnlySystemAttributesMap arrangement delegates to System.getProperty though, hitting the synchronized Properties instance underneath.

Indeed. I was thinking ReadOnlySystemAttributesMap made an upfront copy. Mea culpa.

If system properties are never supposed to be checked at all for performance reasons, maybe we need a setting along the lines of the existing “spring.getenv.ignore”… either for system properties specifically, or for the combination of system properties and system environment checks (since I suppose typically neither of those is needed then).

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 for spring.env.environment.variables.cache=true (though naming is always a challenge).

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found