“抛出:IllegalArgumentException:UTF8”在大多数请求码头错误(“Ille

2019-10-22 12:30发布

我今天做了小改动,以我的应用程序,以及我们所有的请求的突然90%是在这一行引发错误:

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

我不知道该怎么办 - 例外的是深Jetty的查询请求语法分析程序中。 有什么不寻常的有关要求的,我不认为有任何非UTF8字符,除非它们是不可打印什么的。

/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)

Answer 1:

我解决了这个感谢JoakimErdfelt 。 问题是,这是一个POST请求,HttpServletRequest的试图解析输入数据作为查询字符串。 我可以防止通过读取查询字符串到缓冲区第一。 下面是新的代码:

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

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



文章来源: “IllegalArgumentException: !utf8” Jetty error on most requests