(Swallowed) Nullpointer access in TextFormatter.updateValue

Jens Auer Jens.Auer at h-d-gmbh.de
Wed Mar 22 15:36:42 UTC 2017


Hi,

I am using a TextField with a TextFormatter constructed with a predicate:
private TextFormatter.Change validateText(TextFormatter.Change c) { ... }
...
this.textInput.setTextFormatter(new TextFormatter<>(this::validateText));

While debugging some other problem I realized that the Debugger stops with a Nullpointer access in TextFormatter.updateValue:
    void updateValue(String text) {
        if (!value.isBound()) {
            try {
                V v = valueConverter.fromString(text);
                setValue(v);
            } catch (Exception e) {
                updateText(); // Set the text with the latest value
            }
        }
    }

The member valueConverter may not be initialized in the constructor and thus can be null. Even though the exception is caught and swallowed, I would consider this an issue.

Cheers,
Jens

Jens Auer
(Softwareentwicklung)
___________________________________________________________
Unternehmensberatung H & D GmbH
Niederlassung Weißenthurm
Werftstr. 5 - 56575 Weißenthurm
Tel.:            02637/94238 -110
Fax:            02637/94238 -149
jens.auer at h-d-gmbh.de<mailto:jens.auer at h-d-gmbh.de>
http://www.h-d-gmbh.de<http://www.h-d-gmbh.de/>
http://www.h-d-gmbh.de/impressum.html
___________________________________________________________



More information about the openjfx-dev mailing list