Strange JavaFX Application Thread exception - javafx

We are making a card game named Dominion with client-server, using Java Serialization. We are working also with observer/observable and threads (threads for reading messages on server and client side).
We are highlighting the card with CSS if a player is able to play or buy a card. The highlight is added by the update methode of the interface Observer where a gamecard is being observed. If a specific condition is true, we will add the highlight to the gamecard (class GameCard is implements Observer).
In general it works fine, but there is a card (named Militia) which forces the opponents to discard cards from their hand until they got only 3 cards left. We can play this for several times without exceptions, but suddenly there are several exceptions (after about 7-10 times played the Militia cards). We have no idea why.
What could be the reason of this exceptions? I think it doesn't help if I post the code, I will post the exceptions:
Exception in thread "JavaFX Application Thread" java.lang.NullPointerException
at com.sun.javafx.text.PrismTextLayout.addTextRun(PrismTextLayout.java:755)
at com.sun.javafx.text.GlyphLayout.addTextRun(GlyphLayout.java:140)
at com.sun.javafx.text.GlyphLayout.breakRuns(GlyphLayout.java:210)
at com.sun.javafx.text.PrismTextLayout.buildRuns(PrismTextLayout.java:770)
at com.sun.javafx.text.PrismTextLayout.layout(PrismTextLayout.java:1021)
at com.sun.javafx.text.PrismTextLayout.ensureLayout(PrismTextLayout.java:223)
at com.sun.javafx.text.PrismTextLayout.getBounds(PrismTextLayout.java:246)
at javafx.scene.text.Text.getLogicalBounds(Text.java:358)
at javafx.scene.text.Text.impl_computeGeomBounds(Text.java:1168)
at javafx.scene.Node.updateGeomBounds(Node.java:3579)
at javafx.scene.Node.getGeomBounds(Node.java:3532)
at javafx.scene.Node.getLocalBounds(Node.java:3480)
at javafx.scene.Node.updateTxBounds(Node.java:3643)
at javafx.scene.Node.getTransformedBounds(Node.java:3426)
at javafx.scene.Parent.getChildTransformedBounds(Parent.java:1732)
at javafx.scene.Parent.recomputeBounds(Parent.java:1524)
at javafx.scene.Parent.impl_computeGeomBounds(Parent.java:1388)
at javafx.scene.Node.updateGeomBounds(Node.java:3579)
at javafx.scene.Node.getGeomBounds(Node.java:3532)
at javafx.scene.Node.getLocalBounds(Node.java:3480)
at javafx.scene.Node.updateTxBounds(Node.java:3643)
at javafx.scene.Node.getTransformedBounds(Node.java:3426)
at javafx.scene.Parent.getChildTransformedBounds(Parent.java:1732)
at javafx.scene.Parent.updateCachedBounds(Parent.java:1596)
at javafx.scene.Parent.recomputeBounds(Parent.java:1535)
at javafx.scene.Parent.impl_computeGeomBounds(Parent.java:1388)
at javafx.scene.layout.Region.impl_computeGeomBounds(Region.java:3078)
at javafx.scene.Node.updateGeomBounds(Node.java:3579)
at javafx.scene.Node.getGeomBounds(Node.java:3532)
at javafx.scene.Node.getLocalBounds(Node.java:3480)
at javafx.scene.Node.updateTxBounds(Node.java:3643)
at javafx.scene.Node.getTransformedBounds(Node.java:3426)
at javafx.scene.Parent.getChildTransformedBounds(Parent.java:1732)
at javafx.scene.Parent.recomputeBounds(Parent.java:1524)
at javafx.scene.Parent.impl_computeGeomBounds(Parent.java:1388)
at javafx.scene.layout.Region.impl_computeGeomBounds(Region.java:3078)
at javafx.scene.Node.updateGeomBounds(Node.java:3579)
at javafx.scene.Node.getGeomBounds(Node.java:3532)
at javafx.scene.Node.getLocalBounds(Node.java:3480)
at javafx.scene.Node.updateTxBounds(Node.java:3643)
at javafx.scene.Node.getTransformedBounds(Node.java:3426)
at javafx.scene.Parent.getChildTransformedBounds(Parent.java:1732)
at javafx.scene.Parent.recomputeBounds(Parent.java:1524)
at javafx.scene.Parent.impl_computeGeomBounds(Parent.java:1388)
at javafx.scene.layout.Region.impl_computeGeomBounds(Region.java:3078)
at javafx.scene.Node.updateGeomBounds(Node.java:3579)
at javafx.scene.Node.getGeomBounds(Node.java:3532)
at javafx.scene.Node.computeLocalBounds(Node.java:3595)
at javafx.scene.Node.updateLocalBounds(Node.java:3625)
at javafx.scene.Node.getLocalBounds(Node.java:3486)
at javafx.scene.Node.updateTxBounds(Node.java:3643)
at javafx.scene.Node.getTransformedBounds(Node.java:3426)
at javafx.scene.Parent.getChildTransformedBounds(Parent.java:1732)
at javafx.scene.Parent.updateCachedBounds(Parent.java:1596)
at javafx.scene.Parent.recomputeBounds(Parent.java:1535)
at javafx.scene.Parent.impl_computeGeomBounds(Parent.java:1388)
at javafx.scene.layout.Region.impl_computeGeomBounds(Region.java:3078)
at javafx.scene.Node.updateGeomBounds(Node.java:3579)
at javafx.scene.Node.getGeomBounds(Node.java:3532)
at javafx.scene.Node.getLocalBounds(Node.java:3480)
at javafx.scene.Node.updateTxBounds(Node.java:3643)
at javafx.scene.Node.getTransformedBounds(Node.java:3426)
at javafx.scene.Parent.getChildTransformedBounds(Parent.java:1732)
at javafx.scene.Parent.recomputeBounds(Parent.java:1524)
at javafx.scene.Parent.impl_computeGeomBounds(Parent.java:1388)
at javafx.scene.layout.Region.impl_computeGeomBounds(Region.java:3078)
at javafx.scene.Node.updateGeomBounds(Node.java:3579)
at javafx.scene.Node.getGeomBounds(Node.java:3532)
at javafx.scene.Node.getLocalBounds(Node.java:3480)
at javafx.scene.Node.updateTxBounds(Node.java:3643)
at javafx.scene.Node.getTransformedBounds(Node.java:3426)
at javafx.scene.Parent.getChildTransformedBounds(Parent.java:1732)
at javafx.scene.Parent.recomputeBounds(Parent.java:1524)
at javafx.scene.Parent.impl_computeGeomBounds(Parent.java:1388)
at javafx.scene.layout.Region.impl_computeGeomBounds(Region.java:3078)
at javafx.scene.Node.updateGeomBounds(Node.java:3579)
at javafx.scene.Node.getGeomBounds(Node.java:3532)
at javafx.scene.Node.getLocalBounds(Node.java:3480)
at javafx.scene.Node.updateTxBounds(Node.java:3643)
at javafx.scene.Node.getTransformedBounds(Node.java:3426)
at javafx.scene.Parent.getChildTransformedBounds(Parent.java:1732)
at javafx.scene.Parent.updateCachedBounds(Parent.java:1596)
at javafx.scene.Parent.recomputeBounds(Parent.java:1535)
at javafx.scene.Parent.impl_computeGeomBounds(Parent.java:1388)
at javafx.scene.layout.Region.impl_computeGeomBounds(Region.java:3078)
at javafx.scene.Node.updateGeomBounds(Node.java:3579)
at javafx.scene.Node.getGeomBounds(Node.java:3532)
at javafx.scene.Node.getLocalBounds(Node.java:3480)
at javafx.scene.Node.updateTxBounds(Node.java:3643)
at javafx.scene.Node.getTransformedBounds(Node.java:3426)
at javafx.scene.Parent.getChildTransformedBounds(Parent.java:1732)
at javafx.scene.Parent.recomputeBounds(Parent.java:1524)
at javafx.scene.Parent.impl_computeGeomBounds(Parent.java:1388)
at javafx.scene.layout.Region.impl_computeGeomBounds(Region.java:3078)
at javafx.scene.Node.updateGeomBounds(Node.java:3579)
at javafx.scene.Node.getGeomBounds(Node.java:3532)
at javafx.scene.Node.getLocalBounds(Node.java:3480)
at javafx.scene.Node.updateTxBounds(Node.java:3643)
at javafx.scene.Node.getTransformedBounds(Node.java:3426)
at javafx.scene.Parent.getChildTransformedBounds(Parent.java:1732)
at javafx.scene.Parent.updateCachedBounds(Parent.java:1596)
at javafx.scene.Parent.recomputeBounds(Parent.java:1535)
at javafx.scene.Parent.impl_computeGeomBounds(Parent.java:1388)
at javafx.scene.layout.Region.impl_computeGeomBounds(Region.java:3078)
at javafx.scene.Node.updateGeomBounds(Node.java:3579)
at javafx.scene.Node.getGeomBounds(Node.java:3532)
at javafx.scene.Node.getLocalBounds(Node.java:3480)
at javafx.scene.Node.impl_intersectsBounds(Node.java:5015)
at javafx.scene.layout.Region.impl_pickNodeLocal(Region.java:2931)
at javafx.scene.Node.impl_pickNode(Node.java:4914)
at javafx.scene.Scene$MouseHandler.pickNode(Scene.java:3899)
at javafx.scene.Scene$MouseHandler.access$1600(Scene.java:3485)
at javafx.scene.Scene.pick(Scene.java:1942)
at javafx.scene.Scene.access$6700(Scene.java:159)
at javafx.scene.Scene$MouseHandler.process(Scene.java:3711)
at javafx.scene.Scene$MouseHandler.access$1500(Scene.java:3485)
at javafx.scene.Scene.impl_processMouseEvent(Scene.java:1762)
at javafx.scene.Scene$ScenePeerListener.mouseEvent(Scene.java:2494)
at com.sun.javafx.tk.quantum.GlassViewEventHandler$MouseEventNotification.run(GlassViewEventHandler.java:381)
at com.sun.javafx.tk.quantum.GlassViewEventHandler$MouseEventNotification.run(GlassViewEventHandler.java:295)
at java.security.AccessController.doPrivileged(Native Method)
at com.sun.javafx.tk.quantum.GlassViewEventHandler.lambda$handleMouseEvent$353(GlassViewEventHandler.java:417)
at com.sun.javafx.tk.quantum.QuantumToolkit.runWithoutRenderLock(QuantumToolkit.java:389)
at com.sun.javafx.tk.quantum.GlassViewEventHandler.handleMouseEvent(GlassViewEventHandler.java:416)
at com.sun.glass.ui.View.handleMouseEvent(View.java:555)
at com.sun.glass.ui.View.notifyMouse(View.java:937)
at com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
at com.sun.glass.ui.win.WinApplication.lambda$null$147(WinApplication.java:177)
at java.lang.Thread.run(Unknown Source)
Exception in thread "JavaFX Application Thread" java.lang.ArrayIndexOutOfBoundsException: -1
at java.util.ArrayList.elementData(Unknown Source)
at java.util.ArrayList.get(Unknown Source)
at com.sun.javafx.collections.ObservableListWrapper.get(ObservableListWrapper.java:89)
at com.sun.javafx.collections.VetoableListDecorator.get(VetoableListDecorator.java:306)
at javafx.scene.Parent.updateCachedBounds(Parent.java:1591)
at javafx.scene.Parent.recomputeBounds(Parent.java:1535)
at javafx.scene.Parent.impl_computeGeomBounds(Parent.java:1388)
at javafx.scene.layout.Region.impl_computeGeomBounds(Region.java:3078)
at javafx.scene.Node.updateGeomBounds(Node.java:3579)
at javafx.scene.Node.getGeomBounds(Node.java:3532)
at javafx.scene.Node.getLocalBounds(Node.java:3480)
at javafx.scene.Node.impl_intersectsBounds(Node.java:5015)
at javafx.scene.layout.Region.impl_pickNodeLocal(Region.java:2931)
at javafx.scene.Node.impl_pickNode(Node.java:4914)
at javafx.scene.Scene$MouseHandler.pickNode(Scene.java:3899)
at javafx.scene.Scene$MouseHandler.access$1600(Scene.java:3485)
at javafx.scene.Scene.pick(Scene.java:1942)
at javafx.scene.Scene.access$6700(Scene.java:159)
at javafx.scene.Scene$MouseHandler.process(Scene.java:3711)
at javafx.scene.Scene$MouseHandler.access$1500(Scene.java:3485)
at javafx.scene.Scene.impl_processMouseEvent(Scene.java:1762)
at javafx.scene.Scene$ScenePeerListener.mouseEvent(Scene.java:2494)
at com.sun.javafx.tk.quantum.GlassViewEventHandler$MouseEventNotification.run(GlassViewEventHandler.java:381)
at com.sun.javafx.tk.quantum.GlassViewEventHandler$MouseEventNotification.run(GlassViewEventHandler.java:295)
at java.security.AccessController.doPrivileged(Native Method)
at com.sun.javafx.tk.quantum.GlassViewEventHandler.lambda$handleMouseEvent$353(GlassViewEventHandler.java:417)
at com.sun.javafx.tk.quantum.QuantumToolkit.runWithoutRenderLock(QuantumToolkit.java:389)
at com.sun.javafx.tk.quantum.GlassViewEventHandler.handleMouseEvent(GlassViewEventHandler.java:416)
at com.sun.glass.ui.View.handleMouseEvent(View.java:555)
at com.sun.glass.ui.View.notifyMouse(View.java:937)
at com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
at com.sun.glass.ui.win.WinApplication.lambda$null$147(WinApplication.java:177)
at java.lang.Thread.run(Unknown Source)
Exception in thread "JavaFX Application Thread"
...and if we just mouse hover over the stage, it throws hundreds of times this exception:
Exception in thread "JavaFX Application Thread" java.lang.ArrayIndexOutOfBoundsException
Code which could cause the exceptions:
1. in this class we highlight the cards which the opponent has to discard (until he has left 3 cards; see line where croupier.isDiscardModeMilitia....)
public class GameCard extends Button implements Observer {
protected static final boolean MoneyCard = false;
ServiceLocatorClient sl = ServiceLocatorClient.getServiceLocator();
Croupier croupier = Croupier.getCroupier();
Label lbl_cardName;
String text_DE;
boolean holeCard = false;
int costs;
StackSizeInfo stackSizeInfo;
public GameCard(Label cardName, String text_DE) {
super();
this.lbl_cardName = cardName;
this.text_DE=text_DE;
this.assignPicture();
}
public GameCard(){
}
GameCard gc = this;
#Override
public void update(Observable arg0, Object arg1) {
getStyleClass().remove("highlight");
getStyleClass().remove("highlight2");
getStyleClass().remove("highlight3");
//Highlighte alle Karten im Kaufmodus, welche ich mit der aktuelln Buypower und buys kaufen kann
if (croupier.isBuyMode() == true && croupier.getBuyPower() >= this.costs && !this.isHoleCard() && croupier.getBuys() > 0){
this.getStyleClass().add("highlight");
}
//Highlighte alle Geldkarten im Kaufmodus
if (croupier.isBuyMode() == true && this.isHoleCard() && this instanceof MoneyCard){
this.getStyleClass().add("highlight");
}
//Highlighte alle Aktionskarten im Aktionsmodus
if (croupier.isActionMode() == true && this.isHoleCard() && this instanceof ActionCard){
this.getStyleClass().add("highlight");
}
//Highlighte alle HoleCards im Discardmodus (basement)
if (croupier.isDiscardMode() == true && this.isHoleCard()){
this.getStyleClass().add("highlight3");
}
//Highlighte alle HoleCards im TrashModus Kapelle
if (croupier.isTrashModeChapel() == true && this.isHoleCard()){
this.getStyleClass().add("highlight3");
}
//Highlighte alle MoneyCards im TrashModus Mine
if (croupier.isTrashModeMine() == true && this instanceof MoneyCard && this.isHoleCard()){
this.getStyleClass().add("highlight3");
}
//Highlighte alle Karten auf der Hand, welche im Umbaumodus weggeworfen werden können
if (croupier.isTrashModeRebuilding() == true && this.isHoleCard()){
this.getStyleClass().add("highlight3");
}
//Highlighte alle Kupferkarten auf der Hand, die gegen +3Geld weggeworfen werden können (ActionCard Geldverleiher)
if (croupier.isTrashModeMoneylender() == true && this.isHoleCard() && this.getLbl_cardName().getText().equals("copper")){
this.getStyleClass().add("highlight3");
}
//Highlighte alle MoneyCards, welche erworben werden können im Minen-Modus
if (croupier.isModeForMine() == true && this instanceof MoneyCard && !this.isHoleCard() && this.costs <= croupier.getSavedMCValueForMineMode()){
this.getStyleClass().add("highlight");
}
//Highlighte alle Karten zum Kauf, welche erworben werden können im Rebuilding-Modus
if (croupier.isModeForRebuilding() == true && !this.isHoleCard() && this.costs <= croupier.getCardValueForRebuildingMode()){
this.getStyleClass().add("highlight");
}
//Highlighte alle Karten zum Kauf, welche erworben werden können im Rebuilding-Modus
if (croupier.isModeForWorkshop() == true && !this.isHoleCard() && this.costs <= 4){
this.getStyleClass().add("highlight3");
}
//Highlighte alle Moat-Karten wenn ein Angriff gemacht worden ist
if (croupier.isReactionMode() == true && this.isHoleCard() && this.getLbl_cardName().getText().equals("moat")){
this.getStyleClass().add("highlight3");
}
//Highlighte alle Moat-Karten wenn ein Angriff gemacht worden ist
if (croupier.isDiscardModeMilitia() == true && this.isHoleCard()){
this.getStyleClass().add("highlight2");
}
//Highlighte alle Moat-Karten wenn ein Angriff gemacht worden ist
if (croupier.isModeForCurseCard() == true && !this.isHoleCard() && this.getLbl_cardName().getText().equals("curse")){
this.getStyleClass().add("highlight2");
}
//wenn stacksize auf 0, wird highlighting ebenfalls deaktiviert
if (croupier.getStackSize(gc) == 0) {
this.getStyleClass().remove("highlight");
}
//update das STackSize infoLabel auf der Karte
if (this.stackSizeInfo != null){
stackSizeInfo.updateStackSizeInfo();
}
}
public void assignStackSizeInfo(){
stackSizeInfo = new StackSizeInfo(gc,croupier.getStackSize(gc));
}
public void assignPicture(){
if (this.holeCard == false)
this.getStyleClass().addAll("card_mini",lbl_cardName.getText());
else
this.getStyleClass().addAll("card",lbl_cardName.getText()+"_big");
}
public boolean isHoleCard() {
return holeCard;
}
public void setHoleCard(boolean holeCard) {
this.holeCard = holeCard;
}
public Label getLbl_cardName() {
return lbl_cardName;
}
public String getText_DE(){
return this.text_DE;
}
public void setLbl_cardName(Label lbl_cardName) {
this.lbl_cardName = lbl_cardName;
}
}
possible code fragment: here we are updating the GUI. This happens whenever we play a card from the hand. We will remove it first from the LinkedList (HoleCards) in another method and then we call updateGUI
public void updateGUI() {
// Zeichne holeCards Neu
hb_wrapper_holeCards.getChildren().clear();
for (int i = 0; i < croupier.getHoleCards().size(); i++) {
GameCard gc1 = croupier.getHoleCards().get(i);
try{
hb_wrapper_holeCards.getChildren().add(gc1);
gc1.setPrefSize(160, 260);
gc1.setMaxWidth(160);
}catch (NullPointerException e){
//
}
// Zeichne Ablagekarte neu
hb_wrapper_stapel.getChildren().clear();
dummyCardAblagestapel.getStyleClass().clear();
try {
String cssSelector = new String(croupier.getAblagestapel().peekLast().getLbl_cardName().getText()+"_big");
dummyCardAblagestapel.getStyleClass().addAll("card",cssSelector);
hb_wrapper_stapel.getChildren().addAll(dummyCardAblagestapel,nachziehstapel);
} catch(Exception e){
hb_wrapper_stapel.getChildren().addAll(this.dummyCardAblagestapel,nachziehstapel);
}
}
}
note1: I guess it happens in the first fragment where we highlight the cards. After a player has discarded cards until he has only 3 left in the hand, we will remove the highlight. Exactly when he discards his last card, the exception is thrown (but as I said, we can play this for about 7-10 times without exceptions, but suddenly the exceptions are thrown)
note2: I have already tried with Platform.runLater on this 2 code fragments and it didn't help

