From 033875c82579be8313296c08c867ff76fea0f11f Mon Sep 17 00:00:00 2001 From: Christopher Viel Date: Thu, 15 Aug 2013 13:22:39 -0400 Subject: [PATCH 1/2] Removed illegal call to Throwable#initCause --- .../dispatch/server/AbstractDispatchImpl.java | 4 +- .../server/AbstractDispatchServiceImpl.java | 46 +++++++++---------- 2 files changed, 22 insertions(+), 28 deletions(-) diff --git a/gwtp-core/gwtp-dispatch-server/src/main/java/com/gwtplatform/dispatch/server/AbstractDispatchImpl.java b/gwtp-core/gwtp-dispatch-server/src/main/java/com/gwtplatform/dispatch/server/AbstractDispatchImpl.java index 9b1eab9f90..698cf4449a 100644 --- a/gwtp-core/gwtp-dispatch-server/src/main/java/com/gwtplatform/dispatch/server/AbstractDispatchImpl.java +++ b/gwtp-core/gwtp-dispatch-server/src/main/java/com/gwtplatform/dispatch/server/AbstractDispatchImpl.java @@ -163,9 +163,7 @@ private , R extends Result> R doExecute(A action, } catch (Exception e) { String newMessage = "Service exception executing action \"" + action.getClass().getSimpleName() + "\", " + "" + e.toString(); - ServiceException rethrown = new ServiceException(newMessage); - rethrown.initCause(e); - throw rethrown; + throw new ServiceException(newMessage, e); } } diff --git a/gwtp-core/gwtp-dispatch-server/src/main/java/com/gwtplatform/dispatch/server/AbstractDispatchServiceImpl.java b/gwtp-core/gwtp-dispatch-server/src/main/java/com/gwtplatform/dispatch/server/AbstractDispatchServiceImpl.java index 19b7c4d904..845713e809 100644 --- a/gwtp-core/gwtp-dispatch-server/src/main/java/com/gwtplatform/dispatch/server/AbstractDispatchServiceImpl.java +++ b/gwtp-core/gwtp-dispatch-server/src/main/java/com/gwtplatform/dispatch/server/AbstractDispatchServiceImpl.java @@ -46,21 +46,22 @@ * @see com.gwtplatform.dispatch.server.guice.DispatchServiceImpl */ public abstract class AbstractDispatchServiceImpl extends RemoteServiceServlet implements DispatchService { - - private static final String noSecurityCookieMessage = "You have to define a security cookie in order to use " + - "secured actions. See com.gwtplatform.dispatch.shared.SecurityCookie for details."; - private static final long serialVersionUID = -4753225025940949024L; + private static final String noSecurityCookieMessage = "You have to define a security cookie in order to use " + + "secured actions. See com.gwtplatform.dispatch.shared" + + ".SecurityCookie for details."; private static final String xsrfAttackMessage = "Cookie provided by RPC doesn't match request cookie, " + - "aborting action, possible XSRF attack. (Maybe you forgot to set the security cookie?)"; + "aborting action, possible XSRF attack. (Maybe you forgot to set " + + "the security cookie?)"; protected final Dispatch dispatch; protected final Logger logger; protected RequestProvider requestProvider; - protected AbstractDispatchServiceImpl(final Logger logger, final Dispatch dispatch, - RequestProvider requestProvider) { + protected AbstractDispatchServiceImpl(Logger logger, + Dispatch dispatch, + RequestProvider requestProvider) { this.logger = logger; this.dispatch = dispatch; this.requestProvider = requestProvider; @@ -84,34 +85,32 @@ public Result execute(String cookieSentByRPC, Action action) throws ActionExc return dispatch.execute(action); } catch (ActionException e) { if (logger.isLoggable(Level.WARNING)) { - logger.log(Level.WARNING, "Action exception while executing " + action.getClass().getName() + ": " + - e.getMessage(), e); + String newMessage = "Action exception while executing " + action.getClass().getName() + ": " + + e.getMessage(); + logger.log(Level.WARNING, newMessage, e); } - e.initCause(null); - throw e; + throw new ActionException(e.getMessage()); } catch (ServiceException e) { if (logger.isLoggable(Level.WARNING)) { logger.log(Level.WARNING, "Service exception while executing " + action.getClass().getName() + ": " + - e.getMessage(), e); + e.getMessage(), e); } - e.initCause(null); - throw e; + throw new ServiceException(e.getMessage()); } catch (RuntimeException e) { if (logger.isLoggable(Level.WARNING)) { logger.log(Level.WARNING, "Unexpected exception while executing " + action.getClass().getName() + ": " + - "" + e.getMessage(), e); + "" + e.getMessage(), e); } - e.initCause(null); - throw new ServiceException(e); + throw new ServiceException(e.getMessage()); } } @Override public void undo(String cookieSentByRPC, Action action, Result result) throws ActionException, - ServiceException { + ServiceException { if (action.isSecured() && !cookieMatch(cookieSentByRPC)) { String message = xsrfAttackMessage + " While undoing action: " + action.getClass().getName(); @@ -125,18 +124,15 @@ public void undo(String cookieSentByRPC, Action action, Result result) t } catch (ActionException e) { logger.warning("Action exception while undoing " + action.getClass().getName() + ": " + e.getMessage()); - e.initCause(null); - throw e; + throw new ActionException(e.getMessage()); } catch (ServiceException e) { logger.warning("Service exception while undoing " + action.getClass().getName() + ": " + e.getMessage()); - e.initCause(null); - throw e; + throw new ServiceException(e.getMessage()); } catch (RuntimeException e) { logger.warning("Unexpected exception while undoing " + action.getClass().getName() + ": " + e.getMessage()); - e.initCause(null); - throw new ServiceException(e); + throw new ServiceException(e.getMessage()); } } @@ -159,7 +155,7 @@ private boolean cookieMatch(String cookieSentByRPC) throws ServiceException { if (cookieSentByRPC == null) { logger.info("No cookie sent by client in RPC. (Did you forget to bind the security cookie client-side? Or" + - " it could be an attack.)"); + " it could be an attack.)"); return false; } From 16757cb24141ffc74d3d92d1ba9399151a471d26 Mon Sep 17 00:00:00 2001 From: Christopher Viel Date: Thu, 15 Aug 2013 15:10:20 -0400 Subject: [PATCH 2/2] Format --- .../dispatch/server/AbstractDispatchServiceImpl.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gwtp-core/gwtp-dispatch-server/src/main/java/com/gwtplatform/dispatch/server/AbstractDispatchServiceImpl.java b/gwtp-core/gwtp-dispatch-server/src/main/java/com/gwtplatform/dispatch/server/AbstractDispatchServiceImpl.java index 845713e809..81f596a154 100644 --- a/gwtp-core/gwtp-dispatch-server/src/main/java/com/gwtplatform/dispatch/server/AbstractDispatchServiceImpl.java +++ b/gwtp-core/gwtp-dispatch-server/src/main/java/com/gwtplatform/dispatch/server/AbstractDispatchServiceImpl.java @@ -110,7 +110,7 @@ public Result execute(String cookieSentByRPC, Action action) throws ActionExc @Override public void undo(String cookieSentByRPC, Action action, Result result) throws ActionException, - ServiceException { + ServiceException { if (action.isSecured() && !cookieMatch(cookieSentByRPC)) { String message = xsrfAttackMessage + " While undoing action: " + action.getClass().getName();