Source:
<code>public void execute(final AccountAuthenticator aa) throws URISyntaxException, UnsupportedEncodingException { AuthenticateAccountStageDelegate callbackDelegate = new AuthenticateAccountStageDelegate() { @Override public void handleSuccess(boolean isSuccess) { aa.isSuccess = isSuccess; aa.runNextStage(); } @Override public void handleFailure(HttpResponse response) { Logger.debug(LOG_TAG, "handleFailure"); aa.abort(response.toString(), new Exception(response.getStatusLine().getStatusCode() + " error.")); try { <START> BufferedReader reader = new BufferedReader(new InputStreamReader(response.getEntity().getContent(), "UTF-8")); <END> Logger.warn(LOG_TAG, "content: " + reader.readLine()); SyncResourceDelegate.consumeReader(reader); reader.close(); SyncResourceDelegate.consumeEntity(response.getEntity()); } catch (IllegalStateException e) { Logger.debug(LOG_TAG, "Error reading content.", e); } catch (IOException e) { Logger.debug(LOG_TAG, "Error reading content.", e); } } @Override public void handleError(Exception e) { Logger.debug(LOG_TAG, "handleError", e); aa.abort("HTTP failure.", e); } }; String authHash = Base64.encodeToString((aa.usernameHash + ":" + aa.password).getBytes(), Base64.DEFAULT); String authRequestUrl = aa.authServer + Constants.AUTH_SERVER_VERSION + aa.usernameHash + "/" + Constants.AUTH_SERVER_SUFFIX; authenticateAccount(callbackDelegate, authRequestUrl, authHash); }</code><technical_language>Firstly, want check for null. HttpEntity entity = response.getEntity(); if (entity == null) { // cleanup needed. return; } Secondly, a RuntimeException here. Add a clause: } catch (RuntimeException e) { Logger.warn(LOG_TAG, "Unexpected exception.", e); // TODO: get a handle HttpGet itself, call .abort() it. }</technical_language>

Target:
public void execute(final AccountAuthenticator aa) throws URISyntaxException, UnsupportedEncodingException { AuthenticateAccountStageDelegate callbackDelegate = new AuthenticateAccountStageDelegate() { @Override public void handleSuccess(boolean isSuccess) { aa.isSuccess = isSuccess; aa.runNextStage(); } @Override public void handleFailure(HttpResponse response) { Logger.debug(LOG_TAG, "handleFailure"); aa.abort(response.toString(), new Exception(response.getStatusLine().getStatusCode() + " error.")); if (response.getEntity() == null) { return; } try { BufferedReader reader = new BufferedReader(new InputStreamReader(response.getEntity().getContent(), "UTF-8")); Logger.warn(LOG_TAG, "content: " + reader.readLine()); SyncResourceDelegate.consumeReader(reader); } catch (IllegalStateException e) { Logger.debug(LOG_TAG, "Error reading content.", e); } catch (RuntimeException e) { Logger.debug(LOG_TAG, "Unexpected exception.", e); if (httpRequest != null) { httpRequest.abort(); } } catch (IOException e) { Logger.debug(LOG_TAG, "Error reading content.", e); } } @Override public void handleError(Exception e) { Logger.debug(LOG_TAG, "handleError", e); aa.abort("HTTP failure.", e); } }; String authHash = Base64.encodeToString((aa.usernameHash + ":" + aa.password).getBytes(), Base64.DEFAULT); String authRequestUrl = aa.authServer + Constants.AUTH_SERVER_VERSION + aa.usernameHash + "/" + Constants.AUTH_SERVER_SUFFIX; authenticateAccount(callbackDelegate, authRequestUrl, authHash); }