Related

FXMLLoader.load(getClass().getResource()) gives null

I'm trying to make tests using TestFX. But when calling this code I get an error.
#ExtendWith(ApplicationExtension.class)
class HelloApplicationTest extends ApplicationTest {
public double x, y;
#Start
#Override
public void start(Stage stage) throws Exception {
Parent root = FXMLLoader.load(Objects.requireNonNull(getClass().getResource("fxml/Home.fxml")));
stage.initStyle(StageStyle.UNDECORATED);
root.setOnMousePressed(event -> {
x = stage.getX() - event.getSceneX();
y = stage.getY() - event.getSceneY();
});
root.setOnMouseDragged(event -> {
stage.setX(event.getSceneX() + x);
stage.setY(event.getSceneY() + y);
});
stage.setScene(new Scene(root, 606, 614));
stage.show();
}
}
Error:
--- Exception in Async Thread ---
java.lang.reflect.InvocationTargetException: null
java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:116)
java.base/java.lang.reflect.Method.invoke(Method.java:578)
org.testfx.framework.junit5.ApplicationExtension$AnnotationBasedApplicationFixture.start(ApplicationExtension.java:158)
org.testfx.framework.junit5.ApplicationAdapter.start(ApplicationAdapter.java:37)
org.testfx.toolkit.impl.ApplicationServiceImpl.lambda$start$0(ApplicationServiceImpl.java:49)
java.base/java.util.concurrent.FutureTask.run(FutureTask.java:317)
javafx.graphics#20-ea/com.sun.javafx.application.PlatformImpl.lambda$runLater$10(PlatformImpl.java:456)
java.base/java.security.AccessController.doPrivileged(AccessController.java:399)
javafx.graphics#20-ea/com.sun.javafx.application.PlatformImpl.lambda$runLater$11(PlatformImpl.java:455)
javafx.graphics#20-ea/com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:95)
javafx.graphics#20-ea/com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
javafx.graphics#20-ea/com.sun.glass.ui.win.WinApplication.lambda$runLoop$3(WinApplication.java:183)
java.base/java.lang.Thread.run(Thread.java:1589)
java.lang.NullPointerException: null
java.base/java.util.Objects.requireNonNull(Objects.java:233)
HelloApplicationTest.start(HelloApplicationTest.java:28)
java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:104)
java.base/java.lang.reflect.Method.invoke(Method.java:578)
org.testfx.framework.junit5.ApplicationExtension$AnnotationBasedApplicationFixture.start(ApplicationExtension.java:158)
org.testfx.framework.junit5.ApplicationAdapter.start(ApplicationAdapter.java:37)
org.testfx.toolkit.impl.ApplicationServiceImpl.lambda$start$0(ApplicationServiceImpl.java:49)
java.base/java.util.concurrent.FutureTask.run(FutureTask.java:317)
javafx.graphics#20-ea/com.sun.javafx.application.PlatformImpl.lambda$runLater$10(PlatformImpl.java:456)
java.base/java.security.AccessController.doPrivileged(AccessController.java:399)
javafx.graphics#20-ea/com.sun.javafx.application.PlatformImpl.lambda$runLater$11(PlatformImpl.java:455)
javafx.graphics#20-ea/com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:95)
javafx.graphics#20-ea/com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
javafx.graphics#20-ea/com.sun.glass.ui.win.WinApplication.lambda$runLoop$3(WinApplication.java:183)
java.base/java.lang.Thread.run(Thread.java:1589)
--- Trace of caller of unhandled exception in Async Thread ---
java.base/java.lang.Thread.getStackTrace(Thread.java:2550)
org.testfx.util.WaitForAsyncUtils$ASyncFXCallable.<init>(WaitForAsyncUtils.java:650)
org.testfx.util.WaitForAsyncUtils.asyncFx(WaitForAsyncUtils.java:258)
org.testfx.toolkit.impl.ApplicationServiceImpl.start(ApplicationServiceImpl.java:48)
org.testfx.toolkit.impl.ToolkitServiceImpl.lambda$setupApplication$6(ToolkitServiceImpl.java:127)
java.base/java.util.concurrent.FutureTask.run(FutureTask.java:317)
java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:577)
java.base/java.util.concurrent.FutureTask.run(FutureTask.java:317)
java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1144)
java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:642)
java.base/java.lang.Thread.run(Thread.java:1589)
--- Exception in Async Thread ---
java.util.concurrent.ExecutionException: java.lang.reflect.InvocationTargetException
java.base/java.util.concurrent.FutureTask.report(FutureTask.java:122)
java.base/java.util.concurrent.FutureTask.get(FutureTask.java:191)
org.testfx.util.WaitForAsyncUtils$ASyncFXCallable.get(WaitForAsyncUtils.java:697)
org.testfx.toolkit.impl.ToolkitServiceImpl.lambda$setupApplication$6(ToolkitServiceImpl.java:127)
java.base/java.util.concurrent.FutureTask.run(FutureTask.java:317)
java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:577)
java.base/java.util.concurrent.FutureTask.run(FutureTask.java:317)
java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1144)
java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:642)
java.base/java.lang.Thread.run(Thread.java:1589)
java.lang.reflect.InvocationTargetException: null
java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:116)
java.base/java.lang.reflect.Method.invoke(Method.java:578)
org.testfx.framework.junit5.ApplicationExtension$AnnotationBasedApplicationFixture.start(ApplicationExtension.java:158)
org.testfx.framework.junit5.ApplicationAdapter.start(ApplicationAdapter.java:37)
org.testfx.toolkit.impl.ApplicationServiceImpl.lambda$start$0(ApplicationServiceImpl.java:49)
java.base/java.util.concurrent.FutureTask.run(FutureTask.java:317)
javafx.graphics#20-ea/com.sun.javafx.application.PlatformImpl.lambda$runLater$10(PlatformImpl.java:456)
java.base/java.security.AccessController.doPrivileged(AccessController.java:399)
javafx.graphics#20-ea/com.sun.javafx.application.PlatformImpl.lambda$runLater$11(PlatformImpl.java:455)
javafx.graphics#20-ea/com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:95)
javafx.graphics#20-ea/com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
javafx.graphics#20-ea/com.sun.glass.ui.win.WinApplication.lambda$runLoop$3(WinApplication.java:183)
java.base/java.lang.Thread.run(Thread.java:1589)
java.lang.NullPointerException: null
java.base/java.util.Objects.requireNonNull(Objects.java:233)
HelloApplicationTest.start(HelloApplicationTest.java:28)
java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:104)
java.base/java.lang.reflect.Method.invoke(Method.java:578)
org.testfx.framework.junit5.ApplicationExtension$AnnotationBasedApplicationFixture.start(ApplicationExtension.java:158)
org.testfx.framework.junit5.ApplicationAdapter.start(ApplicationAdapter.java:37)
org.testfx.toolkit.impl.ApplicationServiceImpl.lambda$start$0(ApplicationServiceImpl.java:49)
java.base/java.util.concurrent.FutureTask.run(FutureTask.java:317)
javafx.graphics#20-ea/com.sun.javafx.application.PlatformImpl.lambda$runLater$10(PlatformImpl.java:456)
java.base/java.security.AccessController.doPrivileged(AccessController.java:399)
javafx.graphics#20-ea/com.sun.javafx.application.PlatformImpl.lambda$runLater$11(PlatformImpl.java:455)
javafx.graphics#20-ea/com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:95)
javafx.graphics#20-ea/com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
javafx.graphics#20-ea/com.sun.glass.ui.win.WinApplication.lambda$runLoop$3(WinApplication.java:183)
java.base/java.lang.Thread.run(Thread.java:1589)
--- Trace of caller of unhandled exception in Async Thread ---
java.base/java.lang.Thread.getStackTrace(Thread.java:2550)
org.testfx.util.WaitForAsyncUtils$ASyncFXCallable.<init>(WaitForAsyncUtils.java:650)
org.testfx.util.WaitForAsyncUtils.async(WaitForAsyncUtils.java:193)
org.testfx.toolkit.impl.ToolkitServiceImpl.setupApplication(ToolkitServiceImpl.java:123)
org.testfx.api.FxToolkit.setupApplication(FxToolkit.java:153)
org.testfx.framework.junit5.ApplicationExtension.beforeEach(ApplicationExtension.java:85)
org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.lambda$invokeBeforeEachCallbacks$2(TestMethodTestDescriptor.java:163)
org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.lambda$invokeBeforeMethodsOrCallbacksUntilExceptionOccurs$6(TestMethodTestDescriptor.java:199)
org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.invokeBeforeMethodsOrCallbacksUntilExceptionOccurs(TestMethodTestDescriptor.java:199)
org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.invokeBeforeEachCallbacks(TestMethodTestDescriptor.java:162)
org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.execute(TestMethodTestDescriptor.java:129)
org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.execute(TestMethodTestDescriptor.java:66)
org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$6(NodeTestTask.java:151)
org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$8(NodeTestTask.java:141)
org.junit.platform.engine.support.hierarchical.Node.around(Node.java:137)
org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$9(NodeTestTask.java:139)
org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
org.junit.platform.engine.support.hierarchical.NodeTestTask.executeRecursively(NodeTestTask.java:138)
org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:95)
java.base/java.util.ArrayList.forEach(ArrayList.java:1511)
org.junit.platform.engine.support.hierarchical.SameThreadHierarchicalTestExecutorService.invokeAll(SameThreadHierarchicalTestExecutorService.java:41)
org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$6(NodeTestTask.java:155)
org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$8(NodeTestTask.java:141)
org.junit.platform.engine.support.hierarchical.Node.around(Node.java:137)
org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$9(NodeTestTask.java:139)
org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
org.junit.platform.engine.support.hierarchical.NodeTestTask.executeRecursively(NodeTestTask.java:138)
org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:95)
java.base/java.util.ArrayList.forEach(ArrayList.java:1511)
org.junit.platform.engine.support.hierarchical.SameThreadHierarchicalTestExecutorService.invokeAll(SameThreadHierarchicalTestExecutorService.java:41)
org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$6(NodeTestTask.java:155)
org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$8(NodeTestTask.java:141)
org.junit.platform.engine.support.hierarchical.Node.around(Node.java:137)
org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$9(NodeTestTask.java:139)
org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
org.junit.platform.engine.support.hierarchical.NodeTestTask.executeRecursively(NodeTestTask.java:138)
org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:95)
org.junit.platform.engine.support.hierarchical.SameThreadHierarchicalTestExecutorService.submit(SameThreadHierarchicalTestExecutorService.java:35)
org.junit.platform.engine.support.hierarchical.HierarchicalTestExecutor.execute(HierarchicalTestExecutor.java:57)
org.junit.platform.engine.support.hierarchical.HierarchicalTestEngine.execute(HierarchicalTestEngine.java:54)
org.junit.platform.launcher.core.EngineExecutionOrchestrator.execute(EngineExecutionOrchestrator.java:107)
org.junit.platform.launcher.core.EngineExecutionOrchestrator.execute(EngineExecutionOrchestrator.java:88)
org.junit.platform.launcher.core.EngineExecutionOrchestrator.lambda$execute$0(EngineExecutionOrchestrator.java:54)
org.junit.platform.launcher.core.EngineExecutionOrchestrator.withInterceptedStreams(EngineExecutionOrchestrator.java:67)
org.junit.platform.launcher.core.EngineExecutionOrchestrator.execute(EngineExecutionOrchestrator.java:52)
org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:114)
org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:86)
org.junit.platform.launcher.core.DefaultLauncherSession$DelegatingLauncher.execute(DefaultLauncherSession.java:86)
org.junit.platform.launcher.core.SessionPerRequestLauncher.execute(SessionPerRequestLauncher.java:53)
com.intellij.junit5.JUnit5IdeaTestRunner.startRunnerWithArgs(JUnit5IdeaTestRunner.java:71)
com.intellij.rt.junit.IdeaTestRunner$Repeater$1.execute(IdeaTestRunner.java:38)
com.intellij.rt.execution.junit.TestsRepeater.repeat(TestsRepeater.java:11)
com.intellij.rt.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:35)
com.intellij.rt.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:235)
com.intellij.rt.junit.JUnitStarter.main(JUnitStarter.java:54)
java.lang.RuntimeException: java.util.concurrent.ExecutionException: java.lang.reflect.InvocationTargetException
at org.testfx.util.WaitForAsyncUtils.waitFor(WaitForAsyncUtils.java:302)
at org.testfx.api.FxToolkit.waitForSetup(FxToolkit.java:245)
at org.testfx.api.FxToolkit.setupApplication(FxToolkit.java:153)
at org.testfx.framework.junit5.ApplicationExtension.beforeEach(ApplicationExtension.java:85)
at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.lambda$invokeBeforeEachCallbacks$2(TestMethodTestDescriptor.java:163)
at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.lambda$invokeBeforeMethodsOrCallbacksUntilExceptionOccurs$6(TestMethodTestDescriptor.java:199)
at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.invokeBeforeMethodsOrCallbacksUntilExceptionOccurs(TestMethodTestDescriptor.java:199)
at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.invokeBeforeEachCallbacks(TestMethodTestDescriptor.java:162)
at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.execute(TestMethodTestDescriptor.java:129)
at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.execute(TestMethodTestDescriptor.java:66)
at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$6(NodeTestTask.java:151)
at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$8(NodeTestTask.java:141)
at org.junit.platform.engine.support.hierarchical.Node.around(Node.java:137)
at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$9(NodeTestTask.java:139)
at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
at org.junit.platform.engine.support.hierarchical.NodeTestTask.executeRecursively(NodeTestTask.java:138)
at org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:95)
at java.base/java.util.ArrayList.forEach(ArrayList.java:1511)
at org.junit.platform.engine.support.hierarchical.SameThreadHierarchicalTestExecutorService.invokeAll(SameThreadHierarchicalTestExecutorService.java:41)
at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$6(NodeTestTask.java:155)
at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$8(NodeTestTask.java:141)
at org.junit.platform.engine.support.hierarchical.Node.around(Node.java:137)
at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$9(NodeTestTask.java:139)
at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
at org.junit.platform.engine.support.hierarchical.NodeTestTask.executeRecursively(NodeTestTask.java:138)
at org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:95)
at java.base/java.util.ArrayList.forEach(ArrayList.java:1511)
at org.junit.platform.engine.support.hierarchical.SameThreadHierarchicalTestExecutorService.invokeAll(SameThreadHierarchicalTestExecutorService.java:41)
at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$6(NodeTestTask.java:155)
at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$8(NodeTestTask.java:141)
at org.junit.platform.engine.support.hierarchical.Node.around(Node.java:137)
at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$9(NodeTestTask.java:139)
at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
at org.junit.platform.engine.support.hierarchical.NodeTestTask.executeRecursively(NodeTestTask.java:138)
at org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:95)
at org.junit.platform.engine.support.hierarchical.SameThreadHierarchicalTestExecutorService.submit(SameThreadHierarchicalTestExecutorService.java:35)
at org.junit.platform.engine.support.hierarchical.HierarchicalTestExecutor.execute(HierarchicalTestExecutor.java:57)
at org.junit.platform.engine.support.hierarchical.HierarchicalTestEngine.execute(HierarchicalTestEngine.java:54)
at org.junit.platform.launcher.core.EngineExecutionOrchestrator.execute(EngineExecutionOrchestrator.java:107)
at org.junit.platform.launcher.core.EngineExecutionOrchestrator.execute(EngineExecutionOrchestrator.java:88)
at org.junit.platform.launcher.core.EngineExecutionOrchestrator.lambda$execute$0(EngineExecutionOrchestrator.java:54)
at org.junit.platform.launcher.core.EngineExecutionOrchestrator.withInterceptedStreams(EngineExecutionOrchestrator.java:67)
at org.junit.platform.launcher.core.EngineExecutionOrchestrator.execute(EngineExecutionOrchestrator.java:52)
at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:114)
at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:86)
at org.junit.platform.launcher.core.DefaultLauncherSession$DelegatingLauncher.execute(DefaultLauncherSession.java:86)
at org.junit.platform.launcher.core.SessionPerRequestLauncher.execute(SessionPerRequestLauncher.java:53)
at com.intellij.junit5.JUnit5IdeaTestRunner.startRunnerWithArgs(JUnit5IdeaTestRunner.java:71)
at com.intellij.rt.junit.IdeaTestRunner$Repeater$1.execute(IdeaTestRunner.java:38)
at com.intellij.rt.execution.junit.TestsRepeater.repeat(TestsRepeater.java:11)
at com.intellij.rt.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:35)
at com.intellij.rt.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:235)
at com.intellij.rt.junit.JUnitStarter.main(JUnitStarter.java:54)
Caused by: java.util.concurrent.ExecutionException: java.lang.reflect.InvocationTargetException
at java.base/java.util.concurrent.FutureTask.report(FutureTask.java:122)
at java.base/java.util.concurrent.FutureTask.get(FutureTask.java:191)
at org.testfx.util.WaitForAsyncUtils$ASyncFXCallable.get(WaitForAsyncUtils.java:697)
at org.testfx.toolkit.impl.ToolkitServiceImpl.lambda$setupApplication$6(ToolkitServiceImpl.java:127)
at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:317)
at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:577)
at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:317)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1144)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:642)
at java.base/java.lang.Thread.run(Thread.java:1589)
Caused by: java.lang.reflect.InvocationTargetException
at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:116)
at java.base/java.lang.reflect.Method.invoke(Method.java:578)
at org.testfx.framework.junit5.ApplicationExtension$AnnotationBasedApplicationFixture.start(ApplicationExtension.java:158)
at org.testfx.framework.junit5.ApplicationAdapter.start(ApplicationAdapter.java:37)
at org.testfx.toolkit.impl.ApplicationServiceImpl.lambda$start$0(ApplicationServiceImpl.java:49)
at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:317)
at javafx.graphics#20-ea/com.sun.javafx.application.PlatformImpl.lambda$runLater$10(PlatformImpl.java:456)
at java.base/java.security.AccessController.doPrivileged(AccessController.java:399)
at javafx.graphics#20-ea/com.sun.javafx.application.PlatformImpl.lambda$runLater$11(PlatformImpl.java:455)
at javafx.graphics#20-ea/com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:95)
at javafx.graphics#20-ea/com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
at javafx.graphics#20-ea/com.sun.glass.ui.win.WinApplication.lambda$runLoop$3(WinApplication.java:183)
... 1 more
Caused by: java.lang.NullPointerException
at java.base/java.util.Objects.requireNonNull(Objects.java:233)
at HelloApplicationTest.start(HelloApplicationTest.java:28)
at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:104)
... 12 more
As if it couldn't find the Home.fxml file. Here is the hierarchy of the project:
I tried to give a different file path, but I can't find it. Instead of getClass().getResource() I tried HelloApplication.class.getResource() but to no avail.

