Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix NPE from BurningManView column comparators #6666

Merged

Conversation

stejbac
Copy link
Contributor

@stejbac stejbac commented Apr 22, 2023

Prevent an NPE when a user attempts to sort a column (excluding Revenue) containing blank entries in the Revenue table of a selected contributor in the DAO / Proof of Burn / BurningMen view. Such blank entries appear when viewing individual balance items instead of by month, such as the received BTC of a burned BSQ entry, or the burned BSQ of received BTC entry.

Prior to this change, errors such as the following occur:

Apr-21 17:11:31.210 [JavaFX Application Thread] ERROR bisq.common.setup.CommonSetup: Uncaught Exception from thread JavaFX Application Thread
Apr-21 17:11:31.210 [JavaFX Application Thread] ERROR bisq.common.setup.CommonSetup: throwableMessage= null
Apr-21 17:11:31.211 [JavaFX Application Thread] ERROR bisq.common.setup.CommonSetup: throwableClass= class java.lang.NullPointerException
Apr-21 17:11:31.218 [JavaFX Application Thread] ERROR bisq.common.setup.CommonSetup: Stack trace:
java.lang.NullPointerException
at java.base/java.util.Comparator.lambda$comparing$77a9974f$1(Comparator.java:469)
at com.sun.javafx.scene.control.TableColumnComparatorBase$TableColumnComparator.doCompare(TableColumnComparatorBase.java:121)
at com.sun.javafx.scene.control.TableColumnComparatorBase.compare(TableColumnComparatorBase.java:61)
at javafx.collections.transformation.SortedList$ElementComparator.compare(SortedList.java:299)
at javafx.collections.transformation.SortedList$ElementComparator.compare(SortedList.java:288)
at com.sun.javafx.collections.SortHelper.mergeSort(SortHelper.java:260)
at com.sun.javafx.collections.SortHelper.mergeSort(SortHelper.java:272)
at com.sun.javafx.collections.SortHelper.mergeSort(SortHelper.java:272)
at com.sun.javafx.collections.SortHelper.mergeSort(SortHelper.java:272)
at com.sun.javafx.collections.SortHelper.mergeSort(SortHelper.java:272)
at com.sun.javafx.collections.SortHelper.mergeSort(SortHelper.java:272)
at com.sun.javafx.collections.SortHelper.mergeSort(SortHelper.java:272)
at com.sun.javafx.collections.SortHelper.mergeSort(SortHelper.java:272)
at com.sun.javafx.collections.SortHelper.sort(SortHelper.java:96)
at javafx.collections.transformation.SortedList.setAllToMapping(SortedList.java:357)
at javafx.collections.transformation.SortedList.addRemove(SortedList.java:402)
at javafx.collections.transformation.SortedList.sourceChanged(SortedList.java:108)
at javafx.collections.transformation.TransformationList.lambda$getListener$0(TransformationList.java:106)
at javafx.collections.WeakListChangeListener.onChanged(WeakListChangeListener.java:88)
at com.sun.javafx.collections.ListListenerHelper$SingleChange.fireValueChangedEvent(ListListenerHelper.java:164)
at com.sun.javafx.collections.ListListenerHelper.fireValueChangedEvent(ListListenerHelper.java:73)
at javafx.collections.ObservableListBase.fireChange(ObservableListBase.java:239)
at javafx.collections.transformation.FilteredList.refilter(FilteredList.java:338)
at javafx.collections.transformation.FilteredList$1.invalidated(FilteredList.java:102)
at javafx.beans.property.ObjectPropertyBase.markInvalid(ObjectPropertyBase.java:112)
at javafx.beans.property.ObjectPropertyBase.set(ObjectPropertyBase.java:147)
at javafx.collections.transformation.FilteredList.setPredicate(FilteredList.java:125)
at bisq.desktop.main.dao.burnbsq.burningman.BurningManView.onTypeChanged(BurningManView.java:712)
at bisq.desktop.main.dao.burnbsq.burningman.BurningManView.lambda$new$5(BurningManView.java:260)
at com.sun.javafx.binding.ExpressionHelper$Generic.fireValueChangedEvent(ExpressionHelper.java:360)
at com.sun.javafx.binding.ExpressionHelper.fireValueChangedEvent(ExpressionHelper.java:80)
at javafx.beans.property.ReadOnlyObjectPropertyBase.fireValueChangedEvent(ReadOnlyObjectPropertyBase.java:80)
at javafx.beans.property.ReadOnlyObjectWrapper.fireValueChangedEvent(ReadOnlyObjectWrapper.java:102)
at javafx.beans.property.ObjectPropertyBase.markInvalid(ObjectPropertyBase.java:113)
at javafx.beans.property.ObjectPropertyBase.set(ObjectPropertyBase.java:147)
at javafx.scene.control.ToggleGroup$3.set(ToggleGroup.java:146)
at javafx.scene.control.ToggleGroup$3.set(ToggleGroup.java:128)
at javafx.scene.control.ToggleGroup.selectToggle(ToggleGroup.java:158)
at javafx.scene.control.ToggleButton$1.invalidated(ToggleButton.java:169)
at javafx.beans.property.BooleanPropertyBase.markInvalid(BooleanPropertyBase.java:110)
at javafx.beans.property.BooleanPropertyBase.set(BooleanPropertyBase.java:145)
at javafx.scene.control.ToggleButton.setSelected(ToggleButton.java:150)
at javafx.scene.control.ToggleButton.fire(ToggleButton.java:256)
at javafx.scene.control.RadioButton.fire(RadioButton.java:112)
at com.sun.javafx.scene.control.behavior.ButtonBehavior.mouseReleased(ButtonBehavior.java:208)
at com.sun.javafx.scene.control.inputmap.InputMap.handle(InputMap.java:274)
at com.sun.javafx.event.CompositeEventHandler$NormalEventHandlerRecord.handleBubblingEvent(CompositeEventHandler.java:247)
at com.sun.javafx.event.CompositeEventHandler.dispatchBubblingEvent(CompositeEventHandler.java:80)
at com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventHandlerManager.java:234)
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.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.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:3856)
at javafx.scene.Scene.processMouseEvent(Scene.java:1851)
at javafx.scene.Scene$ScenePeerListener.mouseEvent(Scene.java:2584)
at com.sun.javafx.tk.quantum.GlassViewEventHandler$MouseEventNotification.run(GlassViewEventHandler.java:409)
at com.sun.javafx.tk.quantum.GlassViewEventHandler$MouseEventNotification.run(GlassViewEventHandler.java:299)
at java.base/java.security.AccessController.doPrivileged(Native Method)
at com.sun.javafx.tk.quantum.GlassViewEventHandler.lambda$handleMouseEvent$2(GlassViewEventHandler.java:447)
at com.sun.javafx.tk.quantum.QuantumToolkit.runWithoutRenderLock(QuantumToolkit.java:412)
at com.sun.javafx.tk.quantum.GlassViewEventHandler.handleMouseEvent(GlassViewEventHandler.java:446)
at com.sun.glass.ui.View.handleMouseEvent(View.java:556)
at com.sun.glass.ui.View.notifyMouse(View.java:942)
at com.sun.glass.ui.gtk.GtkApplication._runLoop(Native Method)
at com.sun.glass.ui.gtk.GtkApplication.lambda$runLoop$11(GtkApplication.java:277)
at java.base/java.lang.Thread.run(Thread.java:834)

(Line numbers in BurningManView may be slightly off.)

Make sure that none of the key extractor functions passed to
'Comparator.comparing(fn)' can return null, as this results in an NPE
when the corresponding column is sorted in the UI, but has blank entries
(such as the BTC received for a BSQ burn in the balance entries table).

(Make blanks appear smallest in magnitude using 'Comparator.nullsFirst'
or by defaulting to 0 instead of null, since the entries are initially
sorted biggest to smallest, pushing them to the bottom of the table.)

Also change the default sort type of the burned BSQ column, which should
be ASCENDING since the entries are negative.
Replace uses of 'Comparator.comparing' with 'comparing[Double|Int|Long]'
in BurningManView, as appropriate, since it is slightly more efficient.
1) Replace statement lambda with expression lambda;
2) Use '.iterator().next()' instead of 'new ArrayList<>(_).get(0)'.
Copy link
Contributor

@alvasw alvasw left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

utACK

@ripcurlx ripcurlx added this to the v1.9.11 milestone Apr 24, 2023
Copy link
Contributor

@ripcurlx ripcurlx left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

utACK - based on #6666 (review)

@ripcurlx ripcurlx merged commit c8c256f into bisq-network:master Apr 24, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants