title: Null pointer exception in lambda expression
body: <p>I have JavaFx application in which there is a ListView named roomList. I use following line of code to check if something from ListView is selected :</p>
  
  <pre><code>    roomList.getSelectionModel().selectedItemProperty().addListener((observable, oldValue, newValue)   -&gt; showRoomElements(newValue));
  </code></pre>
  
  <p>and if some item is selected then according to which is selected I change some text on some labels. That works fine.
  Problem comes when, using some other menu, I change items in <strong>roomList</strong>.It still works on changing labels but i have Null pointer exception.</p>
  
  <pre><code>    Exception in thread "JavaFX Application Thread" java.lang.NullPointerException
  at homeautomation.view.HomePageController.showRoomElements(HomePageController.java:207)
  at homeautomation.view.HomePageController.lambda$setHomeAutomation$1(HomePageController.java:59)
  at homeautomation.view.HomePageController$$Lambda$276/1011775954.changed(Unknown Source)
  at com.sun.javafx.binding.ExpressionHelper$SingleChange.fireValueChangedEvent(ExpressionHelper.java:182)
  at com.sun.javafx.binding.ExpressionHelper.fireValueChangedEvent(ExpressionHelper.java:81)
  at javafx.beans.property.ReadOnlyObjectWrapper$ReadOnlyPropertyImpl.fireValueChangedEvent(ReadOnlyObjectWrapper.java:176)
  at javafx.beans.property.ReadOnlyObjectWrapper.fireValueChangedEvent(ReadOnlyObjectWrapper.java:142)
  at javafx.beans.property.ObjectPropertyBase.markInvalid(ObjectPropertyBase.java:112)
  at javafx.beans.property.ObjectPropertyBase.set(ObjectPropertyBase.java:145)
  at javafx.scene.control.SelectionModel.setSelectedItem(SelectionModel.java:102)
  at javafx.scene.control.MultipleSelectionModelBase.lambda$new$34(MultipleSelectionModelBase.java:67)
  at javafx.scene.control.MultipleSelectionModelBase$$Lambda$192/1369453379.invalidated(Unknown Source)
  at com.sun.javafx.binding.ExpressionHelper$SingleInvalidation.fireValueChangedEvent(ExpressionHelper.java:137)
  at com.sun.javafx.binding.ExpressionHelper.fireValueChangedEvent(ExpressionHelper.java:81)
  at javafx.beans.property.ReadOnlyIntegerWrapper$ReadOnlyPropertyImpl.fireValueChangedEvent(ReadOnlyIntegerWrapper.java:176)
  at javafx.beans.property.ReadOnlyIntegerWrapper.fireValueChangedEvent(ReadOnlyIntegerWrapper.java:142)
  at javafx.beans.property.IntegerPropertyBase.markInvalid(IntegerPropertyBase.java:113)
  at javafx.beans.property.IntegerPropertyBase.set(IntegerPropertyBase.java:146)
  at javafx.scene.control.SelectionModel.setSelectedIndex(SelectionModel.java:68)
  at javafx.scene.control.ListView$ListViewBitSetSelectionModel.updateItemsObserver(ListView.java:1287)
  at javafx.scene.control.ListView$ListViewBitSetSelectionModel.access$000(ListView.java:1186)
  at javafx.scene.control.ListView$1.invalidated(ListView.java:426)
  at javafx.beans.property.ObjectPropertyBase.markInvalid(ObjectPropertyBase.java:111)
  at javafx.beans.property.ObjectPropertyBase.set(ObjectPropertyBase.java:145)
  at javafx.scene.control.ListView.setItems(ListView.java:394)
  at homeautomation.view.HomePageController.handleSelectFirstFloor(HomePageController.java:141)
  at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
  at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
  at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
  at java.lang.reflect.Method.invoke(Method.java:483)
  at sun.reflect.misc.Trampoline.invoke(MethodUtil.java:71)
  at sun.reflect.GeneratedMethodAccessor1.invoke(Unknown Source)
  at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
  at java.lang.reflect.Method.invoke(Method.java:483)
  at sun.reflect.misc.MethodUtil.invoke(MethodUtil.java:275)
  at javafx.fxml.FXMLLoader$MethodHandler.invoke(FXMLLoader.java:1759)
  at javafx.fxml.FXMLLoader$ControllerMethodEventHandler.handle(FXMLLoader.java:1645)
  at com.sun.javafx.event.CompositeEventHandler.dispatchBubblingEvent(CompositeEventHandler.java:86)
  at com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventHandlerManager.java:238)
  at com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventHandlerManager.java:191)
  at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:58)
  at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
  at com.sun.javafx.event.EventUtil.fireEventImpl(EventUtil.java:74)
  at com.sun.javafx.event.EventUtil.fireEvent(EventUtil.java:49)
  at javafx.event.Event.fireEvent(Event.java:198)
  at javafx.scene.control.MenuItem.fire(MenuItem.java:462)
  at com.sun.javafx.scene.control.skin.ContextMenuContent$MenuItemContainer.doSelect(ContextMenuContent.java:1364)
  at com.sun.javafx.scene.control.skin.ContextMenuContent$MenuItemContainer.lambda$createChildren$324(ContextMenuContent.java:1317)
  at com.sun.javafx.scene.control.skin.ContextMenuContent$MenuItemContainer$$Lambda$295/2103054710.handle(Unknown Source)
  at com.sun.javafx.event.CompositeEventHandler$NormalEventHandlerRecord.handleBubblingEvent(CompositeEventHandler.java:218)
  at com.sun.javafx.event.CompositeEventHandler.dispatchBubblingEvent(CompositeEventHandler.java:80)
  at com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventHandlerManager.java:238)
  at com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventHandlerManager.java:191)
  at com.sun.javafx.event.CompositeEventDispatcher.dispatchBubblingEvent(CompositeEventDispatcher.java:59)
  at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:58)
  at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
  at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)
  at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
  at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)
  at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
  at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)
  at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
  at com.sun.javafx.event.EventUtil.fireEventImpl(EventUtil.java:74)
  at com.sun.javafx.event.EventUtil.fireEvent(EventUtil.java:54)
  at javafx.event.Event.fireEvent(Event.java:198)
  at javafx.scene.Scene$MouseHandler.process(Scene.java:3724)
  at javafx.scene.Scene$MouseHandler.access$1500(Scene.java:3452)
  at javafx.scene.Scene.impl_processMouseEvent(Scene.java:1728)
  at javafx.scene.Scene$ScenePeerListener.mouseEvent(Scene.java:2461)
  at com.sun.javafx.tk.quantum.GlassViewEventHandler$MouseEventNotification.run(GlassViewEventHandler.java:348)
  at com.sun.javafx.tk.quantum.GlassViewEventHandler$MouseEventNotification.run(GlassViewEventHandler.java:273)
  at java.security.AccessController.doPrivileged(Native Method)
  at com.sun.javafx.tk.quantum.GlassViewEventHandler.handleMouseEvent(GlassViewEventHandler.java:382)
  at com.sun.glass.ui.View.handleMouseEvent(View.java:553)
  at com.sun.glass.ui.View.notifyMouse(View.java:925)
  at com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
  at com.sun.glass.ui.win.WinApplication.lambda$null$141(WinApplication.java:102)
  at com.sun.glass.ui.win.WinApplication$$Lambda$37/728890494.run(Unknown Source)
  at java.lang.Thread.run(Thread.java:745)
  </code></pre>