MCPcopy Create free account
hub / github.com/apache/tomcat / getExecutor

Method getExecutor

java/org/apache/tomcat/util/compat/Jre19Compat.java:50–81  ·  view source on GitHub ↗
(Thread thread)

Source from the content-addressed store, hash-verified

48 }
49
50 @Override
51 public Object getExecutor(Thread thread)
52 throws NoSuchFieldException, SecurityException, IllegalArgumentException, IllegalAccessException {
53
54 Object result = super.getExecutor(thread);
55
56 if (result == null) {
57 Object holder = null;
58 Object task = null;
59 try {
60 Field holderField = thread.getClass().getDeclaredField("holder");
61 holderField.setAccessible(true);
62 holder = holderField.get(thread);
63
64 Field taskField = holder.getClass().getDeclaredField("task");
65 taskField.setAccessible(true);
66 task = taskField.get(holder);
67 } catch (NoSuchFieldException nfe) {
68 return null;
69 }
70
71 if (task != null && task.getClass().getCanonicalName() != null && (task.getClass().getCanonicalName()
72 .equals("org.apache.tomcat.util.threads.ThreadPoolExecutor.Worker") ||
73 task.getClass().getCanonicalName().equals("java.util.concurrent.ThreadPoolExecutor.Worker"))) {
74 Field executorField = task.getClass().getDeclaredField("this$0");
75 executorField.setAccessible(true);
76 result = executorField.get(task);
77 }
78 }
79
80 return result;
81 }
82}

Callers

nothing calls this directly

Calls 4

getCanonicalNameMethod · 0.80
getExecutorMethod · 0.65
getMethod · 0.65
equalsMethod · 0.65

Tested by

no test coverage detected