java.util.concurrent.RejectedExecutionException when action calls runAsync

I noticed while updating my TornadoFX version from 1.7.12 to 1.7.14 that one of my tests broke. Things seemed to go off the rails when a runAsyncWithProgress in the View under test was rejected by a ThreadPoolExecutor with status Terminated. I saw in the release notes for 1.7.13 there was a change "internal thread pools are shut down on app exit". Setting the TornadoFX version to 1.7.13 resulted in the same failure, confirming my suspicion that it was related to the above change.
I wrote a simple app to demonstrate this bug.
// src/main/kotlin/me/carltonwhitehead/AsyncBugApp.kt
class AsyncBugApp : App(MainView::class)
/**
* The main method is needed to support the mvn jfx:run goal.
*/
fun main(args: Array<String>) {
Application.launch(AsyncBugApp::class.java, *args)
}
class MainView : View("Async Bug App") {
val controller: MainController by inject()
override val root = pane {
button("Robot-click to repeat bug") {
id = "bug"
action {
runAsync {
controller.onAction("button clicked")
}
}
}
}
}
class MainController : Controller() {
fun onAction(message: String) {
println(message)
}
}
And the test
// src/test/kotlin/me/carltonwhitehead/AsyncBugAppTest.kt
#RunWith(Parameterized::class)
class AsyncBugAppTest(val rounds: Int) {
companion object {
#JvmStatic
#Parameterized.Parameters
fun data() : Collection<Array<Int>> {
return listOf(arrayOf(1), arrayOf(1))
}
}
lateinit var robot: FxRobot
lateinit var app: App
#RelaxedMockK
lateinit var controller: MainController
#Rule #JvmField
val timeout = Timeout(10, TimeUnit.SECONDS)
#Before
fun before() {
MockKAnnotations.init(this)
FxToolkit.registerPrimaryStage()
app = AsyncBugApp()
app.scope.set(controller)
FxToolkit.setupApplication { app }
robot = FxRobot()
println("rounds = $rounds")
}
#After
fun after() {
FxToolkit.cleanupStages()
FxToolkit.cleanupApplication(app)
}
#Test()
fun itShouldSurviveRunAsyncMultipleTimes() {
val latch = CountDownLatch(rounds)
every { controller.onAction(any()) }.answers { latch.countDown() }
var i = 0
while(i <= rounds) {
robot.clickOn("#bug")
i++
}
latch.await()
verify(exactly = rounds) { controller.onAction(any()) }
}
}
The first time that test executes, it passes. The second time, it hangs, because the runAsync is rejected with the below stack trace.
--- Exception in Async Thread ---
java.util.concurrent.RejectedExecutionException: Task tornadofx.FXTask#a315135 rejected from java.util.concurrent.ThreadPoolExecutor#75bde925[Terminated, pool size = 0, active threads = 0, queued tasks = 0, completed tasks = 2]
java.base/java.util.concurrent.ThreadPoolExecutor$AbortPolicy.rejectedExecution(ThreadPoolExecutor.java:2104)
java.base/java.util.concurrent.ThreadPoolExecutor.reject(ThreadPoolExecutor.java:848)
java.base/java.util.concurrent.ThreadPoolExecutor.execute(ThreadPoolExecutor.java:1397)
tornadofx.AsyncKt.task(Async.kt:76)
tornadofx.AsyncKt.task(Async.kt:69)
tornadofx.Component.runAsync(Component.kt:272)
tornadofx.Component.runAsync$default(Component.kt:988)
me.carltonwhitehead.MainView$root$1$1$1.invoke(AsyncBugApp.kt:21)
me.carltonwhitehead.MainView$root$1$1$1.invoke(AsyncBugApp.kt:15)
tornadofx.ControlsKt$action$2.handle(Controls.kt:513)
tornadofx.ControlsKt$action$2.handle(Controls.kt)
javafx.base/com.sun.javafx.event.CompositeEventHandler.dispatchBubblingEvent(CompositeEventHandler.java:86)
javafx.base/com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventHandlerManager.java:238)
javafx.base/com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventHandlerManager.java:191)
javafx.base/com.sun.javafx.event.CompositeEventDispatcher.dispatchBubblingEvent(CompositeEventDispatcher.java:59)
javafx.base/com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:58)
javafx.base/com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
javafx.base/com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)
javafx.base/com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
javafx.base/com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)
javafx.base/com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
javafx.base/com.sun.javafx.event.EventUtil.fireEventImpl(EventUtil.java:74)
javafx.base/com.sun.javafx.event.EventUtil.fireEvent(EventUtil.java:49)
javafx.base/javafx.event.Event.fireEvent(Event.java:198)
javafx.graphics/javafx.scene.Node.fireEvent(Node.java:8863)
javafx.controls/javafx.scene.control.Button.fire(Button.java:200)
javafx.controls/com.sun.javafx.scene.control.behavior.ButtonBehavior.mouseReleased(ButtonBehavior.java:206)
javafx.controls/com.sun.javafx.scene.control.inputmap.InputMap.handle(InputMap.java:274)
javafx.base/com.sun.javafx.event.CompositeEventHandler$NormalEventHandlerRecord.handleBubblingEvent(CompositeEventHandler.java:218)
javafx.base/com.sun.javafx.event.CompositeEventHandler.dispatchBubblingEvent(CompositeEventHandler.java:80)
javafx.base/com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventHandlerManager.java:238)
javafx.base/com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventHandlerManager.java:191)
javafx.base/com.sun.javafx.event.CompositeEventDispatcher.dispatchBubblingEvent(CompositeEventDispatcher.java:59)
javafx.base/com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:58)
javafx.base/com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
javafx.base/com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)
javafx.base/com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
javafx.base/com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)
javafx.base/com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
javafx.base/com.sun.javafx.event.EventUtil.fireEventImpl(EventUtil.java:74)
javafx.base/com.sun.javafx.event.EventUtil.fireEvent(EventUtil.java:54)
javafx.base/javafx.event.Event.fireEvent(Event.java:198)
javafx.graphics/javafx.scene.Scene$MouseHandler.process(Scene.java:3876)
javafx.graphics/javafx.scene.Scene$MouseHandler.access$1300(Scene.java:3604)
javafx.graphics/javafx.scene.Scene.processMouseEvent(Scene.java:1874)
javafx.graphics/javafx.scene.Scene$ScenePeerListener.mouseEvent(Scene.java:2613)
javafx.graphics/com.sun.javafx.tk.quantum.GlassViewEventHandler$MouseEventNotification.run(GlassViewEventHandler.java:397)
javafx.graphics/com.sun.javafx.tk.quantum.GlassViewEventHandler$MouseEventNotification.run(GlassViewEventHandler.java:295)
java.base/java.security.AccessController.doPrivileged(Native Method)
javafx.graphics/com.sun.javafx.tk.quantum.GlassViewEventHandler.lambda$handleMouseEvent$2(GlassViewEventHandler.java:434)
javafx.graphics/com.sun.javafx.tk.quantum.QuantumToolkit.runWithoutRenderLock(QuantumToolkit.java:389)
javafx.graphics/com.sun.javafx.tk.quantum.GlassViewEventHandler.handleMouseEvent(GlassViewEventHandler.java:433)
javafx.graphics/com.sun.glass.ui.View.handleMouseEvent(View.java:556)
javafx.graphics/com.sun.glass.ui.View.notifyMouse(View.java:942)
javafx.graphics/com.sun.glass.ui.gtk.GtkApplication._runLoop(Native Method)
javafx.graphics/com.sun.glass.ui.gtk.GtkApplication.lambda$runLoop$11(GtkApplication.java:277)
java.base/java.lang.Thread.run(Thread.java:844)
I suspect I might be doing something wrong with the TestFX/TornadoFX app lifecycle. Each test cycle is creating a new app instance, so I'm confused why the ThreadPoolExecutor would be retained. Any suggestions?
Repo at https://github.com/carltonwhitehead/fx-async-bug-test

