diff --git a/core/src/main/java/org/jacorb/orb/Delegate.java b/core/src/main/java/org/jacorb/orb/Delegate.java index e65bd07..848f3c4 100644 --- a/core/src/main/java/org/jacorb/orb/Delegate.java +++ b/core/src/main/java/org/jacorb/orb/Delegate.java @@ -749,17 +749,16 @@ public final class Delegate * } **/ - if (piorLastFailed != null && piorLastFailed.equals(pior)) - { - //we've already failed to bind to the ior - throw new org.omg.CORBA.TRANSIENT(); - } - if (piorOriginal == null) { //keep original pior for fallback piorOriginal = _pior; } + else if (piorOriginal.equals(_pior) && piorLastFailed != null && piorLastFailed.equals(pior)) + { + //we've already failed to rebind to this pior + throw new org.omg.CORBA.TRANSIENT(); + } _pior = pior; @@ -1729,27 +1728,33 @@ public final class Delegate logger.debug("Delegate: falling back to original IOR"); } - //keep last failed ior to detect forwarding loops - piorLastFailed = getParsedIOR(); - if (piorOriginal.equals(piorLastFailed) && getParsedIOR().getProfiles().size() > 1) - { - if ( (useJacORBIMR && ! isJacORBImR) || (useTaoIMR) || getParsedIOR().isNameServiceIor() ) - { + ParsedIOR piorCurrent = getParsedIOR(); + Profile newProfile = null; + if (piorCurrent.equals(piorOriginal)) { + if ( piorCurrent.getProfiles().size() > 1 && ( (useJacORBIMR && ! isJacORBImR) || (useTaoIMR) || piorCurrent.isNameServiceIor() ) ) { if( logger.isDebugEnabled()) { logger.debug( "Delegate.try_rebind: binding to next profile <" + getParsedIOR().getTypeIdName() + ">"); } + newProfile = getParsedIOR().getNextEffectiveProfile(); + } + else + { + // already bound to the original, notify rebind failed + return false; + } + } - Profile newProfile = getParsedIOR().getNextEffectiveProfile(); + // save last failed ior to avoid loop due to forwarding to a + // same dead ior from the original one. + piorLastFailed = piorCurrent; - if (newProfile != null) - { - piorLastFailed = null; - randomMilliSecDelay(); - } - } + if (newProfile != null) + { + piorLastFailed = null; + randomMilliSecDelay(); } //rebind to the original ior