-
Notifications
You must be signed in to change notification settings - Fork 208
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ZK-5677: Executions.schedule cause infinite loop if async event cause…
…s exception
- Loading branch information
1 parent
769a16b
commit 2ff7450
Showing
6 changed files
with
125 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
55 changes: 55 additions & 0 deletions
55
zktest/src/main/java/org/zkoss/zktest/test2/B101_ZK_5677_Composer.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
/* B101_ZK_5677_Composer.java | ||
Purpose: | ||
Description: | ||
History: | ||
10:48 AM 2024/9/9, Created by jumperchen | ||
Copyright (C) 2024 Potix Corporation. All Rights Reserved. | ||
*/ | ||
package org.zkoss.zktest.test2; | ||
|
||
import org.zkoss.zk.ui.Component; | ||
import org.zkoss.zk.ui.Desktop; | ||
import org.zkoss.zk.ui.Executions; | ||
import org.zkoss.zk.ui.event.Event; | ||
import org.zkoss.zk.ui.event.EventListener; | ||
import org.zkoss.zk.ui.select.SelectorComposer; | ||
import org.zkoss.zk.ui.select.annotation.Listen; | ||
|
||
/** | ||
* @author jumperchen | ||
*/ | ||
public class B101_ZK_5677_Composer extends SelectorComposer<Component> { | ||
|
||
|
||
@Override | ||
public void doAfterCompose(Component comp) throws Exception { | ||
super.doAfterCompose(comp); | ||
Executions.getCurrent().getDesktop().enableServerPush(true); | ||
} | ||
|
||
public static int errorCount = 0; | ||
@Listen("onClick=#btn") | ||
public void scheduleEvent() { | ||
Desktop dt = Executions.getCurrent().getDesktop(); | ||
Runnable runnable = () -> { | ||
if (errorCount < 3) { | ||
throw new NullPointerException("test: " + ++errorCount); | ||
} | ||
}; | ||
EventListener executeEventListener = (evt)->{ | ||
Thread.sleep(500); //simulate processing time | ||
runnable.run(); | ||
}; | ||
try { | ||
Executions.schedule(dt, executeEventListener, new Event("foo")); | ||
} catch (Exception e) { | ||
String msg = "scheduling error"; | ||
throw new RuntimeException(msg,e); | ||
} | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
|
||
<!-- | ||
B101-ZK-5677.zul | ||
Purpose: | ||
Description: | ||
History: | ||
2024/9/9, Created by jumperchen | ||
Copyright (C) 2024 Potix Corporation. All Rights Reserved. | ||
--> | ||
<zk> | ||
<div apply="org.zkoss.zktest.test2.B101_ZK_5677_Composer"> | ||
Click this button, and you will only see a "test 1" message alert | ||
<button id="btn" label="schedule event" /> | ||
</div> | ||
</zk> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
40 changes: 40 additions & 0 deletions
40
zktest/src/test/java/org/zkoss/zktest/zats/test2/B101_ZK_5677Test.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
/* B101_ZK_5677Test.java | ||
Purpose: | ||
Description: | ||
History: | ||
10:54 AM 2024/9/9, Created by jumperchen | ||
Copyright (C) 2024 Potix Corporation. All Rights Reserved. | ||
*/ | ||
package org.zkoss.zktest.zats.test2; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
import static org.junit.jupiter.api.Assertions.fail; | ||
|
||
import org.junit.jupiter.api.Test; | ||
|
||
import org.zkoss.zats.ZatsException; | ||
import org.zkoss.zats.mimic.ComponentAgent; | ||
import org.zkoss.zats.mimic.DesktopAgent; | ||
import org.zkoss.zktest.test2.B101_ZK_5677_Composer; | ||
import org.zkoss.zktest.zats.ZATSTestCase; | ||
|
||
/** | ||
* @author jumperchen | ||
*/ | ||
public class B101_ZK_5677Test extends ZATSTestCase { | ||
@Test | ||
public void test() { | ||
DesktopAgent desktop = connect(); | ||
ComponentAgent btn = desktop.query("#btn"); | ||
try { | ||
btn.click(); | ||
fail("cannot reach here"); | ||
} catch (ZatsException ze) { | ||
assertEquals(1, B101_ZK_5677_Composer.errorCount, "error count should be 1"); | ||
} | ||
} | ||
} |