相关疑难解决方法(0)

Jetty:以编程方式停止导致"1个线程无法停止"

我有一个嵌入式Jetty 6.1.26实例.我希望通过发送的HTTP GET将其关闭/shutdown.所以我创建了一个JettyShutdownServlet:

@Override
protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {

 resp.setStatus(202, "Shutting down.");
 resp.setContentType("text/plain");
 ServletOutputStream os = resp.getOutputStream();
 os.println("Shutting down.");
 os.close();
 resp.flushBuffer();

 // Stop the server.
 try {
    log.info("Shutting down the server...");
    server.stop();
 } catch (Exception ex) {
    log.error("Error when stopping Jetty server: "+ex.getMessage(), ex);
 }
Run Code Online (Sandbox Code Playgroud)

但是,当我发送请求时,Jetty不会停止 - 一个线程一直挂org.mortbay.thread.QueuedThreadPool在线上this.wait():

   // We are idle
   // wait for a dispatched job
   synchronized (this)
   {
       if (_job==null)
          this.wait(getMaxIdleTimeMs());
       job=_job;
       _job=null;
   } …
Run Code Online (Sandbox Code Playgroud)

java shutdown jetty

6
推荐指数
1
解决办法
9998
查看次数

标签 统计

java ×1

jetty ×1

shutdown ×1