apache / apache/grails-core

AsyncWebRequest IllegalStateException when using render method with just the status code

Open
#9,585 1 comment 0 reactions 0 assignees View on GitHub
info: workaround available type: minor
Dominant language
Groovy
Stars
2.9k
Forks
975
Avg merge
1d 22h
Merged PRs (30d)
92

Description

Rendering just the status code asynchronously throws IllegalStateException and also doubles the execution of the action (as you can see with 'hello' being printed out twice in the first image below).

In the synchronous version, rendering does not have the same problem and an object is returned with a predefined message attribute.

Adding a text argument to the asynchronous render call e.g. `render status: 404, text: ''` dispels the problem. I've not had the time to do a trace -- but rendering behavior is expected to be consistent whether synchronous or asynchronous.
### Async rendering

![async-render](https://cloud.githubusercontent.com/assets/4891894/12528494/a048643c-c1d2-11e5-9f52-63c8a2ff17ab.png)

```
Grails application running at http://localhost:8080 in environment: development
hello
hello
ERROR org.grails.web.errors.GrailsExceptionResolver - IllegalStateException occurred when processing request: [POST] /keys
Can't set AsyncWebRequest with concurrent handling in progress. Stacktrace follows:
java.lang.IllegalStateException: Can't set AsyncWebRequest with concurrent handling in progress
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) ~[na:1.8.0_51]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) ~[na:1.8.0_51]
at java.lang.Thread.run(Thread.java:745) [na:1.8.0_51]
```
### Synchronous rendering

![screen shot 2016-01-23 at 11 55 30 am](https://cloud.githubusercontent.com/assets/4891894/12528495/aa42f0c4-c1d2-11e5-9a46-9571e1c300fe.png)

Contributor guide

Open the contributing guide

Research direction

Start by reproducing the asynchronous `render status: 404` case described in the issue and compare it with the synchronous render behavior. Trace the `AsyncWebRequest` handling around the render call; done means the status-only asynchronous render does not throw `IllegalStateException` or execute the action twice, and behaves consistently with the synchronous version.

Written by the indexing model from the issue text.

Assessment

Tech stack
groovy
Domain
backend
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.