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

NumberFormatException with HttpHeader.LAST_MODIFIED #10574

Closed
janitza-bjag opened this issue Sep 25, 2023 · 6 comments
Closed

NumberFormatException with HttpHeader.LAST_MODIFIED #10574

janitza-bjag opened this issue Sep 25, 2023 · 6 comments

Comments

@janitza-bjag
Copy link

Jetty version(s)
12.0.1

Jetty Environment
core, ee8

Java version/vendor
17.0.8

Question
I have a simple WAR and want to server a static html file. I get a NumberFormatException because the DateHeader field contains a formatted Date instead of an expected String with milliseconds ... Can anyone help me out?

[INFO] 07:50:10.545   WARN  o.e.jetty.ee8.nested.ResourceService  - Failed to serve resource: /doc/index.html java.lang.NumberFormatException: For input string: "Mon, 25 Sep 2023 05:49:32 GMT"
[INFO] 	at java.base/java.lang.NumberFormatException.forInputString(NumberFormatException.java:67)
[INFO] 	at java.base/java.lang.Long.parseLong(Long.java:711)
[INFO] 	at java.base/java.lang.Long.parseLong(Long.java:836)
[INFO] 	at org.eclipse.jetty.http.HttpField.getLongValue(HttpField.java:461)
[INFO] 	at org.eclipse.jetty.ee8.nested.Response.putHeaders(Response.java:1185)
[INFO] 	at org.eclipse.jetty.ee8.nested.ResourceService.putHeaders(ResourceService.java:730)
[INFO] 	at org.eclipse.jetty.ee8.nested.ResourceService.sendData(ResourceService.java:574)
[INFO] 	at org.eclipse.jetty.ee8.nested.ResourceService.doGet(ResourceService.java:284)
[INFO] 	at org.eclipse.jetty.ee8.servlet.DefaultServlet.doGet(DefaultServlet.java:435)
[INFO] 	at javax.servlet.http.HttpServlet.service(HttpServlet.java:503)
[INFO] 	at javax.servlet.http.HttpServlet.service(HttpServlet.java:590)
[INFO] 	at org.eclipse.jetty.ee8.servlet.ServletHolder$NotAsync.service(ServletHolder.java:1150)
[INFO] 	at org.eclipse.jetty.ee8.servlet.ServletHolder.handle(ServletHolder.java:640)
[INFO] 	at org.eclipse.jetty.ee8.servlet.ServletHandler$ChainEnd.doFilter(ServletHandler.java:1373)
[INFO] 	at org.apache.shiro.web.servlet.ProxiedFilterChain.doFilter(ProxiedFilterChain.java:61)
[INFO] 	at org.apache.shiro.web.servlet.AdviceFilter.executeChain(AdviceFilter.java:108)
[INFO] 	at org.apache.shiro.web.servlet.AdviceFilter.doFilterInternal(AdviceFilter.java:137)
[INFO] 	at org.apache.shiro.web.servlet.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:154)
[INFO] 	at org.apache.shiro.web.servlet.ProxiedFilterChain.doFilter(ProxiedFilterChain.java:66)
[INFO] 	at org.apache.shiro.web.servlet.AdviceFilter.executeChain(AdviceFilter.java:108)
[INFO] 	at org.apache.shiro.web.servlet.AdviceFilter.doFilterInternal(AdviceFilter.java:137)
[INFO] 	at org.apache.shiro.web.servlet.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:154)
[INFO] 	at org.apache.shiro.web.servlet.ProxiedFilterChain.doFilter(ProxiedFilterChain.java:66)
[INFO] 	at org.apache.shiro.web.servlet.AdviceFilter.executeChain(AdviceFilter.java:108)
[INFO] 	at org.apache.shiro.web.servlet.AdviceFilter.doFilterInternal(AdviceFilter.java:137)
[INFO] 	at org.apache.shiro.web.servlet.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:154)
[INFO] 	at org.apache.shiro.web.servlet.ProxiedFilterChain.doFilter(ProxiedFilterChain.java:66)
[INFO] 	at org.apache.shiro.web.servlet.AbstractShiroFilter.executeChain(AbstractShiroFilter.java:458)
[INFO] 	at org.apache.shiro.web.servlet.AbstractShiroFilter$1.call(AbstractShiroFilter.java:373)
[INFO] 	at org.apache.shiro.subject.support.SubjectCallable.doCall(SubjectCallable.java:90)
[INFO] 	at org.apache.shiro.subject.support.SubjectCallable.call(SubjectCallable.java:83)
[INFO] 	at org.apache.shiro.subject.support.DelegatingSubject.execute(DelegatingSubject.java:387)
[INFO] 	at org.apache.shiro.web.servlet.AbstractShiroFilter.doFilterInternal(AbstractShiroFilter.java:370)
[INFO] 	at org.apache.shiro.web.servlet.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:154)
[INFO] 	at org.eclipse.jetty.ee8.servlet.FilterHolder.doFilter(FilterHolder.java:171)
[INFO] 	at org.eclipse.jetty.ee8.servlet.ServletHandler$Chain.doFilter(ServletHandler.java:1347)
[INFO] 	at org.eclipse.jetty.ee8.servlet.ServletHandler.doHandle(ServletHandler.java:454)
[INFO] 	at org.eclipse.jetty.ee8.nested.ScopedHandler.handle(ScopedHandler.java:119)
[INFO] 	at org.eclipse.jetty.ee8.security.SecurityHandler.handle(SecurityHandler.java:492)
[INFO] 	at org.eclipse.jetty.ee8.nested.HandlerWrapper.handle(HandlerWrapper.java:103)
[INFO] 	at org.eclipse.jetty.ee8.nested.ScopedHandler.nextHandle(ScopedHandler.java:193)
[INFO] 	at org.eclipse.jetty.ee8.nested.SessionHandler.doHandle(SessionHandler.java:364)
[INFO] 	at org.eclipse.jetty.ee8.nested.ScopedHandler.nextHandle(ScopedHandler.java:191)
[INFO] 	at org.eclipse.jetty.ee8.nested.ContextHandler.doHandle(ContextHandler.java:849)
[INFO] 	at org.eclipse.jetty.ee8.nested.ScopedHandler.nextScope(ScopedHandler.java:152)
[INFO] 	at org.eclipse.jetty.ee8.servlet.ServletHandler.doScope(ServletHandler.java:423)
[INFO] 	at org.eclipse.jetty.ee8.nested.ScopedHandler.nextScope(ScopedHandler.java:150)
[INFO] 	at org.eclipse.jetty.ee8.nested.SessionHandler.doScope(SessionHandler.java:359)
[INFO] 	at org.eclipse.jetty.ee8.nested.ScopedHandler.nextScope(ScopedHandler.java:150)
[INFO] 	at org.eclipse.jetty.ee8.nested.ContextHandler.doScope(ContextHandler.java:794)
[INFO] 	at org.eclipse.jetty.ee8.nested.ScopedHandler.handle(ScopedHandler.java:117)
[INFO] 	at org.eclipse.jetty.ee8.nested.Dispatcher.forward(Dispatcher.java:168)
[INFO] 	at org.eclipse.jetty.ee8.nested.Dispatcher.forward(Dispatcher.java:114)
[INFO] 	at org.eclipse.jetty.ee8.nested.ResourceService.sendWelcome(ResourceService.java:388)
[INFO] 	at org.eclipse.jetty.ee8.nested.ResourceService.doGet(ResourceService.java:244)
[INFO] 	at org.eclipse.jetty.ee8.servlet.DefaultServlet.doGet(DefaultServlet.java:435)
[INFO] 	at javax.servlet.http.HttpServlet.service(HttpServlet.java:503)
[INFO] 	at javax.servlet.http.HttpServlet.service(HttpServlet.java:590)
[INFO] 	at org.eclipse.jetty.ee8.servlet.ServletHolder$NotAsync.service(ServletHolder.java:1150)
[INFO] 	at org.eclipse.jetty.ee8.servlet.ServletHolder.handle(ServletHolder.java:640)
[INFO] 	at org.eclipse.jetty.ee8.servlet.ServletHandler$ChainEnd.doFilter(ServletHandler.java:1373)
[INFO] 	at org.apache.shiro.web.servlet.ProxiedFilterChain.doFilter(ProxiedFilterChain.java:61)
[INFO] 	at org.apache.shiro.web.servlet.AdviceFilter.executeChain(AdviceFilter.java:108)
[INFO] 	at org.apache.shiro.web.servlet.AdviceFilter.doFilterInternal(AdviceFilter.java:137)
[INFO] 	at org.apache.shiro.web.servlet.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:154)
[INFO] 	at org.apache.shiro.web.servlet.ProxiedFilterChain.doFilter(ProxiedFilterChain.java:66)
[INFO] 	at org.apache.shiro.web.servlet.AdviceFilter.executeChain(AdviceFilter.java:108)
[INFO] 	at org.apache.shiro.web.servlet.AdviceFilter.doFilterInternal(AdviceFilter.java:137)
[INFO] 	at org.apache.shiro.web.servlet.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:154)
[INFO] 	at org.apache.shiro.web.servlet.ProxiedFilterChain.doFilter(ProxiedFilterChain.java:66)
[INFO] 	at org.apache.shiro.web.servlet.AdviceFilter.executeChain(AdviceFilter.java:108)
[INFO] 	at org.apache.shiro.web.servlet.AdviceFilter.doFilterInternal(AdviceFilter.java:137)
[INFO] 	at org.apache.shiro.web.servlet.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:154)
[INFO] 	at org.apache.shiro.web.servlet.ProxiedFilterChain.doFilter(ProxiedFilterChain.java:66)
[INFO] 	at org.apache.shiro.web.servlet.AbstractShiroFilter.executeChain(AbstractShiroFilter.java:458)
[INFO] 	at org.apache.shiro.web.servlet.AbstractShiroFilter$1.call(AbstractShiroFilter.java:373)
[INFO] 	at org.apache.shiro.subject.support.SubjectCallable.doCall(SubjectCallable.java:90)
[INFO] 	at org.apache.shiro.subject.support.SubjectCallable.call(SubjectCallable.java:83)
[INFO] 	at org.apache.shiro.subject.support.DelegatingSubject.execute(DelegatingSubject.java:387)
[INFO] 	at org.apache.shiro.web.servlet.AbstractShiroFilter.doFilterInternal(AbstractShiroFilter.java:370)
[INFO] 	at org.apache.shiro.web.servlet.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:154)
[INFO] 	at org.eclipse.jetty.ee8.servlet.FilterHolder.doFilter(FilterHolder.java:177)
[INFO] 	at org.eclipse.jetty.ee8.servlet.ServletHandler$Chain.doFilter(ServletHandler.java:1347)
[INFO] 	at org.eclipse.jetty.ee8.websocket.servlet.WebSocketUpgradeFilter.doFilter(WebSocketUpgradeFilter.java:175)
[INFO] 	at org.eclipse.jetty.ee8.servlet.FilterHolder.doFilter(FilterHolder.java:171)
[INFO] 	at org.eclipse.jetty.ee8.servlet.ServletHandler$Chain.doFilter(ServletHandler.java:1347)
[INFO] 	at org.eclipse.jetty.ee8.servlet.ServletHandler.doHandle(ServletHandler.java:454)
[INFO] 	at org.eclipse.jetty.ee8.nested.ScopedHandler.handle(ScopedHandler.java:119)
[INFO] 	at org.eclipse.jetty.ee8.security.SecurityHandler.handle(SecurityHandler.java:480)
[INFO] 	at org.eclipse.jetty.ee8.nested.HandlerWrapper.handle(HandlerWrapper.java:103)
[INFO] 	at org.eclipse.jetty.ee8.nested.ScopedHandler.nextHandle(ScopedHandler.java:193)
[INFO] 	at org.eclipse.jetty.ee8.nested.SessionHandler.doHandle(SessionHandler.java:364)
[INFO] 	at org.eclipse.jetty.ee8.nested.ScopedHandler.nextHandle(ScopedHandler.java:191)
[INFO] 	at org.eclipse.jetty.ee8.nested.ContextHandler.doHandle(ContextHandler.java:849)
[INFO] 	at org.eclipse.jetty.ee8.nested.ScopedHandler.nextScope(ScopedHandler.java:152)
[INFO] 	at org.eclipse.jetty.ee8.servlet.ServletHandler.doScope(ServletHandler.java:423)
[INFO] 	at org.eclipse.jetty.ee8.nested.ScopedHandler.nextScope(ScopedHandler.java:150)
[INFO] 	at org.eclipse.jetty.ee8.nested.SessionHandler.doScope(SessionHandler.java:359)
[INFO] 	at org.eclipse.jetty.ee8.nested.ScopedHandler.nextScope(ScopedHandler.java:150)
[INFO] 	at org.eclipse.jetty.ee8.nested.ContextHandler.doScope(ContextHandler.java:794)
[INFO] 	at org.eclipse.jetty.ee8.nested.ScopedHandler.handle(ScopedHandler.java:117)
[INFO] 	at org.eclipse.jetty.ee8.nested.ContextHandler.handle(ContextHandler.java:1407)
[INFO] 	at org.eclipse.jetty.ee8.nested.HttpChannel$RequestDispatchable.dispatch(HttpChannel.java:1353)
[INFO] 	at org.eclipse.jetty.ee8.nested.HttpChannel.dispatch(HttpChannel.java:678)
[INFO] 	at org.eclipse.jetty.ee8.nested.HttpChannel.handle(HttpChannel.java:510)
[INFO] 	at org.eclipse.jetty.ee8.nested.ContextHandler$CoreContextHandler$CoreToNestedHandler.handle(ContextHandler.java:2237)
[INFO] 	at org.eclipse.jetty.server.handler.ContextHandler.handle(ContextHandler.java:811)
[INFO] 	at org.eclipse.jetty.server.handler.ContextHandlerCollection.handle(ContextHandlerCollection.java:177)
[INFO] 	at org.eclipse.jetty.server.Handler$Wrapper.handle(Handler.java:712)
[INFO] 	at org.eclipse.jetty.rewrite.handler.RewriteHandler.handle(RewriteHandler.java:129)
[INFO] 	at org.eclipse.jetty.rewrite.handler.Rule$Handler.handle(Rule.java:99)
[INFO] 	at org.eclipse.jetty.rewrite.handler.HeaderPatternRule$1.handle(HeaderPatternRule.java:87)
[INFO] 	at org.eclipse.jetty.rewrite.handler.Rule$Handler.handle(Rule.java:83)
[INFO] 	at org.eclipse.jetty.rewrite.handler.RewriteHandler.handle(RewriteHandler.java:133)
[INFO] 	at org.eclipse.jetty.rewrite.handler.Rule$Handler.handle(Rule.java:99)
[INFO] 	at org.eclipse.jetty.rewrite.handler.HeaderPatternRule$1.handle(HeaderPatternRule.java:87)
[INFO] 	at org.eclipse.jetty.rewrite.handler.Rule$Handler.handle(Rule.java:83)
[INFO] 	at org.eclipse.jetty.rewrite.handler.RewriteHandler.handle(RewriteHandler.java:133)
[INFO] 	at org.eclipse.jetty.rewrite.handler.Rule$Handler.handle(Rule.java:99)
[INFO] 	at org.eclipse.jetty.rewrite.handler.HeaderPatternRule$1.handle(HeaderPatternRule.java:87)
[INFO] 	at org.eclipse.jetty.rewrite.handler.Rule$Handler.handle(Rule.java:83)
[INFO] 	at org.eclipse.jetty.rewrite.handler.RewriteHandler.handle(RewriteHandler.java:133)
[INFO] 	at org.eclipse.jetty.rewrite.handler.Rule$Handler.handle(Rule.java:99)
[INFO] 	at org.eclipse.jetty.rewrite.handler.HeaderPatternRule$1.handle(HeaderPatternRule.java:87)
[INFO] 	at org.eclipse.jetty.rewrite.handler.Rule$Handler.handle(Rule.java:83)
[INFO] 	at org.eclipse.jetty.rewrite.handler.RewriteHandler.handle(RewriteHandler.java:133)
[INFO] 	at org.eclipse.jetty.server.handler.gzip.GzipHandler.handle(GzipHandler.java:594)
[INFO] 	at org.eclipse.jetty.server.Handler$Wrapper.handle(Handler.java:712)
[INFO] 	at org.eclipse.jetty.server.Server.handle(Server.java:176)
[INFO] 	at org.eclipse.jetty.server.internal.HttpChannelState$HandlerInvoker.run(HttpChannelState.java:648)
[INFO] 	at org.eclipse.jetty.server.internal.HttpConnection.onFillable(HttpConnection.java:471)
[INFO] 	at org.eclipse.jetty.io.AbstractConnection$ReadCallback.succeeded(AbstractConnection.java:322)
[INFO] 	at org.eclipse.jetty.io.FillInterest.fillable(FillInterest.java:100)
[INFO] 	at org.eclipse.jetty.io.SelectableChannelEndPoint$1.run(SelectableChannelEndPoint.java:53)
[INFO] 	at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:969)
[INFO] 	at org.eclipse.jetty.util.thread.QueuedThreadPool$Runner.doRunJob(QueuedThreadPool.java:1194)
[INFO] 	at org.eclipse.jetty.util.thread.QueuedThreadPool$Runner.run(QueuedThreadPool.java:1149)
[INFO] 	at java.base/java.lang.Thread.run(Thread.java:833)
@sbordet
Copy link
Contributor

