Skip to content

Commit

Permalink
Merge pull request #350 from dmlloyd/ejbclient-300
Browse files Browse the repository at this point in the history
[EJBCLIENT-300] Forbid stateless to stateful conversion on older protocol versions
  • Loading branch information
fl4via authored May 9, 2018
2 parents bd671e6 + c29c011 commit e692a05
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 2 deletions.
6 changes: 6 additions & 0 deletions src/main/java/org/jboss/ejb/_private/Logs.java
Original file line number Diff line number Diff line change
Expand Up @@ -422,6 +422,12 @@ public interface Logs extends BasicLogger {
@Message(id = 510, value = "Failed to configure SSL context")
IOException failedToConfigureSslContext(@Cause Throwable cause);

@Message(id = 511, value = "Cannot automatically convert stateless EJB to stateful with this protocol version")
IllegalArgumentException cannotAddSessionID();

@Message(id = 512, value = "Server error (remote EJB is not stateful): %s")
EJBException ejbNotStateful(String serverMessage);

// Remote messages; no ID for brevity but should be translated

@Message(value = "No such EJB: %s")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -863,8 +863,7 @@ StatefulEJBLocator<T> getResult() throws Exception {
}
disassociateRemoteTxIfPossible(clientInvocationContext);
final String message = response.readUTF();
// todo: I don't think this is the best exception type for this case...
throw new IllegalArgumentException(message);
throw Logs.REMOTING.ejbNotStateful(message);
}
default: {
throw new EJBException("Invalid EJB creation response (id " + id + ")");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -765,6 +765,13 @@ final class RemotingInvocationRequest extends RemotingRequest implements Invocat
this.remaining = remaining;
}

public void convertToStateful(final SessionID sessionId) throws IllegalArgumentException, IllegalStateException {
if (version < 3) {
throw Logs.REMOTING.cannotAddSessionID();
}
super.convertToStateful(sessionId);
}

public Resolved getRequestContent(final ClassLoader classLoader) throws IOException, ClassNotFoundException {
classResolver.setClassLoader(classLoader);
int responseCompressLevel = 0;
Expand Down

0 comments on commit e692a05

Please sign in to comment.