Recycle ServletChannel at ServletContextHandler completion.

This commit is contained in:
gregw 2023-11-02 07:19:18 +11:00
parent 0ce52b9741
commit 81814dc226
2 changed files with 14 additions and 4 deletions

View File

@ -29,6 +29,7 @@ import jakarta.servlet.ServletOutputStream;
import jakarta.servlet.http.HttpServlet;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import org.eclipse.jetty.util.ExceptionUtil;
import org.eclipse.jetty.util.IO;
import org.eclipse.jetty.util.thread.AutoLock;
@ -211,8 +212,7 @@ public abstract class EventSourceServlet extends HttpServlet
}
catch (Throwable t)
{
if (t != x)
x.addSuppressed(t);
ExceptionUtil.addSuppressedIfNotAssociated(x, t);
getServletContext().log("failure", x);
}
}

View File

@ -29,6 +29,8 @@ import jakarta.servlet.ServletOutputStream;
import jakarta.servlet.http.HttpServlet;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import org.eclipse.jetty.util.ExceptionUtil;
import org.eclipse.jetty.util.IO;
import org.eclipse.jetty.util.thread.AutoLock;
/**
@ -202,8 +204,16 @@ public abstract class EventSourceServlet extends HttpServlet
catch (IOException x)
{
// The other peer closed the connection
close();
eventSource.onClose();
IO.close(this::close);
try
{
eventSource.onClose();
}
catch (Exception t)
{
ExceptionUtil.addSuppressedIfNotAssociated(x, t);
getServletContext().log("failure", x);
}
}
}