Null pointer checks in event handler / filter registration methods

Lubomir Nerad lubomir.nerad at oracle.com
Fri Jan 13 07:29:54 PST 2012


Right, null event handler value will remain valid for on<EventType> 
properties.

On 13.1.2012 16:21, Richard Bair wrote:
> I think you are fine, sounds like a bug to me as opposed to a change in intent. I'm assuming you will update the docs to indicate null is not allowed. If somebody binds onMouseClicked to null, that should not thrown exception but just unregister any previous handler and not register a new one, right?
>
> Thanks
> Richard
>
>
>
> On Jan 13, 2012, at 7:12 AM, Lubomir Nerad<lubomir.nerad at oracle.com>  wrote:
>
>> Hi,
>>
>> I am working on http://javafx-jira.kenai.com/browse/RT-18865 (Adding null event handlers is allowed - later leads to NPE). To fix it I want to add null checks (with NPE throws) for event type and event handler or filter to the addEventHandler, removeEventHandler, addEventFilter and removeEventFilter methods of Node, Scene, Window, Task, Service, MenuItem, TableColumn and TreeItem. Passing null event type or event handler / filter to these methods clearly indicates programmer's error and so should be reported early. Failure to do that may result in an exception later in program execution which cause is then hard to guess.
>>
>> I don't know whether this change requires an explicit approval, but previously javadoc for these methods didn't specify possible NPE and so the API behavior will change in this respect.
>>
>> Thanks,
>> Lubo
>>


More information about the openjfx-dev mailing list