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

NPE while filtering table #1417

Closed
amitjoy opened this issue Feb 20, 2022 · 6 comments · Fixed by #1429
Closed

NPE while filtering table #1417

amitjoy opened this issue Feb 20, 2022 · 6 comments · Fixed by #1429
Labels
bug Something isn't working

Comments

@amitjoy
Copy link
Contributor

amitjoy commented Feb 20, 2022

java.lang.NullPointerException: Cannot invoke "java.lang.Boolean.booleanValue()" because the return value of "org.controlsfx.control.table.TableRowExpanderColumn.getCellData(int)" is null
	at impl.org.controlsfx.skin.ExpandableTableRowSkin.isExpanded(ExpandableTableRowSkin.java:86)
	at impl.org.controlsfx.skin.ExpandableTableRowSkin.layoutChildren(ExpandableTableRowSkin.java:107)
	at javafx.controls/javafx.scene.control.Control.layoutChildren(Control.java:601)
	at javafx.controls/javafx.scene.control.Cell.layoutChildren(Cell.java:636)
	at javafx.graphics/javafx.scene.Parent.layout(Parent.java:1207)
	at javafx.graphics/javafx.scene.Parent.layout(Parent.java:1214)
	at javafx.graphics/javafx.scene.Parent.layout(Parent.java:1214)
	at javafx.graphics/javafx.scene.Parent.layout(Parent.java:1214)
	at javafx.graphics/javafx.scene.Parent.layout(Parent.java:1214)
	at javafx.graphics/javafx.scene.Parent.layout(Parent.java:1214)
	at javafx.graphics/javafx.scene.Parent.layout(Parent.java:1214)
	at javafx.graphics/javafx.scene.Parent.layout(Parent.java:1214)
	at javafx.graphics/javafx.scene.Parent.layout(Parent.java:1214)
	at javafx.graphics/javafx.scene.Parent.layout(Parent.java:1214)
	at javafx.graphics/javafx.scene.Parent.layout(Parent.java:1214)
	at javafx.graphics/javafx.scene.Parent.layout(Parent.java:1214)
	at javafx.graphics/javafx.scene.Parent.layout(Parent.java:1214)
	at javafx.graphics/javafx.scene.Parent.layout(Parent.java:1214)
	at javafx.graphics/javafx.scene.Parent.layout(Parent.java:1214)
	at javafx.graphics/javafx.scene.Parent.layout(Parent.java:1214)
	at javafx.graphics/javafx.scene.Parent.layout(Parent.java:1214)
	at javafx.graphics/javafx.scene.Parent.layout(Parent.java:1214)
	at javafx.graphics/javafx.scene.Scene.doLayoutPass(Scene.java:579)
	at javafx.graphics/javafx.scene.Scene$ScenePulseListener.pulse(Scene.java:2515)
	at javafx.graphics/com.sun.javafx.tk.Toolkit.lambda$runPulse$2(Toolkit.java:421)
	at java.base/java.security.AccessController.doPrivileged(AccessController.java:399)
	at javafx.graphics/com.sun.javafx.tk.Toolkit.runPulse(Toolkit.java:420)
	at javafx.graphics/com.sun.javafx.tk.Toolkit.firePulse(Toolkit.java:450)
	at javafx.graphics/com.sun.javafx.tk.quantum.QuantumToolkit.pulse(QuantumToolkit.java:575)
	at javafx.graphics/com.sun.javafx.tk.quantum.QuantumToolkit.pulse(QuantumToolkit.java:555)
	at javafx.graphics/com.sun.javafx.tk.quantum.QuantumToolkit.pulseFromQueue(QuantumToolkit.java:548)
	at javafx.graphics/com.sun.javafx.tk.quantum.QuantumToolkit.lambda$runToolkit$11(QuantumToolkit.java:353)
	at javafx.graphics/com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:96
@abhinayagarwal
Copy link
Member

Hi Amit,

Can you provide a SSCCE to reproduce the issue?

@abhinayagarwal abhinayagarwal added the bug Something isn't working label Feb 20, 2022
@amitjoy
Copy link
Contributor Author

amitjoy commented Feb 20, 2022

This is hard to reproduce as it happens unpredictably. I will try to check how I can provide a quick example.

@amitjoy
Copy link
Contributor Author

amitjoy commented Apr 9, 2022

@abhinayagarwal As I mentioned earlier that it is really hard to reproduce as it happens only when filtering while having one of the rows expanded. But still I didn't manage to see a uniform pattern to reproduce it consistently but it still occurs many times. You could try to look into the stacktrace if something could lead to such a behaviour.

Thanks in advance.

@amitjoy
Copy link
Contributor Author

amitjoy commented Apr 9, 2022

Tested on Java Runtime - 17.0.2 with org.controlsfx:controlsfx:11.1.1

@amitjoy
Copy link
Contributor Author

amitjoy commented Apr 11, 2022

@abhinayagarwal I just had a quick look into the stacktrace. According to the implementation of javafx.scene.control.TableColumnBase.getCellData(int), it can return null. And if it returns null, the consumer of it - impl.org.controlsfx.skin.ExpandableTableRowSkin.isExpanded() results in NPE.

I believe it should be fault-tolerant in any case as according to the API, the javafx.scene.control.TableColumnBase.getCellData(int) could return null anytime.

I think we can introduce something like this:

Boolean.TRUE.equals(expander.getCellData(getSkinnable().getIndex()))

This will make it failsafe no matter what javafx.scene.control.TableColumnBase.getCellData(int) returns. Could you also kindly have a look?

@amitjoy
Copy link
Contributor Author

amitjoy commented Apr 11, 2022

You can also use java.util.Objects.requireNonNullElse(T obj, T defaultObj)

The method would then look as follows:

private Boolean isExpanded() {
     return getSkinnable().getItem() != null && Objects.requireNonNullElse(expander.getCellData(getSkinnable().getIndex()), false);
}

amitjoy added a commit to amitjoy/controlsfx that referenced this issue Apr 11, 2022
Fixes controlsfx#1417

Signed-off-by: Amit Kumar Mondal <admin@amitinside.com>
abhinayagarwal pushed a commit that referenced this issue Apr 23, 2022
Fixes #1417

Signed-off-by: Amit Kumar Mondal <admin@amitinside.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants