Skip to content

Commit 06203e3

Browse files
committed
Leverage utility class for determining thread type.
1 parent 48c5765 commit 06203e3

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

src/main/java/com/ning/http/client/providers/grizzly/FeedableBodyGenerator.java

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
import org.glassfish.grizzly.nio.SelectorRunner;
3434
import org.glassfish.grizzly.ssl.SSLBaseFilter;
3535
import org.glassfish.grizzly.ssl.SSLFilter;
36+
import org.glassfish.grizzly.threadpool.Threads;
3637
import org.glassfish.grizzly.utils.Futures;
3738

3839
import static com.ning.http.client.providers.grizzly.GrizzlyAsyncHttpProvider.getHttpTransactionContext;
@@ -193,7 +194,7 @@ public void run() {
193194
// If the current thread is a selector thread, we need to execute
194195
// the remainder of the task on the worker thread to prevent
195196
// it from being blocked.
196-
if (isCurrentThreadSelectorRunner()) {
197+
if (isServiceThread()) {
197198
c.getTransport().getWorkerThreadPool().execute(r);
198199
} else {
199200
r.run();
@@ -204,10 +205,8 @@ public void run() {
204205
// --------------------------------------------------------- Private Methods
205206

206207

207-
private boolean isCurrentThreadSelectorRunner() {
208-
final NIOConnection c = (NIOConnection) context.getConnection();
209-
final SelectorRunner runner = c.getSelectorRunner();
210-
return (Thread.currentThread() == runner.getRunnerThread());
208+
private boolean isServiceThread() {
209+
return Threads.isService();
211210
}
212211

213212

0 commit comments

Comments
 (0)