How to determine if a Java System property has changed?

I would like to know when the System property changes. I have an application on the application server that somehow changes the system property ( System.setProperty() I think). I looked and I found different approaches:

Any suggestions? Thanks in advance.

+6
source share
2 answers

You can replace system properties with your own subclass.

 MyProperties newProps = new MyProperties(System.getProperties()); System.setProperties(newProps); 

Then just write a subclass of properties that intercepts the appropriate methods.

+5
source

If you first want to find the problem, I would look at this SecurityManager . It has several methods, checkPropertiesAccess() and checkPropertyAccess() which look like they will help you find the problem, but they may not be able to "notify you of a change in the system property."

+1
source

Source: https://habr.com/ru/post/916405/


All Articles