mirror of
https://github.com/eclipse-sailing-analytics/sailing-analytics.git
synced 2026-11-15 06:49:56 +00:00
search for Shiro exception in SerializationException message to improve error response to client
Change-Id: Id7925ce44ee4737c15d5c765a2bbf8de6bdeb8b0
This commit is contained in:
1 parent
e3a5ab9957
commit
e6ca196556
1 file changed
+5
-3
+5
-3
@@ -6,6 +6,7 @@ import javax.servlet.ServletContext;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import com.google.gwt.user.client.rpc.SerializationException;
|
||||
import com.google.gwt.user.server.rpc.RPCServletUtils;
|
||||
import com.google.gwt.user.server.rpc.RemoteServiceServlet;
|
||||
import com.google.gwt.user.server.rpc.SerializationPolicy;
|
||||
@@ -38,7 +39,8 @@ public abstract class ProxiedRemoteServiceServlet extends RemoteServiceServlet {
|
||||
|
||||
@Override
|
||||
protected void doUnexpectedFailure(Throwable e) {
|
||||
if (e.getCause().getClass().getName().matches("org\\.apache\\.shiro\\.authz\\..*[Aa]uth.*Exception")) {
|
||||
if ((e.getCause() != null && e.getCause().getClass().getName().matches("org\\.apache\\.shiro\\.authz\\..*[Aa]uth.*Exception")) ||
|
||||
(e instanceof SerializationException && e.getMessage().matches("Type 'org\\.apache\\.shiro\\.authz\\..*[Aa]uth.*Exception' was not included in the set of types which can be serialized.*"))) {
|
||||
final HttpServletResponse servletResponse = getThreadLocalResponse();
|
||||
try {
|
||||
servletResponse.reset();
|
||||
@@ -47,12 +49,12 @@ public abstract class ProxiedRemoteServiceServlet extends RemoteServiceServlet {
|
||||
}
|
||||
ServletContext servletContext = getServletContext();
|
||||
RPCServletUtils.writeResponseForUnexpectedFailure(servletContext, servletResponse, e);
|
||||
servletContext.log("Exception while dispatching incoming RPC call", e.getCause());
|
||||
servletContext.log("Exception while dispatching incoming RPC call", e.getCause()==null?e:e.getCause());
|
||||
try {
|
||||
servletResponse.setContentType("text/plain");
|
||||
servletResponse.setStatus(HttpServletResponse.SC_UNAUTHORIZED);
|
||||
try {
|
||||
servletResponse.getOutputStream().write(e.getCause().getLocalizedMessage().getBytes("UTF-8"));
|
||||
servletResponse.getOutputStream().write((e.getCause()==null?e:e.getCause()).getLocalizedMessage().getBytes("UTF-8"));
|
||||
} catch (IllegalStateException ex) {
|
||||
// Handle the (unexpected) case where getWriter() was previously used
|
||||
servletResponse.getWriter().write("Couldn't write exception");
|
||||
|
||||
Reference in new issue
Block a user