File tree Expand file tree Collapse file tree 1 file changed +13
-15
lines changed
src/main/java/org/kohsuke/github/connector Expand file tree Collapse file tree 1 file changed +13
-15
lines changed Original file line number Diff line number Diff line change @@ -190,29 +190,27 @@ public InputStream bodyStream() throws IOException {
190
190
throw new IOException ("Response is closed" );
191
191
}
192
192
193
- if (avoidBufferedResponseStream ) {
194
- synchronized (this ) {
195
- if (inputStreamRead ) {
196
- throw new IOException ("Response is already consumed" );
197
- }
198
- inputStreamRead = true ;
199
- return wrapStream (rawBodyStream ());
200
- }
201
- }
202
-
203
193
synchronized (this ) {
194
+ InputStream body ;
204
195
if (!inputStreamRead ) {
205
- InputStream rawStream = rawBodyStream ();
206
- try (InputStream stream = wrapStream (rawStream )) {
207
- if (stream != null ) {
208
- inputBytes = IOUtils .toByteArray (stream );
196
+ body = wrapStream (rawBodyStream ());
197
+ if (!avoidBufferedResponseStream ) {
198
+ try (InputStream stream = rawStream ) {
199
+ if (stream != null ) {
200
+ inputBytes = IOUtils .toByteArray (stream );
201
+ }
209
202
}
210
203
}
211
204
inputStreamRead = true ;
205
+ if (avoidBufferedResponseStream ) {
206
+ return body ;
207
+ }
212
208
}
213
209
}
214
210
215
- if (inputBytes == null ) {
211
+ if (avoidBufferedResponseStream ) {
212
+ throw new IOException ("Response is already consumed" );
213
+ } else if (inputBytes == null ) {
216
214
throw new IOException ("Response body missing, stream null" );
217
215
}
218
216
You can’t perform that action at this time.
0 commit comments