java.lang.NullPointerException

There are no available Samebug tips for this exception. Do you have an idea how to solve this issue? A short tip would help users who saw this issue last week.

  • FULL PRODUCT VERSION : java version "1.8.0_102" Java(TM) SE Runtime Environment (build 1.8.0_102-b14) Java HotSpot(TM) 64-Bit Server VM (build 25.102-b14, mixed mode) ADDITIONAL OS VERSION INFORMATION : Microsoft Windows [Version 6.1.7601] A DESCRIPTION OF THE PROBLEM : The following program declares a string property and registers three change listeners. The first listener changes the value from within its listener implementation and thus initiating a recursive notification. If fireValueChangedEvent is invoked, then a lock flag is set which prevents that modifications of the list will not be in conflict with iterating over the collection. After this recursive notification the lock flag is cleared. The second listener removes itself on the second notification, and since the lock flag was cleared, the internal array of change listeners is changed, i.e. the third listener becomes the second and the last reference is set to null. But on this null reference (i.e. the last listener) the changed method is then invoked. STEPS TO FOLLOW TO REPRODUCE THE PROBLEM : Execute the program added to this bug report. EXPECTED VERSUS ACTUAL BEHAVIOR : EXPECTED - The program should not throw an exception and in the console you should see the following output: listener1 listener1 Listener 2 listener3 123$/123$ Listener 2 remove myself from StringProperty [value: 123$] listener3 123$/123$ ACTUAL - listener1 listener1 Listener 2 listener3 123$/123$ Listener 2 remove myself from StringProperty [value: 123$] Exception in thread "main" java.lang.NullPointerException at com.sun.javafx.binding.ExpressionHelper$Generic.fireValueChangedEvent(ExpressionHelper.java:361) at com.sun.javafx.binding.ExpressionHelper.fireValueChangedEvent(ExpressionHelper.java:81) at javafx.beans.property.StringPropertyBase.fireValueChangedEvent(StringPropertyBase.java:103) at javafx.beans.property.StringPropertyBase.markInvalid(StringPropertyBase.java:110) at javafx.beans.property.StringPropertyBase.set(StringPropertyBase.java:144) at javafx.beans.property.StringPropertyBase.set(StringPropertyBase.java:49) at javafx.beans.property.StringProperty.setValue(StringProperty.java:65) at patterns.observer.cycle.fx.ReentrantCalls.main(ReentrantCalls.java:39) ERROR MESSAGES/STACK TRACES THAT OCCUR : lException in thread "main" java.lang.NullPointerException at com.sun.javafx.binding.ExpressionHelper$Generic.fireValueChangedEvent(ExpressionHelper.java:361) at com.sun.javafx.binding.ExpressionHelper.fireValueChangedEvent(ExpressionHelper.java:81) at javafx.beans.property.StringPropertyBase.fireValueChangedEvent(StringPropertyBase.java:103) at javafx.beans.property.StringPropertyBase.markInvalid(StringPropertyBase.java:110) at javafx.beans.property.StringPropertyBase.set(StringPropertyBase.java:144) at javafx.beans.property.StringPropertyBase.set(StringPropertyBase.java:49) at javafx.beans.property.StringProperty.setValue(StringProperty.java:65) at patterns.observer.cycle.fx.ReentrantCalls.main(ReentrantCalls.java:39) REPRODUCIBILITY : This bug can be reproduced always. ---------- BEGIN SOURCE ---------- public class ReentrantCalls { public static void main(String[] args) { StringProperty prop = new SimpleStringProperty("prop"); prop.addListener((observable, oldValue, newValue) -> { System.out.println("listener1"); if(newValue.length() % 2 ==1) prop.set(newValue + "$"); }); class OnceListener implements ChangeListener<String> { private int counter; public OnceListener(int value) { counter = value; } @Override public void changed(ObservableValue<? extends String> observable, String oldValue, String newValue) { System.out.println("Listener 2"); if (--counter == 0) { System.out.println("remove myself from " + observable); observable.removeListener(this); } } } prop.addListener(new OnceListener(2)); prop.addListener((observable, oldValue, newValue) -> { System.out.println("listener3 "+newValue + "/" + prop.getValue()); }); prop.setValue("123"); } } ---------- END SOURCE ---------- CUSTOMER SUBMITTED WORKAROUND : The fix would be to replace the boolean flag by an integer value and increment/decrement that value and only allow to change the list of listeners if this value is 0.
    via by Webbug Group,
  • Java: SetText inside a thread
    via Stack Overflow by PicoYou
    ,
  • HTMLEditor markup error (FXML)
    via by 855977,
  • db:: 4.54::HTMLeditor control not working ma
    via by Unknown author,
    • java.lang.NullPointerException at com.sun.javafx.binding.ExpressionHelper$Generic.fireValueChangedEvent(ExpressionHelper.java:361) at com.sun.javafx.binding.ExpressionHelper.fireValueChangedEvent(ExpressionHelper.java:81) at javafx.beans.property.StringPropertyBase.fireValueChangedEvent(StringPropertyBase.java:103) at javafx.beans.property.StringPropertyBase.markInvalid(StringPropertyBase.java:110) at javafx.beans.property.StringPropertyBase.set(StringPropertyBase.java:144) at javafx.beans.property.StringPropertyBase.set(StringPropertyBase.java:49) at javafx.beans.property.StringProperty.setValue(StringProperty.java:65) at patterns.observer.cycle.fx.ReentrantCalls.main(ReentrantCalls.java:39)
    No Bugmate found.