java.lang.NullPointerException

JDK Bug System | Webbug Group | 4 months ago
  1. 0

    FULL PRODUCT VERSION : Java(TM) SE Runtime Environment (build 1.8.0_66-b17) Java HotSpot(TM) 64-Bit Server VM (build 25.66-b17, mixed mode) ADDITIONAL OS VERSION INFORMATION : Microsoft Windows [Version 6.1.7601] A DESCRIPTION OF THE PROBLEM : In class com.sun.javafx.binding.SelectBinding, there are several convenience methods for computing values for data types (String, Boolean, Double, etc.). In each of these methods, the property itself is checked for null, but after this, the value of the property is directly accessed by, e.g. 'observable.getValue().toString();' in nested class SelectBinding.AsString. This error only occurs, as long as the binding in invalid. As soon as it has ben validated, the result of method get() is returned, which then simply returns 'null'. This may raise a wrong NullPointerException if the value of the property is null, which is a common and legal use case. A better way would be (in my opinion) to check for null-value right after checking for null on property and return the default value, if the value is null. In fact, the exception is caught/handled, so the application keeps on running and there are no side-effects, but we get a lot of unnecessary exceptions, which pollute or logs! STEPS TO FOLLOW TO REPRODUCE THE PROBLEM : See example code below. EXPECTED VERSUS ACTUAL BEHAVIOR : EXPECTED - The default value should be returned. ACTUAL - see ErrorMessages ERROR MESSAGES/STACK TRACES THAT OCCUR : The posted example code results in this exceptions: WARNING: Exception while evaluating select-binding java.lang.NullPointerException at com.sun.javafx.binding.SelectBinding$AsString.computeValue(SelectBinding.java:399) at javafx.beans.binding.StringBinding.get(StringBinding.java:152) at spielwiese.SelectBindingError.main(SelectBindingError.java:15) null Jul 25, 2016 11:35:51 AM com.sun.javafx.binding.SelectBinding$AsString computeValue WARNING: Exception while evaluating select-binding java.lang.NullPointerException at com.sun.javafx.binding.SelectBinding$AsString.computeValue(SelectBinding.java:399) at javafx.beans.binding.StringBinding.get(StringBinding.java:152) at javafx.beans.binding.StringBinding.get(StringBinding.java:61) at javafx.beans.binding.StringExpression.getValue(StringExpression.java:51) at spielwiese.SelectBindingError.main(SelectBindingError.java:16) Jul 25, 2016 11:35:51 AM com.sun.javafx.binding.SelectBinding$AsString computeValue WARNING: Exception while evaluating select-binding java.lang.NullPointerException at com.sun.javafx.binding.SelectBinding$AsString.computeValue(SelectBinding.java:399) at javafx.beans.binding.StringBinding.get(StringBinding.java:152) at javafx.beans.binding.StringBinding.get(StringBinding.java:61) at javafx.beans.binding.StringExpression.getValueSafe(StringExpression.java:62) at spielwiese.SelectBindingError.main(SelectBindingError.java:17) REPRODUCIBILITY : This bug can be reproduced always. ---------- BEGIN SOURCE ---------- import javafx.beans.binding.Bindings; import javafx.beans.property.ObjectProperty; import javafx.beans.property.SimpleObjectProperty; import javafx.beans.property.SimpleStringProperty; import javafx.beans.property.StringProperty; public final class SelectBindingError { public static void main(final String[] args) { final ObjectProperty<SelectBindingError> root = new SimpleObjectProperty<SelectBindingError>(new SelectBindingError()); System.out.println(Bindings.selectString(root, "nullValueProperty").get()); System.out.println(Bindings.selectString(root, "nullValueProperty").getValue()); System.out.println(Bindings.selectString(root, "nullValueProperty").getValueSafe()); } private final StringProperty nullValue = new SimpleStringProperty(); public String getNullValueProperty() { return this.nullValueProperty().get(); } private StringProperty nullValueProperty() { return this.nullValue; } } ---------- END SOURCE ---------- CUSTOMER SUBMITTED WORKAROUND : If using a logger, it could be configured so that this special kind of exception is no longer visible/logged.

    JDK Bug System | 4 months ago | Webbug Group
    java.lang.NullPointerException
  2. 0

    Why does this select binding throw a NullPointerException?

    Oracle Community | 3 years ago | ryan29
    java.lang.NullPointerException
  3. 0

    Android: Saving Map State in Google map

    Stack Overflow | 11 months ago | Junie Negentien
    java.lang.RuntimeException: Unable to resume activity {com.ourThesis.junieNegentien2015/com.ourThesis.junieNegentien2015.MainActivity}: java.lang.NullPointerException
  4. Speed up your debug routine!

    Automated exception search integrated into your IDE

    Not finding the right solution?
    Take a tour to get the most out of Samebug.

    Tired of useless tips?

    Automated exception search integrated into your IDE

    Root Cause Analysis

    1. java.lang.NullPointerException

      No message provided

      at com.sun.javafx.binding.SelectBinding$AsString.computeValue()
    2. com.sun.javafx
      SelectBinding$AsString.computeValue
      1. com.sun.javafx.binding.SelectBinding$AsString.computeValue(SelectBinding.java:399)
      1 frame
    3. javafx.beans.binding
      StringExpression.getValue
      1. javafx.beans.binding.StringBinding.get(StringBinding.java:152)
      2. javafx.beans.binding.StringBinding.get(StringBinding.java:61)
      3. javafx.beans.binding.StringExpression.getValue(StringExpression.java:51)
      3 frames
    4. spielwiese
      SelectBindingError.main
      1. spielwiese.SelectBindingError.main(SelectBindingError.java:16)
      1 frame