Source:
<code>public HttpConnectionInterceptorContext interceptResponse(HttpConnectionInterceptorContext context) { if (shouldAttemptCookieRequest.get()) { HttpURLConnection connection = context.connection.getConnection(); try { boolean renewCookie = false; int statusCode = connection.getResponseCode(); if (statusCode == HttpURLConnection.HTTP_FORBIDDEN || statusCode == HttpURLConnection.HTTP_UNAUTHORIZED) { InputStream errorStream = connection.getErrorStream(); try { switch (statusCode) { case HttpURLConnection.HTTP_FORBIDDEN: String errorString = IOUtils.toString(errorStream, "UTF-8"); if (!errorString.matches("(?siu)" + ".*\\\"error\\\"\\s*:\\s*\\\"credentials_expired\\\".*")) { HttpConnectionInterceptorException toThrow = new HttpConnectionInterceptorException(errorString); toThrow.deserialize = true; throw toThrow; } else { renewCookie = true; } break; case HttpURLConnection.HTTP_UNAUTHORIZED: <START> IOUtils.toString(errorStream, "UTF-8"); <END> renewCookie = true; break; default: break; } } finally { IOUtils.closeQuietly(errorStream); } if (renewCookie) { logger.finest("Cookie was invalid attempt to get new cookie."); boolean success = requestCookie(connection.getURL(), context); if (success) { context.replayRequest = true; } else { context.replayRequest = false; shouldAttemptCookieRequest.set(false); } } } else { storeCookiesFromResponse(connection); } } catch (IOException e) { logger.log(Level.SEVERE, "Failed to get response code from request", e); } } return context; }</code><technical_language>Calling toString throwing result odd. this is consume errorStream. Out of interest findbugs warn discarding return values</technical_language>

Target:
public HttpConnectionInterceptorContext interceptResponse(HttpConnectionInterceptorContext context) { if (shouldAttemptCookieRequest.get()) { HttpURLConnection connection = context.connection.getConnection(); try { boolean renewCookie = false; int statusCode = connection.getResponseCode(); if (statusCode == HttpURLConnection.HTTP_FORBIDDEN || statusCode == HttpURLConnection.HTTP_UNAUTHORIZED) { InputStream errorStream = connection.getErrorStream(); try { String errorString = IOUtils.toString(errorStream, "UTF-8"); logger.log(Level.FINE, String.format(Locale.ENGLISH, "Intercepted " + "response %d %s", statusCode, errorString)); switch (statusCode) { case HttpURLConnection.HTTP_FORBIDDEN: if (!errorString.matches("(?siu)" + ".*\\\"error\\\"\\s*:\\s*\\\"credentials_expired\\\".*")) { HttpConnectionInterceptorException toThrow = new HttpConnectionInterceptorException(errorString); toThrow.deserialize = true; throw toThrow; } else { renewCookie = true; } break; case HttpURLConnection.HTTP_UNAUTHORIZED: renewCookie = true; break; default: break; } } finally { IOUtils.closeQuietly(errorStream); } if (renewCookie) { logger.finest("Cookie was invalid attempt to get new cookie."); boolean success = requestCookie(connection.getURL(), context); if (success) { context.replayRequest = true; } else { context.replayRequest = false; shouldAttemptCookieRequest.set(false); } } } else { storeCookiesFromResponse(connection); } } catch (IOException e) { logger.log(Level.SEVERE, "Error reading response code or body from request", e); } } return context; }