Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Removed illegal call to Throwable#initCause #312

Merged
merged 2 commits into from
Aug 21, 2013
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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,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<Result> action, Result result) throws ActionException,
ServiceException {
ServiceException {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

formatting?


if (action.isSecured() && !cookieMatch(cookieSentByRPC)) {
String message = xsrfAttackMessage + " While undoing action: " + action.getClass().getName();
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