File tree Expand file tree Collapse file tree 1 file changed +5
-4
lines changed
src/main/java/com/dabsquared/gitlabjenkins/gitlab/api/impl Expand file tree Collapse file tree 1 file changed +5
-4
lines changed Original file line number Diff line number Diff line change @@ -208,15 +208,16 @@ private String getPrettyPrintResponseBody(ClientResponseContext responseContext)
208208 }
209209
210210 private String getResponseBody (ClientResponseContext context ) {
211- try (InputStream entityStream = context .getEntityStream ()) {
212- if (entityStream != null ) {
211+ // Cannot use try-with-resources here because the stream needs to remain open for reading later. Instead, we reset it when done.
212+ try {
213+ InputStream entityStream = context .getEntityStream ();
214+ if (entityStream != null && entityStream .markSupported ()) {
213215 byte [] bytes = IOUtils .toByteArray (entityStream );
214- context . setEntityStream ( new ByteArrayInputStream ( bytes ) );
216+ entityStream . reset ( );
215217 return new String (bytes );
216218 }
217219 } catch (IOException e ) {
218220 LOGGER .log (Level .SEVERE , "Failure during reading the response body" , e );
219- context .setEntityStream (new ByteArrayInputStream (new byte [0 ]));
220221 }
221222 return "" ;
222223 }
You can’t perform that action at this time.
0 commit comments