Skip to content

Commit

Permalink
Merge pull request ArcBees#312 from ArcBees/cv_fix_illegal_exception_…
Browse files Browse the repository at this point in the history
…state

Removed illegal call to Throwable#initCause
  • Loading branch information
Christopher Viel committed Aug 21, 2013
2 parents aa34209 + 656f352 commit f0880e1
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 27 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -163,9 +163,7 @@ private <A extends Action<R>, 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);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -84,28 +85,26 @@ 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());
}
}

Expand All @@ -125,18 +124,15 @@ public void undo(String cookieSentByRPC, Action<Result> 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());
}
}

Expand All @@ -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;
}

Expand Down

0 comments on commit f0880e1

Please sign in to comment.