Proposed action: The query method SwitchPoint.isValid was introduced in 7032323 after a vote by the JSR 292 Expert Group. Subsequently, one member (IBM) has asked that, if the API is not removed, it be renamed to SwitchPoint.hasBeenInvalidated, with an inverted boolean sense. (I.e., a valid switchpoint reports hasBeenInvalidated=false.)
This is a reasonable request from IBM, strongly presented.
From: Daniel Heidinga <###@###.###>
Date: June 2, 2011 2:25:40 PM PDT
To: John Rose <###@###.###>
Subject: SwitchPoint#isValid() is the wrong api
Hi John,
As we discussed earlier, SwitchPoint#isValid() is the wrong api. It leads users to make decisions based on the transient state of the SwitchPoint, rather than its terminal state. The only actionable information the SwitchPoint can provide is whether it has already been invalidated. The API in question shouldn't be 'isValid()', rather it should be 'hasBeenInvalidated()'.
Providing an isValid() query will encourage users to introduce bugs and race conditions into their programs. Regardless of how many warnings we put in the javadoc for this method, most users will find 'isValid()' from their IDE's code completion and never read the javadoc until they get bitten by the race conditions due to its use. Let's not encourage our users to create bugs.
Ideally, I'd like to see this API removed. If it can't be removed, at least rename it to 'hasBeenInvalidated()' so that the query guides users to the only safe use.
Regards,
--Dan