我们在GAE / J上部署了一个应用程序。在应用程序设置中,我们将'threadsafe'标志设置为true。还有一个过滤器,可以执行一些安全验证。最近我们对13000个实体进行了压力测试(在某些字段上存在唯一的约束以避免重复)。在测试期间我们遇到了一个奇怪的错误,实际上它是简单的超时异常。但真正出乎意料的是与此请求对应的日志条目:
2012-08-17 16:33:08.279 33579ms 0kb
ms = 33580 cpu_ms = 34 api_cpu_ms = 12 instance = 00c61b117cf644f05e7a39e92b13fdbac6f31cad
I 2012-08-17 16:32:39.231过滤器doFilter:...
I 2012-08-17 16:32:39.320 completeResponse:打印回复正文
I 2012-08-17 16:33:08.262过滤器doFilter:...
W 2012-08-17 16:33:08.275由于数据重复导致异常
这一切都是一个日志条目。我不知道如何找出这种行为的原因..过滤器中的日志消息是第一行代码,它记录是否通过HTTPS发送请求...也许你有一些想法?
[UPDATE。过滤源代码]
public class AuthorizationFilter implements Filter
{
private static final Logger logger = Logger.getLogger(AuthorizationFilter.class.getSimpleName() );
@SuppressWarnings( "unused" )
private FilterConfig filterConfig = null;
@Override
public void destroy()
{
this.filterConfig = null;
}
@Override
public void init( FilterConfig filterConfig ) throws ServletException
{
this.filterConfig = filterConfig;
}
@Override
public void doFilter( ServletRequest request, ServletResponse response, FilterChain filterChain ) throws IOException, ServletException
{
UserService userService = UserServiceFactory.getUserService();
HttpServletRequest servletRequest = (HttpServletRequest) request;
String token = servletRequest.getHeader( "token" );
logger.info( "Request is secure := " + servletRequest.isSecure());
if(userService.isUserLoggedIn())
{
try
{
User user = ...;
//IF OK
servletRequest.setAttribute( "user" , user );
}
catch ( Exception exception )
{
logger.log( Level.WARNING,"Exception : ",exception);
throw new ServiceException( exception );
}
filterChain.doFilter(request, response);
}
else if(null != token && !token.isEmpty())
{
try
{
User user = ...;
//IF OK
servletRequest.setAttribute( "user" , user );
filterChain.doFilter(request, response);
}
catch(Exception exception)
{
logger.log( Level.WARNING, "Exception : ", exception );
throw new ServiceException( ExceptionType.UnknownError );
}
}
else
{
servletResponse.setStatus( 401 );
}
}
}
提前谢谢。
彼得