Skip to content

Commit

Permalink
[EJBCLIENT-262] Fix assertion issue
Browse files Browse the repository at this point in the history
  • Loading branch information
dmlloyd committed Sep 12, 2017
1 parent 179af90 commit 4ae9441
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,11 @@ public DiscoveryEJBClientInterceptor() {
}

public void handleInvocation(final EJBClientInvocationContext context) throws Exception {
if (context.getDestination() != null) {
// already discovered!
context.sendRequest();
return;
}
List<Throwable> problems = executeDiscovery(context);
try {
context.sendRequest();
Expand Down Expand Up @@ -131,6 +136,10 @@ public Object handleInvocationResult(final EJBClientInvocationContext context) t
}

public SessionID handleSessionCreation(final EJBSessionCreationInvocationContext context) throws Exception {
if (context.getDestination() != null) {
// already discovered!
return context.proceed();
}
List<Throwable> problems = executeDiscovery(context);
SessionID sessionID;
try {
Expand Down Expand Up @@ -222,10 +231,7 @@ Discovery getDiscovery() {
}

private List<Throwable> executeDiscovery(AbstractInvocationContext context) {
if (context.getDestination() != null) {
// Someone else discovered already!
return null;
}
assert context.getDestination() == null;
final EJBLocator<?> locator = context.getLocator();
final Affinity affinity = locator.getAffinity();
final Affinity weakAffinity = context.getWeakAffinity();
Expand Down
18 changes: 11 additions & 7 deletions src/main/java/org/jboss/ejb/client/NamingEJBClientInterceptor.java
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,15 @@ public final class NamingEJBClientInterceptor implements EJBClientInterceptor {
*/
public static final int PRIORITY = ClientInterceptorPriority.JBOSS_AFTER + 50;

private static final AttachmentKey<Boolean> SKIP_MISSING_TARGET = new AttachmentKey<>();

public NamingEJBClientInterceptor() {
}

public void handleInvocation(final EJBClientInvocationContext context) throws Exception {
final NamingProvider namingProvider = context.getProxyAttachment(EJBRootContext.NAMING_PROVIDER_ATTACHMENT_KEY);
if (namingProvider == null) {
if (namingProvider == null || context.getDestination() != null) {
context.putAttachment(SKIP_MISSING_TARGET, Boolean.TRUE);
context.sendRequest();
} else {
if (setDestination(context, namingProvider)) try {
Expand All @@ -67,14 +70,18 @@ public Object handleInvocationResult(final EJBClientInvocationContext context) t
try {
return context.getResult();
} catch (NoSuchEJBException | RequestSendFailedException e) {
processMissingTarget(context);
if (context.getAttachment(SKIP_MISSING_TARGET) != Boolean.TRUE) {
processMissingTarget(context);
}
throw e;
} finally {
context.removeAttachment(SKIP_MISSING_TARGET);
}
}

public SessionID handleSessionCreation(final EJBSessionCreationInvocationContext context) throws Exception {
final NamingProvider namingProvider = context.getAttachment(EJBRootContext.NAMING_PROVIDER_ATTACHMENT_KEY);
if (namingProvider == null) {
if (namingProvider == null || context.getDestination() != null) {
return context.proceed();
} else {
if (setDestination(context, namingProvider)) try {
Expand Down Expand Up @@ -123,11 +130,8 @@ private static boolean setDestination(final AbstractInvocationContext context, f

private void processMissingTarget(final AbstractInvocationContext context) {
final URI destination = context.getDestination();
assert destination != null;

if (destination == null) {
// nothing we can/should do.
return;
}
// Oops, we got some wrong information!
addBlackListedDestination(context, destination);

Expand Down

0 comments on commit 4ae9441

Please sign in to comment.