LogManagerProperties extends Properties { @Override public synchronized Object put(final Object key, final Object value) { final Object def = preWrite(key); final Object man = super.put(key, value); return man == null ? def : man; } LogManagerProperties(final Properties parent, final String prefix); @Override @SuppressWarnings("CloneDoesntCallSuperClone") synchronized Object clone(); @Override synchronized String getProperty(final String key); @Override String getProperty(final String key, final String def); @Override Object get(final Object key); @Override synchronized Object put(final Object key, final Object value); @Override Object setProperty(String key, String value); @Override boolean containsKey(final Object key); @Override synchronized Object remove(final Object key); @Override Enumeration<?> propertyNames(); @Override boolean equals(final Object o); @Override int hashCode();  }
@Test public void testPut() throws Exception { String prefix = LogManagerPropertiesTest.class.getName(); LogManager manager = LogManager.getLogManager(); try { String key = prefix.concat(".dummy"); Properties parent = new Properties(); parent.put(key, "value"); parent.put("", "empty"); read(manager, parent); parent = new Properties(); LogManagerProperties mp = new LogManagerProperties(parent, prefix); assertFalse(contains(mp, key, null)); assertEquals("value", mp.put(key, "newValue")); assertFalse(contains(mp, key, "value")); assertTrue(contains(mp, key, "newValue")); parent.put(key, "defValue"); assertEquals("newValue", mp.remove(key)); assertEquals("defValue", mp.remove(key)); assertEquals("empty", mp.put("", "")); } finally { manager.reset(); } }