final String reason = logoutGet.getReason();
if (statusCode == HttpStatus.OK_200) {
LOG.info("Logout successful");
} else {
throw new SalesforceException(
String.format("Logout error, code: [%s] reason: [%s]",
statusCode, reason),
statusCode);
}
break;
case HttpExchange.STATUS_EXCEPTED:
final Throwable ex = logoutGet.getException();
throw new SalesforceException("Unexpected logout exception: " + ex.getMessage(), ex);
case HttpExchange.STATUS_CANCELLED:
throw new SalesforceException("Logout request CANCELLED!", null);
case HttpExchange.STATUS_EXPIRED:
throw new SalesforceException("Logout request TIMEOUT!", null);
default:
throw new SalesforceException("Unknow status: " + done, null);
}
} catch (SalesforceException e) {
throw e;
} catch (Exception e) {
String msg = "Logout error: " + e.getMessage();
throw new SalesforceException(msg, e);
} finally {
// reset session
accessToken = null;
instanceUrl = null;
// notify all session listeners of the new access token and instance url