Skip to content

Commit d63637a

Browse files
committed
Leverage utility class for determining thread type.
1 parent b024947 commit d63637a

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

providers/grizzly/src/main/java/org/asynchttpclient/providers/grizzly/FeedableBodyGenerator.java

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
import org.glassfish.grizzly.impl.FutureImpl;
3232
import org.glassfish.grizzly.nio.NIOConnection;
3333
import org.glassfish.grizzly.nio.SelectorRunner;
34+
import org.glassfish.grizzly.threadpool.Threads;
3435
import org.glassfish.grizzly.utils.Futures;
3536

3637
import static java.lang.Boolean.TRUE;
@@ -185,7 +186,7 @@ public void run() {
185186
// If the current thread is a selector thread, we need to execute
186187
// the remainder of the task on the worker thread to prevent
187188
// it from being blocked.
188-
if (isCurrentThreadSelectorRunner()) {
189+
if (isServiceThread()) {
189190
c.getTransport().getWorkerThreadPool().execute(r);
190191
} else {
191192
r.run();
@@ -196,10 +197,8 @@ public void run() {
196197
// --------------------------------------------------------- Private Methods
197198

198199

199-
private boolean isCurrentThreadSelectorRunner() {
200-
final NIOConnection c = (NIOConnection) context.getConnection();
201-
final SelectorRunner runner = c.getSelectorRunner();
202-
return (Thread.currentThread() == runner.getRunnerThread());
200+
private boolean isServiceThread() {
201+
return Threads.isService();
203202
}
204203

205204

0 commit comments

Comments
 (0)