Jira Cloud plugin throws I/O Exception on POST request for "/rest/api/2/search"

Anuja weerakoon May 30, 2023

Hi,

We use a search query ( /rest/api/2/search) inside a Jira-cloud plugin to find a specific custom field value programmatically. But sometimes the Rest API Call throws IO Exception saying stream is closed (not happening every time). 

Rest API used for search query -> /rest/api/2/search 

Exception: 

com.myapp.security.logging.SecureException: I/O error on POST request for "https://myapp.atlassian.net/rest/api/2/search": stream is closed; nested exception is java.io.IOException: stream is closed
at org.springframework.web.client.RestTemplate.doExecute(RestTemplate.java:785)
at org.springframework.web.client.RestTemplate.execute(RestTemplate.java:711)
at org.springframework.web.client.RestTemplate.exchange(RestTemplate.java:602)
...
Caused by: java.io.IOException: stream is closed
at sun.net.www.protocol.http.HttpURLConnection$HttpInputStream.ensureOpen(HttpURLConnection.java:3429)
at sun.net.www.protocol.http.HttpURLConnection$HttpInputStream.read(HttpURLConnection.java:3434)
at java.io.FilterInputStream.read(FilterInputStream.java:83)
at java.io.PushbackInputStream.read(PushbackInputStream.java:139)
at org.springframework.web.client.MessageBodyClientHttpResponseWrapper.hasEmptyMessageBody(MessageBodyClientHttpResponseWrapper.java:101)
at org.springframework.web.client.HttpMessageConverterExtractor.extractData(HttpMessageConverterExtractor.java:90)
at org.springframework.web.client.RestTemplate$ResponseEntityResponseExtractor.extractData(RestTemplate.java:1037)
at org.springframework.web.client.RestTemplate$ResponseEntityResponseExtractor.extractData(RestTemplate.java:1020)
at org.springframework.web.client.RestTemplate.doExecute(RestTemplate.java:778)
... 20 common frames omitted

This exception is thrown only for specific host URLs and even for them, this exception is not thrown at every time.

Any idea or suggestions? 

1 answer

0 votes
Aron Gombas _Midori_
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
May 30, 2023

Well, generally speaking on cloud you have to embrace temporary failures like these. These happen and will happen all the time.

The usual pattern to resolve these is to implement some sort of retry strategy with exponential backoffs. Here is a theoretical write-up published by AWS: https://docs.aws.amazon.com/sdkref/latest/guide/feature-retry-behavior.html

Suggest an answer

Log in or Sign up to answer