read lines of text file to string array

I need to write lines of text into a file and then read them line by line.
therefore I used these codes to write into a file:
String string = "Hello world55555555555!" + "\r\n";
FileOutputStream outputStream;
try {
outputStream = getActivity().openFileOutput(filename, Context.MODE_PRIVATE);
outputStream.write(string.getBytes());
outputStream.flush();
outputStream.close();
} catch (Exception e) {
e.printStackTrace();
}
return true;
which it seems work properly. but when I am reading it get error! I am trying to read it by these codes:
FileInputStream inputStream = null;
BufferedReader reader;
String[] text = new String[0];
List < String > words = new ArrayList < String > ();
String line;
try {
inputStream = getActivity().openFileInput(filename);
reader = new BufferedReader(new InputStreamReader(inputStream));
while ((line = reader.readLine()) != null) {
words.add(line);
}
text = new String[words.size()];
text = words.toArray(text);
} catch (IOException e) {
//You'll need to add proper error handling here
}
tv.setText(text[0]);
Toast.makeText(getActivity(), text[1],
Toast.LENGTH_SHORT).show();
}
any comments! Please!
Thanks for your considerations, I update my read codes to:
FileInputStream inputStream = null;
BufferedReader reader;
StringBuilder[] total = new StringBuilder[]{};
String line;
try{
inputStream = new FileInputStream(filename);
reader = new BufferedReader(new InputStreamReader(inputStream));
int j =0;
while ((line = reader.readLine()) != null) {
total[j].append(line);
j++;
}
}
catch(IOException e){
//You'll need to add proper error handling here
}
tv.setText(total[0]);
Toast.makeText(getActivity(),total[1],
Toast.LENGTH_SHORT).show();
}
But I get errors yet and app shutdown:
10-18 10:36:50.700 3087-3087/? D/AndroidRuntime﹕ Shutting down VM
10-18 10:36:50.700 3087-3087/? E/AndroidRuntime﹕ FATAL EXCEPTION: main
Process: ir.siavashon.sunshine, PID: 3087
java.lang.ArrayIndexOutOfBoundsException: length=0; index=0
at ir.siavashon.sunshine.MainActivityFragment.onClick(MainActivityFragment.java:140)
at android.view.View.performClick(View.java:5198)
at android.view.View$PerformClick.run(View.java:21147)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:5417)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
10-18 10:36:50.700 1342-2903/? W/ActivityManager﹕ Force finishing activity ir.siavashon.sunshine/.MainActivity
10-18 10:36:50.710 993-993/? D/gralloc﹕ Registering a buffer in the process that created it. This may cause memory ordering problems.
10-18 10:36:50.710 993-993/? E/libEGL﹕ called unimplemented OpenGL ES API
10-18 10:36:50.710 993-993/? E/SurfaceFlinger﹕ glCheckFramebufferStatusOES error -906983389
10-18 10:36:50.710 993-993/? E/SurfaceFlinger﹕ got GL_FRAMEBUFFER_COMPLETE_OES error while taking screenshot
10-18 10:36:50.730 1342-3103/? W/DropBoxManagerService﹕ Dropping: data_app_crash (848 > 0 bytes)
10-18 10:36:51.220 1342-1356/? W/ActivityManager﹕ Activity pause timeout for ActivityRecord{a21f483 u0 ir.siavashon.sunshine/.MainActivity t897 f}
10-18 10:36:52.190 1656-1656/? I/Choreographer﹕ Skipped 55 frames! The application may be doing too much work on its main thread.
10-18 10:36:53.330 3087-3087/? I/Process﹕ Sending signal. PID: 3087 SIG: 9
10-18 10:36:53.430 1342-1372/? W/InputDispatcher﹕ channel 'cb217a9 ir.siavashon.sunshine/ir.siavashon.sunshine.MainActivity (server)' ~ Consumer closed input channel or an error occurred. events=0x9
10-18 10:36:53.430 1342-1372/? E/InputDispatcher﹕ channel 'cb217a9 ir.siavashon.sunshine/ir.siavashon.sunshine.MainActivity (server)' ~ Channel is unrecoverably broken and will be disposed!
10-18 10:36:53.430 1342-2903/? I/ActivityManager﹕ Process ir.siavashon.sunshine (pid 3087) has died
10-18 10:36:53.590 1342-1361/? W/AppOps﹕ Finishing op nesting under-run: uid 1000 pkg android code 24 time=0 duration=0 nesting=0
10-18 10:36:53.600 1342-1490/? I/WindowState﹕ WIN DEATH: Window{cb217a9 u0 ir.siavashon.sunshine/ir.siavashon.sunshine.MainActivity}
10-18 10:36:53.600 1342-1490/? W/InputDispatcher﹕ Attempted to unregister already unregistered input channel 'cb217a9 ir.siavashon.sunshine/ir.siavashon.sunshine.MainActivity (server)'

