Code Review Request for 6578042
darryl.mocek at oracle.com
Tue Nov 15 19:51:00 UTC 2011
I've modified the fix per feedback (thanks all). System.clearProperty
now attempts to get the property with the specified key. If there is
such a property, and the value is a String, remove the property and
return the value removed, otherwise return null (if it is null) or throw
CCE (if it's not null and is not a String...do not remove the property
here). Webrev can be found here:
On 11/12/2011 04:14 AM, Alan Bateman wrote:
> On 11/11/2011 19:37, Darryl Mocek wrote:
>> Returning null if the value is not a String gives the impression that
>> there was no property with that key when the property may have been
>> there and may in fact have been removed.
> That's a fair point and probably enough to conclude that this approach
> should be dismissed.
> The toString approach is inconsistent so I think this brings us back
> to the original suggestion which is to specify that CCE is thrown (as
> it always has) but without side effects (meaning it doesn't remove the
> property). I think this is the best we can do with this broken API.
>> I would prefer it if Properties didn't allow non-String keys and
>> values at all since they're supposed to be Strings (by API
>> implication) and that Properties not extend Hashtable or extends
>> Hashtable<String, String>, but I digress.
> Properties goes back to JDK1.0 and has a warning in its javadoc for
> many years to discourage inserting keys or values that are not
> Strings. I'm not sure whether we can do much about it now without
> risking compatibility issues.
More information about the core-libs-dev