Skip to content

Commit

Permalink
[WFLY-18658] Fix i18n of exception messages in ejb3
Browse files Browse the repository at this point in the history
  • Loading branch information
soul2zimate committed Oct 17, 2023
1 parent aad5592 commit 20e7e84
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
package org.jboss.as.ejb3.component.interceptors;

import java.rmi.NoSuchObjectException;
import java.rmi.RemoteException;

import jakarta.ejb.CreateException;
import jakarta.ejb.EJBException;
Expand All @@ -20,6 +19,7 @@
import jakarta.transaction.TransactionRolledbackException;

import org.jboss.as.ejb3.component.EJBComponentUnavailableException;
import org.jboss.as.ejb3.logging.EjbLogger;
import org.jboss.invocation.ImmediateInterceptorFactory;
import org.jboss.invocation.Interceptor;
import org.jboss.invocation.InterceptorContext;
Expand Down Expand Up @@ -83,7 +83,7 @@ public Object processInvocation(final InterceptorContext context) throws Excepti
if (createException != null) {
throw createException;
}
throw new RemoteException("Invocation failed", e);
throw EjbLogger.ROOT_LOGGER.invocationFailed(e);
}
}
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -440,11 +440,11 @@ private SecurityIdentity authenticate(final Principal principal, final char[] cr
return context.getAuthorizedIdentity();
} else {
context.fail();
throw new SecurityException("Authorization failed");
throw EjbLogger.ROOT_LOGGER.authenticationFailed();
}
} else {
context.fail();
throw new SecurityException("Authentication failed");
throw EjbLogger.ROOT_LOGGER.authenticationFailed();
}
} catch (IllegalArgumentException | IllegalStateException | RealmUnavailableException e) {
context.fail();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ protected final TransactionManager getTransactionManager() {
@Override
public void release() {
if (released.getAndSet(true))
throw new IllegalStateException("Message endpoint " + this + " has already been released");
throw EjbLogger.ROOT_LOGGER.messageEndpointAlreadyReleasedISE(this);

// TODO: tidy up outstanding delivery

Expand Down
12 changes: 12 additions & 0 deletions ejb3/src/main/java/org/jboss/as/ejb3/logging/EjbLogger.java
Original file line number Diff line number Diff line change
Expand Up @@ -3242,4 +3242,16 @@ public interface EjbLogger extends BasicLogger {
@LogMessage(level = WARN)
@Message(id = 532, value = "Database detected from configuration is: '%s'. If this is incorrect, please specify the correct database.")
void unknownDatabaseName(String name);

@Message(id = 533, value = "Invocation failed")
RemoteException invocationFailed(@Cause Exception e);

@Message(id = 534, value = "Authentication failed")
SecurityException authenticationFailed();

@Message(id = 535, value = "Message endpoint %s has already been released")
IllegalStateException messageEndpointAlreadyReleasedISE(MessageEndpoint messageEndpoint);

@Message(id = 536, value = "Unsupported EJB receiver protocol %s")
IllegalArgumentException unsupportedEJBReceiverProtocol(String uriScheme);
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
package org.jboss.as.ejb3.remote;

import org.jboss.as.ejb3.deployment.DeploymentRepository;
import org.jboss.as.ejb3.logging.EjbLogger;
import org.jboss.ejb.client.EJBReceiver;
import org.jboss.ejb.client.EJBReceiverContext;
import org.jboss.ejb.client.EJBTransportProvider;
Expand Down Expand Up @@ -68,7 +69,7 @@ public EJBReceiver getReceiver(final EJBReceiverContext receiverContext, final S
break;
}
default: {
throw new IllegalArgumentException("Unsupported EJB receiver protocol " + uriScheme);
throw EjbLogger.ROOT_LOGGER.unsupportedEJBReceiverProtocol(uriScheme);
}
}
return receiver;
Expand Down

0 comments on commit 20e7e84

Please sign in to comment.