I can't figure out my error

I have a JavaFX application which have a scheduledExecutorService who's requesting some datas from a server. these datas are used to fill a ListView and when I click on an element in this list a request for more datas is sent to the server and a MQTT connection is set, but a few seconds later I get a NullPointerException from somwhere I don't understand and I don't even know what object points to Null.
Here is the part where the error comes from :
public class DevicePane extends BorderPane {
private final TcpConnection tcp;
private final MqttConnection mqtt;
private final DeviceListView deviceListView;
private SpecificDevicePane deviceInfoPane;
private String[] topicsArray;
public DevicePane() {
tcp = new TcpConnection();
mqtt = new MqttConnection();
mqtt.connect();
deviceListView = new DeviceListView();
deviceListView.getSelectionModel().selectedIndexProperty().addListener(e -> {
if (topicsArray != null) mqtt.unsubscribeToAll(topicsArray);
AnswerMessage answer = tcp.sendRequest(new RequestMessage(RQST_DEVICE_INFO, deviceListView.getSelectionModel().getSelectedItem().toString()));
topicsArray = new String[answer.getParams().size()];
topicsArray = answer.getParams().toArray(topicsArray);
mqtt.subscribeToAll(topicsArray);
deviceInfoPane = new SpecificDevicePane(answer.getParams(), mqtt, tcp);
ScrollPane scrollPane = new ScrollPane(deviceInfoPane);
this.setCenter(scrollPane);
});
this.setLeft(deviceListView);
// Tâche planifiée afin de récupérer la liste des objets IOT de la DB.
ScheduledExecutorService threadPool = Executors.newScheduledThreadPool(1);
threadPool.scheduleAtFixedRate(() -> {
refreshDeviceList();
}, 0, 5, TimeUnit.SECONDS);
}
And here is the error I get :
Exception in thread "JavaFX Application Thread" java.lang.NullPointerException
at view.DevicePane.lambda$new$8(DevicePane.java:36)
at view.DevicePane$$Lambda$77/576256602.invalidated(Unknown Source)
at com.sun.javafx.binding.ExpressionHelper$Generic.fireValueChangedEvent(ExpressionHelper.java:349)
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:147)
at javafx.scene.control.SelectionModel.setSelectedIndex(SelectionModel.java:68)
at javafx.scene.control.MultipleSelectionModelBase.clearSelection(MultipleSelectionModelBase.java:665)
at javafx.scene.control.ListView$ListViewBitSetSelectionModel.updateSelection(ListView.java:1306)
at javafx.scene.control.ListView$ListViewBitSetSelectionModel.access$1600(ListView.java:1173)
at javafx.scene.control.ListView$ListViewBitSetSelectionModel$1.onChanged(ListView.java:1246)
at javafx.collections.WeakListChangeListener.onChanged(WeakListChangeListener.java:88)
at com.sun.javafx.collections.ListListenerHelper$Generic.fireValueChangedEvent(ListListenerHelper.java:329)
at com.sun.javafx.collections.ListListenerHelper.fireValueChangedEvent(ListListenerHelper.java:73)
at javafx.collections.ObservableListBase.fireChange(ObservableListBase.java:233)
at javafx.collections.ListChangeBuilder.commit(ListChangeBuilder.java:482)
at javafx.collections.ListChangeBuilder.endChange(ListChangeBuilder.java:541)
at javafx.collections.ObservableListBase.endChange(ObservableListBase.java:205)
at javafx.collections.ModifiableObservableListBase.setAll(ModifiableObservableListBase.java:90)
at view.DeviceListView.refreshShownDevice(DeviceListView.java:43)
at view.DeviceListView.setDeviceList(DeviceListView.java:33)
at view.DeviceListView.lambda$setDeviceList$7(DeviceListView.java:36)
at view.DeviceListView$$Lambda$160/2054192134.run(Unknown Source)
at com.sun.javafx.application.PlatformImpl.lambda$null$170(PlatformImpl.java:295)
at com.sun.javafx.application.PlatformImpl$$Lambda$48/1826358374.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at com.sun.javafx.application.PlatformImpl.lambda$runLater$171(PlatformImpl.java:294)
at com.sun.javafx.application.PlatformImpl$$Lambda$47/1915503092.run(Unknown Source)
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$145(WinApplication.java:101)
at com.sun.glass.ui.win.WinApplication$$Lambda$36/1963387170.run(Unknown Source)
at java.lang.Thread.run(Thread.java:745)
Line 36 is this line : AnswerMessage answer = tcp.sendRequest(new RequestMessage(RQST_DEVICE_INFO, deviceListView.getSelectionModel().getSelectedItem().toString()));
I hope someone will be able to help me

