大多数请求上的码头错误

大多数请求上的码头错误

本文介绍了" IllegalArgumentException:!utf8"大多数请求上的码头错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我今天对自己的应用程序做了一些小改动,突然有90%的请求在这一行中抛出错误:

I made a small change to my app today, and all of a sudden 90% of our requests are throwing errors on this line:

private void serve(HttpServletRequest req, HttpServletResponse resp) {
    String bundle = req.getParameter("bundle");

我不知道该怎么做 - Jetty的查询请求解析器中存在异常。这些请求没有什么不同之处,我不认为有任何非UTF8字符,除非它们不可打印或其他东西。

I don't know what to do – the exception is deep within Jetty's query request parser. There's nothing unusual about the requests, and I don't think there's any non-UTF8 characters, unless they are unprintable or something.

/sync
java.lang.IllegalArgumentException: !utf8
    at org.mortbay.util.Utf8StringBuffer.append(Utf8StringBuffer.java:121)
    at org.mortbay.util.UrlEncoded.decodeUtf8To(UrlEncoded.java:458)
    at org.mortbay.util.UrlEncoded.decodeTo(UrlEncoded.java:503)
    at org.mortbay.jetty.Request.extractParameters(Request.java:1565)
    at org.mortbay.jetty.Request.getParameter(Request.java:858)
    at javax.servlet.ServletRequestWrapper.getParameter(ServletRequestWrapper.java:158)
    at javax.servlet.ServletRequestWrapper.getParameter(ServletRequestWrapper.java:158)
    at com.keithlea.whamserver.sync.ServerSyncServlet.serve(ServerSyncServlet.java:169)
    at com.keithlea.whamserver.sync.ServerSyncServlet.doGet(ServerSyncServlet.java:77)
    at com.keithlea.whamserver.sync.ServerSyncServlet.doPost(ServerSyncServlet.java:67)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:637)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
    at com.google.inject.servlet.ServletDefinition.doServiceImpl(ServletDefinition.java:278)
    at com.google.inject.servlet.ServletDefinition.doService(ServletDefinition.java:268)
    at com.google.inject.servlet.ServletDefinition.service(ServletDefinition.java:180)
    at com.google.inject.servlet.ManagedServletPipeline.service(ManagedServletPipeline.java:93)
    at com.google.inject.servlet.ManagedFilterPipeline.dispatch(ManagedFilterPipeline.java:120)
    at com.google.inject.servlet.GuiceFilter$1.call(GuiceFilter.java:134)
    at com.google.inject.servlet.GuiceFilter$1.call(GuiceFilter.java:131)
    at com.google.inject.servlet.GuiceFilter$Context.call(GuiceFilter.java:208)
    at com.google.inject.servlet.GuiceFilter.doFilter(GuiceFilter.java:131)
    at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
    at com.googlecode.objectify.cache.AsyncCacheFilter.doFilter(AsyncCacheFilter.java:59)
    at com.googlecode.objectify.ObjectifyFilter.doFilter(ObjectifyFilter.java:49)
    at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
    at com.keithlea.whamserver.EditorDomainFilter.doFilter(EditorDomainFilter.java:90)
    at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
    at com.google.apphosting.utils.servlet.ParseBlobUploadFilter.doFilter(ParseBlobUploadFilter.java:125)
    at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
    at com.google.apphosting.runtime.jetty.SaveSessionFilter.doFilter(SaveSessionFilter.java:35)
    at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
    at com.google.apphosting.utils.servlet.JdbcMySqlConnectionCleanupFilter.doFilter(JdbcMySqlConnectionCleanupFilter.java:60)
    at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
    at com.google.apphosting.utils.servlet.TransactionCleanupFilter.doFilter(TransactionCleanupFilter.java:43)
    at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
    at org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:388)
    at org.mortbay.jetty.security.SecurityHandler.handle(SecurityHandler.java:216)
    at org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:182)
    at org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:765)
    at org.mortbay.jetty.webapp.WebAppContext.handle(WebAppContext.java:418)
    at com.google.apphosting.runtime.jetty.AppVersionHandlerMap.handle(AppVersionHandlerMap.java:254)
    at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
    at org.mortbay.jetty.Server.handle(Server.java:326)
    at org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:542)
    at org.mortbay.jetty.HttpConnection$RequestHandler.headerComplete(HttpConnection.java:923)
    at com.google.apphosting.runtime.jetty.RpcRequestParser.parseAvailable(RpcRequestParser.java:76)
    at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:404)
    at com.google.apphosting.runtime.jetty.JettyServletEngineAdapter.serviceRequest(JettyServletEngineAdapter.java:146)
    at com.google.apphosting.runtime.JavaRuntime$RequestRunnable.run(JavaRuntime.java:527)
    at com.google.tracing.TraceContext$TraceContextRunnable.runInContext(TraceContext.java:437)
    at com.google.tracing.TraceContext$TraceContextRunnable$1.run(TraceContext.java:444)
    at com.google.tracing.CurrentContext.runInContext(CurrentContext.java:220)
    at com.google.tracing.TraceContext$AbstractTraceContextCallback.runInInheritedContextNoUnref(TraceContext.java:308)
    at com.google.tracing.TraceContext$AbstractTraceContextCallback.runInInheritedContext(TraceContext.java:300)
    at com.google.tracing.TraceContext$TraceContextRunnable.run(TraceContext.java:441)
    at com.google.apphosting.runtime.ThreadGroupPool$PoolEntry.run(ThreadGroupPool.java:251)
    at java.lang.Thread.run(Thread.java:745)


推荐答案

这要感谢。问题是这是一个POST请求,并且HttpServletRequest试图将输入数据解析为查询字符串。我可以通过首先将查询字符串读入缓冲区来防止这种情况。以下是新代码:

I fixed this thanks to JoakimErdfelt. The issue is that this is a POST request, and the HttpServletRequest is trying to parse the input data as a query string. I can prevent that by reading the query string into a buffer first. Here's the new code:

private void serve(HttpServletRequest req, HttpServletResponse resp) {
    UserInput input = readUserInput(req.getInputStream());
    String bundle = req.getParameter("bundle");

这似乎已经完全解决了问题。

This appears to have fixed the issue completely.

这篇关于" IllegalArgumentException:!utf8"大多数请求上的码头错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-05 23:10