question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

JFXSnackbar fireEvent issue when closing snackbar to hide previous event and show next one

See original GitHub issue

Hi there,

I do the following which causes an NPE in line JFXSnackbar:179 eventsSet.remove(currentEvent):

  1. snackbar.fireEvent(e1); //e1 should appear for 10 seconds for instance
  2. 5 seconds after showing e1 do: 2.1. snackbar.close();// To hide e1 2.2 snackbar.fireEvent(e2); // to show e2

This will produces an NPE right when e1 is going to finish at line 179, i.e., 10 seconds after firing e1.

A workaround for this issue is to check if currentEvent is not null right before removing it from eventsSet like this:

Replace eventsSet.remove(currentEvent); with :

if (currentEvent != null)
                        eventsSet.remove(currentEvent);

Note that there are more issues to resolve when trying to fire more events between the time e1 is issued to the time e1 is finished (10 seconds in this example). However, this workaround is very simple to apply for now.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:11

github_iconTop GitHub Comments

1reaction
TurekBotcommented, May 8, 2019

(If it’s helpful, here’s what Web SnackBars interrupting each other looks like.)

1reaction
TurekBotcommented, May 8, 2019

I think I ran into this same problem today.

My stack trace looks like this:

Exception in thread "JavaFX Application Thread" java.lang.NullPointerException
	at java.util.concurrent.ConcurrentHashMap.replaceNode(ConcurrentHashMap.java:1106)
	at java.util.concurrent.ConcurrentHashMap.remove(ConcurrentHashMap.java:1097)
	at java.util.concurrent.ConcurrentHashMap$KeySetView.remove(ConcurrentHashMap.java:4569)
	at com.jfoenix.controls.JFXSnackbar.lambda$null$5(JFXSnackbar.java:179)
	at com.jfoenix.controls.JFXSnackbar$$Lambda$11.handle(Unknown Source)
	at javafx.animation.Animation.impl_finished(Animation.java:1132)
	at javafx.animation.AnimationAccessorImpl.finished(AnimationAccessorImpl.java:49)
	at com.sun.scenario.animation.shared.SingleLoopClipEnvelope.timePulse(SingleLoopClipEnvelope.java:103)
	at javafx.animation.Animation.impl_timePulse(Animation.java:1102)
	at javafx.animation.Animation$1.lambda$timePulse$25(Animation.java:186)
	at java.security.AccessController.doPrivileged(Native Method)
	at javafx.animation.Animation$1.timePulse(Animation.java:185)
	at com.sun.scenario.animation.AbstractMasterTimer.timePulseImpl(AbstractMasterTimer.java:344)
	at com.sun.scenario.animation.AbstractMasterTimer$MainLoop.run(AbstractMasterTimer.java:267)
	at com.sun.javafx.tk.quantum.QuantumToolkit.pulse(QuantumToolkit.java:514)
	at com.sun.javafx.tk.quantum.QuantumToolkit.pulse(QuantumToolkit.java:498)
	at com.sun.javafx.tk.quantum.QuantumToolkit.pulseFromQueue(QuantumToolkit.java:491)
	at com.sun.javafx.tk.quantum.QuantumToolkit.lambda$runToolkit$408(QuantumToolkit.java:319)
	at com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:95)
	at com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
	at com.sun.glass.ui.win.WinApplication.lambda$null$152(WinApplication.java:177)
	at java.lang.Thread.run(Thread.java:748)

I’m trying this

// If there is already an snackbar event showing, close it.
if (snackbar.getCurrentEvent() != null) {
    snackbar.close();
}

    snackbar.enqueue(event);

but trying to close the snackbar seems to be causing the above exception.

@aminabs, you’re referring to this line 179 (it’s now line 249), right?

@jfoenixadmin, what is the recommended way for SnackBars to interrupt each other?

Read more comments on GitHub >

github_iconTop Results From Across the Web

JFXSnackbar fireEvent issue when closing snackbar to hide ...
fireEvent (e1); //e1 should appear for 10 seconds for instance 5 ... when closing snackbar to hide previous event and show next one...
Read more >
JFXSnackbar fireEvent issue when closing snackbar to hide ...
JFXSnackbar fireEvent issue when closing snackbar to hide previous event and show next one.
Read more >
How to use .show() for JFXSnackbar in java fx - Stack Overflow
In the newest version of JFoenix (jfoenix-8.0.8), the show() method is purposefully encapsulated or hidden in the JFXSnackbar class.
Read more >
com.jfoenix.controls.JFXSnackbar.fireEvent java code examples
fireEvent (new SnackbarEvent(new JFXSnackbarLayout("Toast Message " + count)));... ... Persistent " + count, "CLOSE", action -> snackbar.close()), Duration.
Read more >
Viewing online file analysis results for 'HMCL-3.2.130.jar'
... Evasive: Possibly tries to implement anti-virtualization techniques; Network Behavior: Contacts 1 domain and 1 host. View all details ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found