# I'm getting a Blocking Operation related exception when running search using Java

**URL:** <https://discuss.elastic.co/t/im-getting-a-blocking-operation-related-exception-when-running-search-using-java/89765>\
**Category:** Elasticsearch\
**Created:** [June 16, 2017, 7:01pm UTC](https://discuss.elastic.co/t/im-getting-a-blocking-operation-related-exception-when-running-search-using-java/89765 "2017-06-16T19:01:13Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Gregory\_Berezowsky](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/gregory_berezowsky/32/19218_2.png) [@Gregory\_Berezowsky](https://discuss.elastic.co/u/Gregory_Berezowsky)\
**Post date:** [June 16, 2017, 7:01pm UTC](https://discuss.elastic.co/t/im-getting-a-blocking-operation-related-exception-when-running-search-using-java/89765/1 "2017-06-16T19:01:13Z")

</div>

I searched past issues, but I can't find any reference to this one.

I'm upgrading a 1.4.2 solution to a 2.4.4 (on the way to 5.x).

The offending operation is basically:

> QueryBuilder query = ...  
> Client client = Node.client(); // Same behaviour with transport client  
> client.prepareSearch("myindex").setVersion(true).setQuery(query).

The exception I'm getting is:

> ```
> Caused by: java.lang.AssertionError: Expected current thread [Thread[task-scheduler-6,5,main]] to not be the scheduler thread. Reason: [Blocking operation]
> at org.elasticsearch.threadpool.ThreadPool.assertNotScheduleThread(ThreadPool.java:1089)
> at org.elasticsearch.common.util.concurrent.BaseFuture.get(BaseFuture.java:119)
> at org.elasticsearch.action.support.AdapterActionFuture.actionGet(AdapterActionFuture.java:42)
> at org.elasticsearch.action.ActionRequestBuilder.get(ActionRequestBuilder.java:64)
> 
> ```

I've looked at the ES source and I see that the get operation should, indeed, not be running on a scheduler thread, but I'm unclear why this is happening or how to avoid it.

---

<div class="post-metadata">

**Author:** ![Gregory\_Berezowsky](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/gregory_berezowsky/32/19218_2.png) [@Gregory\_Berezowsky](https://discuss.elastic.co/u/Gregory_Berezowsky)\
**Post date:** [June 16, 2017, 8:14pm UTC](https://discuss.elastic.co/t/im-getting-a-blocking-operation-related-exception-when-running-search-using-java/89765/2 "2017-06-16T20:14:35Z")

</div>

I didn't mention I'm running this within the spring framework. On looking closer at how ES determines whether the scheduler thread is the current thread (sub-string check), I now believe this is a Spring/ES conflict. I'll drop a custom task scheduler in spring to rename it.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [July 14, 2017, 8:14pm UTC](https://discuss.elastic.co/t/im-getting-a-blocking-operation-related-exception-when-running-search-using-java/89765/3 "2017-07-14T20:14:48Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
