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

Jetty-12 can't retrieve some resources (lastModified wrong type) #10575

Closed
SergYarovoye opened this issue Sep 25, 2023 · 2 comments
Closed

Jetty-12 can't retrieve some resources (lastModified wrong type) #10575

SergYarovoye opened this issue Sep 25, 2023 · 2 comments
Labels
Bug For general bugs on Jetty side Duplicate

Comments

@SergYarovoye
Copy link

Jetty version(s)
12.0.0+

Jetty Environment
ee8

Java version/vendor
openjdk version "17.0.4.1" 2022-08-12 LTS
OpenJDK Runtime Environment (build 17.0.4.1+1-LTS)
OpenJDK 64-Bit Server VM (build 17.0.4.1+1-LTS, mixed mode, sharing)

OS type/version
KUbuntu 22.04
Linux
5.15.0-83-generic
x86_64

Description
My app started, but some resources didn't load in browser.
Mostly PNG images.
Debug showed a problem:
in org.eclipse.jetty.http.content.ResourceHttpContent#getLastModified we created HttpField with value as string representation of lastModified date (example: "Tue, 19 Sep 2023 08:59:00 GMT"),
but later, in org.eclipse.jetty.ee8.nested.Response.putHeaders we try to get this value as Long.
Exception as a result:

09-19;16:02:51.987 WARN [ qtp244185498-30][ o.e.j.e.n.ResourceService][]: Failed to serve resource: /images/icons/32/id_card.png
java.lang.NumberFormatException: For input string: "Tue, 19 Sep 2023 08:59:00 GMT"
at java.base/java.lang.NumberFormatException.forInputString(NumberFormatException.java:67)
at java.base/java.lang.Long.parseLong(Long.java:711)
at java.base/java.lang.Long.parseLong(Long.java:836)
at org.eclipse.jetty.http.HttpField.getLongValue(HttpField.java:355)
at org.eclipse.jetty.ee8.nested.Response.putHeaders(Response.java:1198)
at org.eclipse.jetty.ee8.nested.ResourceService.putHeaders(ResourceService.java:717)
at org.eclipse.jetty.ee8.nested.ResourceService.sendData(ResourceService.java:564)
at org.eclipse.jetty.ee8.nested.ResourceService.doGet(ResourceService.java:279)
at org.eclipse.jetty.ee8.servlet.DefaultServlet.doGet(DefaultServlet.java:432)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:503)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:590)

But other images and other resources successfully loaded.

How to reproduce?
Just run jetty-12 with ee8 env, try to load image from your app class path.

How to fix
Just change org.eclipse.jetty.http.content.ResourceHttpContent#getLastModified:

public HttpField getLastModified()
{
    Instant lm = _resource.lastModified();
    return new HttpField.LongValueHttpField(HttpHeader.LAST_MODIFIED, DateGenerator.formatDate(lm), lm.toEpochMilli());
}
@SergYarovoye SergYarovoye added the Bug For general bugs on Jetty side label Sep 25, 2023
@janbartel
Copy link
Contributor

Duplicate of #10463.

@janbartel
Copy link
Contributor

Closing as duplicate

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug For general bugs on Jetty side Duplicate
Projects
None yet
Development

No branches or pull requests

2 participants