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

Header image for Jetty demo page fails on hard refresh #9078

Closed
gregpoulos opened this issue Dec 21, 2022 · 2 comments
Closed

Header image for Jetty demo page fails on hard refresh #9078

gregpoulos opened this issue Dec 21, 2022 · 2 comments
Assignees
Labels
Bug For general bugs on Jetty side

Comments

@gregpoulos
Copy link
Contributor

Jetty version(s)
Jetty 12

Java version/vendor
openjdk version "19.0.1" 2022-10-18

OS type/version
macOS Monterey 12.6.2

Description
When running the demos module that ships with Jetty 12, I am seeing some odd behavior upon accessing the demo home page at http://0.0.0.0:8080/.

When the page first loads, everything looks fine. But if I do a hard refresh (Cmd+Shift+R), the header image no longer appears and I get the following stacktrace in my terminal:

2022-12-21 15:32:43.501:WARN :oejs.Response:qtp640363654-29: writeError: status=500, message=java.io.IOException: written 0 < 493852 content-length, response=org.eclipse.jetty.server.internal.HttpChannelState$ErrorResponse@7db7a010
java.io.IOException: written 0 < 493852 content-length
	at org.eclipse.jetty.server.internal.HttpChannelState$ChannelResponse.write(HttpChannelState.java:1111)
	at org.eclipse.jetty.ee10.servlet.HttpOutput.channelWrite(HttpOutput.java:213)
	at org.eclipse.jetty.ee10.servlet.HttpOutput.complete(HttpOutput.java:443)
	at org.eclipse.jetty.ee10.servlet.ServletContextResponse.completeOutput(ServletContextResponse.java:152)
	at org.eclipse.jetty.ee10.servlet.ServletChannel.handle(ServletChannel.java:597)
	at org.eclipse.jetty.ee10.servlet.ServletHandler.process(ServletHandler.java:442)
	at org.eclipse.jetty.ee10.servlet.security.SecurityHandler.process(SecurityHandler.java:563)
	at org.eclipse.jetty.ee10.servlet.SessionHandler.process(SessionHandler.java:756)
	at org.eclipse.jetty.server.handler.ContextHandler.process(ContextHandler.java:696)
	at org.eclipse.jetty.server.handler.ContextHandlerCollection.process(ContextHandlerCollection.java:166)
	at org.eclipse.jetty.server.Handler$Collection.process(Handler.java:577)
	at org.eclipse.jetty.server.Handler$Wrapper.process(Handler.java:541)
	at org.eclipse.jetty.rewrite.handler.RewriteHandler.process(RewriteHandler.java:118)
	at org.eclipse.jetty.server.Handler$Wrapper.process(Handler.java:541)
	at org.eclipse.jetty.server.internal.HttpChannelState$HandlerInvoker.run(HttpChannelState.java:594)
	at org.eclipse.jetty.server.internal.HttpConnection.onFillable(HttpConnection.java:445)
	at org.eclipse.jetty.io.AbstractConnection$ReadCallback.succeeded(AbstractConnection.java:322)
	at org.eclipse.jetty.io.FillInterest.fillable(FillInterest.java:100)
	at org.eclipse.jetty.io.SelectableChannelEndPoint$1.run(SelectableChannelEndPoint.java:53)
	at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:934)
	at org.eclipse.jetty.util.thread.QueuedThreadPool$Runner.run(QueuedThreadPool.java:1078)
	at java.base/java.lang.Thread.run(Thread.java:1589)

The fact that the page loads correctly at first and only breaks upon refresh is what seems particularly weird to me here.

How to reproduce?
$ java -jar $JETTY_HOME/start.jar --add-modules=demos $ java -jar $JETTY_HOME/start.jar
Then navigate to http://0.0.0.0:8080/. The page loads correctly upon first load, but if I do a hard refresh (Cmd+Shift+R) the image no longer appears.

@gregpoulos gregpoulos added the Bug For general bugs on Jetty side label Dec 21, 2022
@gregw
Copy link
Contributor

gregw commented Dec 21, 2022

Sounds like a problem with an If-Not-Modified response. My guess is we are sending a 304 not modified, but also setting content-length. @lorban do you want to take this?

lorban added a commit that referenced this issue Dec 22, 2022
Signed-off-by: Ludovic Orban <[email protected]>
@lorban
Copy link
Contributor

lorban commented Dec 22, 2022

@gregw I managed to reproduce the problem. See #9079 for a reproducing test and a prototype fix which should be discussed with @lachlan-roberts. But at least it solves the problem for now so maybe we want to merge it right away and clean it later?

It's not surprising we did not catch this earlier because we need to serve a file of a certain size otherwise it's not mmap'ed and the slow path is taken.

lorban added a commit that referenced this issue Dec 22, 2022
Signed-off-by: Ludovic Orban <[email protected]>
lorban added a commit that referenced this issue Dec 22, 2022
Signed-off-by: Ludovic Orban <[email protected]>
lorban added a commit that referenced this issue Dec 23, 2022
Signed-off-by: Ludovic Orban <[email protected]>
lorban added a commit that referenced this issue Jan 9, 2023
…teBuffer instances and document that contract

Signed-off-by: Ludovic Orban <[email protected]>
lorban added a commit that referenced this issue Jan 10, 2023
…teBuffer instances and document that contract

Signed-off-by: Ludovic Orban <[email protected]>
@lorban lorban closed this as completed Jan 10, 2023
gregpoulos pushed a commit to gregpoulos/jetty.project that referenced this issue Jan 16, 2023
…x-document-modules

* upstream/jetty-12.0.x:
  Issue jetty#9167 - making assumption in flaky test
  jetty 12.0.x cleanup duplicate osgi pom metadata (jetty#9093)
  Jetty 12 - Add tests in util/resource for alternate FileSystem implementations (jetty#9149)
  Cleanup non-retainable `Retainable`s (jetty#9159)
  Fixes retainability of special Chunks (jetty#9073)
  TCK: Dispatch forward and includes attributes do not meet the spec (jetty#9074)
  re-enable h3 tests (jetty#8773)
  More fundamental test case
  Reorganization of jetty-client classes. (jetty#9127)
  Removing @disabled from SslUploadTest
  Removing @disabled from jetty-start
  jetty#9134 added test
  ee10: DefaultServlet: Replace checks for isStreaming() by !isWriting()
  jetty#9078 make HttpContent.getByteBuffer() implementations return new ByteBuffer instances and document that contract
  Fixes jetty#9141 - Thread-safe Content.Chunk#slice (jetty#9142)
  Remove `@Disabled` from `jetty-jmx` (jetty#9143)
  Bump maven.version from 3.8.6 to 3.8.7
  Bump maven.version from 3.8.6 to 3.8.7
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
Projects
None yet
Development

No branches or pull requests

3 participants