org.openqa.selenium.WebDriverException: ReferenceError: jQuery is not defined

Hi I am trying to write autonomous test using Webdriver for firefox profile, I enabled the javascript equal to true while creating Driver object.
In some view jquery responses late so for that I tried to put one check in webdriver code to wait For JQuery Processing
Code snippet for waitForJQueryProcessing:
public static boolean waitForJQueryProcessing(WebDriver driver,
int timeOutInSeconds) {
boolean jQcondition = false;
try {
new WebDriverWait(driver, timeOutInSeconds) {
}.until(new ExpectedCondition<Boolean>() {
#Override
public Boolean apply(WebDriver driverObject) {
return (Boolean) ((JavascriptExecutor) driverObject)
.executeScript("return jQuery.active == 0");
}
});
jQcondition = (Boolean) ((JavascriptExecutor) driver)
.executeScript("return jQuery.active == 0");
return jQcondition;
} catch (Exception e) {
e.printStackTrace();
}
return jQcondition;
}
But the above code is rising exception
Stacktrace
org.openqa.selenium.WebDriverException: ReferenceError: jQuery is not defined
Command duration or timeout: 10 milliseconds
Build info: version: '2.32.0', revision: '6c40c187d01409a5dc3b7f8251859150c8af0bcb', time: '2013-04-09 10:39:28'
System info: os.name: 'Windows 7', os.arch: 'x86', os.version: '6.1', java.version: '1.6.0_17'
Session ID: 58ad81d0-53f9-4862-a916-a1900efdc9c0
Driver info: org.openqa.selenium.firefox.FirefoxDriver
Capabilities [{platform=XP, acceptSslCerts=true, javascriptEnabled=true, browserName=firefox, rotatable=false, locationContextEnabled=true, version=21.0, cssSelectorsEnabled=true, databaseEnabled=true, handlesAlerts=true, browserConnectionEnabled=true, nativeEvents=true, webStorageEnabled=true, applicationCacheEnabled=true, takesScreenshot=true}]
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
at org.openqa.selenium.remote.ErrorHandler.createThrowable(ErrorHandler.java:187)
at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:145)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:554)
at org.openqa.selenium.remote.RemoteWebDriver.executeScript(RemoteWebDriver.java:463)
at com.iclinica.utils.WaitTool$9.apply(WaitTool.java:309)
at com.iclinica.utils.WaitTool$9.apply(WaitTool.java:1)
at org.openqa.selenium.support.ui.FluentWait.until(FluentWait.java:208)
at com.iclinica.utils.WaitTool.waitForJQueryProcessing(WaitTool.java:304)
at com.iclinica.globals.FirefoxCustomWebdriver.findElement(FirefoxCustomWebdriver.java:14)
at com.iclinica.page.studyconfig.studydetails.StudyDetailsPage.studydetails(StudyDetailsPage.java:20)
at com.iclinica.studyconfig.AddPatients.teststudycreation(AddPatients.java:168)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:84)
at org.testng.internal.Invoker.invokeMethod(Invoker.java:714)
at org.testng.internal.Invoker.invokeTestMethod(Invoker.java:901)
at org.testng.internal.Invoker.invokeTestMethods(Invoker.java:1231)
at org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:127)
at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:111)
at org.testng.TestRunner.privateRun(TestRunner.java:767)
at org.testng.TestRunner.run(TestRunner.java:617)
at org.testng.SuiteRunner.runTest(SuiteRunner.java:334)
at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:329)
at org.testng.SuiteRunner.privateRun(SuiteRunner.java:291)
at org.testng.SuiteRunner.run(SuiteRunner.java:240)
at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:52)
at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:86)
at org.testng.TestNG.runSuitesSequentially(TestNG.java:1224)
at org.testng.TestNG.runSuitesLocally(TestNG.java:1149)
at org.testng.TestNG.run(TestNG.java:1057)
at org.testng.remote.RemoteTestNG.run(RemoteTestNG.java:111)
at org.testng.remote.RemoteTestNG.initAndRun(RemoteTestNG.java:204)
at org.testng.remote.RemoteTestNG.main(RemoteTestNG.java:175)
I googled for setting jquery file path in webdriver object, but didn't find any result
I hope it makes sense.
Thanks
Gaurav
Use this instead:
public static boolean waitForJQueryProcessing(WebDriver driver,
int timeOutInSeconds) {
boolean jQcondition = false;
try {
new WebDriverWait(driver, timeOutInSeconds) {
}.until(new ExpectedCondition<Boolean>() {
#Override
public Boolean apply(WebDriver driverObject) {
return (Boolean) ((JavascriptExecutor) driverObject)
.executeScript("return jQuery.active == 0");
}
});
jQcondition = (Boolean) ((JavascriptExecutor) driver)
.executeScript("return window.jQuery != undefined && jQuery.active === 0");
return jQcondition;
} catch (Exception e) {
e.printStackTrace();
}
return jQcondition;
}
The change from your original code snippet is:
.executeScript("return window.jQuery != undefined && jQuery.active === 0");
This will make sure that your jQuery object is defined before checking if there are any active jQuery processes. Selenium runs fast and can sometimes make queries to jQuery before it has had a chance to load into the page you are testing.
There is one shorter version of code which works for me:
public void waitForAjaxLoad(WebDriver driver) throws InterruptedException{
JavascriptExecutor executor = (JavascriptExecutor)driver;
if((Boolean) executor.executeScript("return window.jQuery != undefined")){
while(!(Boolean) executor.executeScript("return jQuery.active == 0")){
Thread.sleep(1000);
}
}
return;
}
Milliseconds (1000) can be added to parameter of method.
When you test for jQuery completion do not forget to add a check for jQuery being undefined else you will end up with :
ReferenceError: jQuery is not defined error.
jQuery check you should perform:
(Boolean)((JavascriptExecutor) wd).executeScript("return window.jQuery != undefined && jQuery.active == 0")
Now when you write method then I would suggest to use Fluent Wait in your selenium code rather than implicit or explicit wait. Fluent wait method will help you do operation in between the polling interval wait unlike other waits and is very useful or rather powerful.
Below is the working method which you can directly use :
public static void pageJqueryLoad(WebDriver driver, Duration waitTimeout) {
Wait<WebDriver> wait = new FluentWait<>(driver)
.withTimeout(waitTimeout)
.pollingEvery(Duration.ofMillis(500))
.ignoring(NoSuchElementException.class);
wait.until((ExpectedCondition<Boolean>) wd -> {
log.info("Waiting for Page jQuery to complete");
log.info("jQuery.active value is : " + ((JavascriptExecutor) wd).executeScript("return window.jQuery != undefined && jQuery.active"));
(Boolean)((JavascriptExecutor) wd).executeScript("return window.jQuery != undefined && jQuery.active == 0");
});
}
In the above method :
You need to pass your driver and waitTimeout duration as argument to this method. For ex: pageJqueryLoad(driver, Duration.ofSeconds(120));
I have defined polling interval as 500 ms. You can modify as per your need.
Every time a poll is done it prints the 3 statement given under log.info.
Using this you can easily add code to determine the exact time your page was rendered completely before doing test operations.

Resources