Skip to content

Commit f1e90a4

Browse files
committed
ModuleErroredEventTest: save ref to subscriber
So that it cannot be garbage collected too early.
1 parent 5e7cdbd commit f1e90a4

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

src/test/java/org/scijava/module/event/ModuleErroredEventTest.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,13 +68,14 @@ public void testModuleErroredEvent() {
6868
final boolean[] caughtException = { false };
6969

7070
// Add a new EventHandler to change our state
71-
es.subscribe(new Object() {
71+
final Object interestedParty = new Object() {
7272

7373
@EventHandler
7474
void onEvent(final ModuleErroredEvent e) {
7575
caughtException[0] = true;
7676
}
77-
});
77+
};
78+
es.subscribe(interestedParty);
7879

7980
// Run the module, ensure we get the exception
8081
assertThrows(Exception.class, //

0 commit comments

Comments
 (0)