sbordet commented Sep 25, 2023

@janitza-bjag I don't understand.

The HTTP Date header must be a date, as specified: https://www.rfc-editor.org/rfc/rfc9110#field.date.

Is it you trying to get the Date field as a long, or it is Jetty that produces the error and you are not doing anything explicitly?

Do you have reproducer steps so we can reproduce the issue?

@janitza-bjag
Copy link
Author

@sbordet Sorry, its about the HttpHeader.LAST_MODIFIED.
I do not set it explicitly, so I think its handled by Jetty.

I debugged into "org.eclipse.jetty.ee8.nested.Response" where the static method putHeaders is called. Here the NumberFormatExceoption occurs ...
image

@janbartel
Copy link
Contributor

@janitza-bjag I think I've recently fixed this problem, see: #10463

@janitza-bjag janitza-bjag changed the title NumberFormatException with DateHeader NumberFormatException with HttpHeader.LAST_MODIFIED Sep 25, 2023
@janitza-bjag
Copy link
Author

janitza-bjag commented Sep 25, 2023

@janitza-bjag I think I've recently fixed this problem, see: #10463

@janbartel
In #10463 I only see commits for ee9 package, are they used in ee8 too?

@sbordet
Copy link
Contributor

sbordet commented Sep 25, 2023

@janitza-bjag ee8 is mechanically copied from ee9 just changing the package names, so ee8 will have the fix.

@sbordet
Copy link
Contributor

sbordet commented Sep 25, 2023

Closing as duplicate of #10463.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants