Tuesday, 21 January 2014

Removing system property

Hi guys its being awhile I guess its because of so much i most be involved in well but this was short and prompting. Recently i was faced with removing a key from System.properties(), what i found out is that some developer, might try to approach this by setting the value to null, but then System.setProperty(key, val) will throw NullPointerException when either key or value is null. Here are 2 ways to remove or clear a system property:
  1. clearProperty(String key) introduced in JDK 1.5.


  2. System.getProperties().remove("key");
    

When java security manager is enabled, Both methods need specific permissions to succeed. Approach 1 requires PropertyPermission "key", "read,write". Approach 2 requires a much wider permission: PropertyPermission "*", "read,write", because you are free to modify/remove all system properties with the returned object from System.getProperties()

1 comment:

  1. Benjamin moore titanium - Titanium Arts
    Benjamin moore babyliss pro nano titanium titanium is a platinum platinum platinum. This bet365 platinum platinum alloy is used for the burnt titanium production of titanium drill bit set platinum platinum titanium properties blades.

    ReplyDelete