Skip to content

Commit

Permalink
Send a message on startup, increase the timeout, and stop sending lat…
Browse files Browse the repository at this point in the history
…er calls

This is a followup to the original bug report to emphasize that Jetty 12
is failing to notify the servlet and its listeners that the client is
definitely gone. Further, it calls out that 12+ee10 does not notify on
timeouts.
  • Loading branch information
niloc132 committed Oct 9, 2024
1 parent 1478f45 commit 0646f88
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 28 deletions.
18 changes: 9 additions & 9 deletions jetty-11/src/main/java/com/example/jetty11/Server.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,15 @@ public static void main(String[] args) throws Exception {
context.addServlet(new ServletHolder(servlet), "/connect");
s.setHandler(context);

ScheduledExecutorService executorService = Executors.newSingleThreadScheduledExecutor();
executorService.scheduleAtFixedRate(() -> {
try {
servlet.sayHi();
} catch (Exception e) {
// log and continue
LOG.warn("Error writing in exec service", e);
}
}, 1, 1, TimeUnit.SECONDS);
// ScheduledExecutorService executorService = Executors.newSingleThreadScheduledExecutor();
// executorService.scheduleAtFixedRate(() -> {
// try {
// servlet.sayHi();
// } catch (Exception e) {
// // log and continue
// LOG.warn("Error writing in exec service", e);
// }
// }, 1, 1, TimeUnit.SECONDS);

s.start();
s.join();
Expand Down
18 changes: 9 additions & 9 deletions jetty-12/ee10/src/main/java/com/example/jetty12/ee10/Server.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,15 @@ public static void main(String[] args) throws Exception {
context.addServlet(new ServletHolder(servlet), "/connect");
s.setHandler(context);

ScheduledExecutorService executorService = Executors.newSingleThreadScheduledExecutor();
executorService.scheduleAtFixedRate(() -> {
try {
servlet.sayHi();
} catch (Exception e) {
// log and continue
LOG.warn("Error writing in exec service", e);
}
}, 1, 1, TimeUnit.SECONDS);
// ScheduledExecutorService executorService = Executors.newSingleThreadScheduledExecutor();
// executorService.scheduleAtFixedRate(() -> {
// try {
// servlet.sayHi();
// } catch (Exception e) {
// // log and continue
// LOG.warn("Error writing in exec service", e);
// }
// }, 1, 1, TimeUnit.SECONDS);

s.start();
s.join();
Expand Down
18 changes: 9 additions & 9 deletions jetty-12/ee9/src/main/java/com/example/jetty12/ee9/Server.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,15 @@ public static void main(String[] args) throws Exception {
context.addServlet(new ServletHolder(servlet), "/connect");
s.setHandler(context);

ScheduledExecutorService executorService = Executors.newSingleThreadScheduledExecutor();
executorService.scheduleAtFixedRate(() -> {
try {
servlet.sayHi();
} catch (Exception e) {
// log and continue
LOG.warn("Error writing in exec service", e);
}
}, 1, 1, TimeUnit.SECONDS);
// ScheduledExecutorService executorService = Executors.newSingleThreadScheduledExecutor();
// executorService.scheduleAtFixedRate(() -> {
// try {
// servlet.sayHi();
// } catch (Exception e) {
// // log and continue
// LOG.warn("Error writing in exec service", e);
// }
// }, 1, 1, TimeUnit.SECONDS);

s.start();
s.join();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,13 +127,14 @@ protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws S
@Override
protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
AsyncContext asyncCtx = req.startAsync(req, resp);
asyncCtx.setTimeout(10_000);
asyncCtx.setTimeout(100_000);

final int id = nextId.getAndIncrement();

LOG.info("New request #" + id);

ClientConnection c = new ClientConnection(id, asyncCtx);
c.println("startup");
connections.add(c);
}

Expand Down

0 comments on commit 0646f88

Please sign in to comment.