Repository: camel Updated Branches: refs/heads/camel-2.17.x 4f2aafed8 -> 1f7abfcb5
CAMEL-10238: Refresh oauth token on 401 in handshake error Project: http://git-wip-us.apache.org/repos/asf/camel/repo Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/1f7abfcb Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/1f7abfcb Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/1f7abfcb Branch: refs/heads/camel-2.17.x Commit: 1f7abfcb586b68e19fea28331f69dd35e6f12145 Parents: 4f2aafe Author: Dhiraj Bokde <dhira...@yahoo.com> Authored: Fri Sep 2 10:39:13 2016 -0700 Committer: Dhiraj Bokde <dhira...@yahoo.com> Committed: Fri Sep 2 10:43:51 2016 -0700 ---------------------------------------------------------------------- .../internal/streaming/SubscriptionHelper.java | 25 +++++++++++--------- 1 file changed, 14 insertions(+), 11 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/camel/blob/1f7abfcb/components/camel-salesforce/camel-salesforce-component/src/main/java/org/apache/camel/component/salesforce/internal/streaming/SubscriptionHelper.java ---------------------------------------------------------------------- diff --git a/components/camel-salesforce/camel-salesforce-component/src/main/java/org/apache/camel/component/salesforce/internal/streaming/SubscriptionHelper.java b/components/camel-salesforce/camel-salesforce-component/src/main/java/org/apache/camel/component/salesforce/internal/streaming/SubscriptionHelper.java index cbe84ab..9eb75ae 100644 --- a/components/camel-salesforce/camel-salesforce-component/src/main/java/org/apache/camel/component/salesforce/internal/streaming/SubscriptionHelper.java +++ b/components/camel-salesforce/camel-salesforce-component/src/main/java/org/apache/camel/component/salesforce/internal/streaming/SubscriptionHelper.java @@ -117,6 +117,20 @@ public class SubscriptionHelper extends ServiceSupport { handshakeError = (String) message.get(ERROR_FIELD); handshakeException = getFailure(message); + + if (handshakeError != null) { + // refresh oauth token, if it's a 401 error + if (handshakeError.startsWith("401::")) { + try { + LOG.info("Refreshing OAuth token..."); + session.login(session.getAccessToken()); + LOG.info("Refreshed OAuth token for re-handshake"); + } catch (SalesforceException e) { + LOG.error("Error renewing OAuth token on 401 error: " + e.getMessage(), e); + } + } + } + // restart if handshake fails for any reason restartClient(); @@ -140,17 +154,6 @@ public class SubscriptionHelper extends ServiceSupport { connectError = (String) message.get(ERROR_FIELD); connectException = getFailure(message); - if (connectError != null) { - // refresh oauth token, if it's a 403 error - if (connectError.startsWith("403::")) { - try { - session.login(null); - } catch (SalesforceException e) { - LOG.error("Error renewing OAuth token on Connect 403: " + e.getMessage(), e); - } - } - } - } else if (reconnecting) { reconnecting = false;