File tree Expand file tree Collapse file tree 1 file changed +23
-3
lines changed
paper/src/main/java/org/incendo/interfaces/paper/utils Expand file tree Collapse file tree 1 file changed +23
-3
lines changed Original file line number Diff line number Diff line change 99@ DefaultQualifier (NonNull .class )
1010public final class EventUtil {
1111
12+ private static final Field EVENT_IS_ASYNC_FIELD ;
13+
14+ static {
15+ Field field ;
16+ try {
17+ try {
18+ field = Event .class .getDeclaredField ("async" );
19+ } catch (final NoSuchFieldException e0 ) {
20+ try {
21+ field = Event .class .getDeclaredField ("isAsync" );
22+ } catch (final NoSuchFieldException e1 ) {
23+ e1 .addSuppressed (e0 );
24+ throw e1 ;
25+ }
26+ }
27+ field .setAccessible (true );
28+ } catch (final Throwable thr ) {
29+ throw new RuntimeException ("Failed to find async/isAsync field in Event class" , thr );
30+ }
31+ EVENT_IS_ASYNC_FIELD = field ;
32+ }
33+
1234 private EventUtil () {
1335 }
1436
@@ -20,9 +42,7 @@ private EventUtil() {
2042 */
2143 public static void setAsync (final Event event , final boolean async ) {
2244 try {
23- final Field field = Event .class .getDeclaredField ("async" );
24- field .setAccessible (true );
25- field .set (event , async );
45+ EVENT_IS_ASYNC_FIELD .set (event , async );
2646 } catch (final ReflectiveOperationException ex ) {
2747 throw new RuntimeException (ex );
2848 }
You can’t perform that action at this time.
0 commit comments