Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [jetty-users] Does Jetty call Thread.interrupt?

Thanks Joakim,

Please allow me to explain.

The guys at H2 database say that if client code that is performing database operations is interrupted the underlying FileHandle that is used to manipulate the database file will be closed. This would cause the database to be left in an invalid state (i.e. a corrupted database, a problem we regularly encounter). So if code inside, lets say, a doPost handler, is doing database mutations and the thread it runs in is interrupted the database it is writing to might be corrupted.

I am looking for scenario's where Jetty might call Thread.interrupt on threads executing such code. Our application calls server.stop in a shutdown hook and if that causes QueuedThreadPool to interrupt our threads this could be the case, I would expect. Or am I mistaken?

Cheers,

Silvio


On 28-07-2022 15:55, Joakim Erdfelt wrote:
Thread.interrupt() is called in many places in code.  

  jetty-ant
    org.eclipse.jetty.ant
      AntBuild
        stop()
          _process.interrupt();
  jetty-server
    org.eclipse.jetty.server
      AbstractConnector
        interruptAcceptors()
          thread.interrupt();
      AsyncRequestLogWriter
        doStop()
          _thread.interrupt();
      ResponseWriter
        write(int)
          Thread.currentThread().interrupt();
        write(char[], int, int)
          Thread.currentThread().interrupt();
        write(String, int, int)
          Thread.currentThread().interrupt();
        println()
          Thread.currentThread().interrupt();
        println(char)
          Thread.currentThread().interrupt();
        println(char[])
          Thread.currentThread().interrupt();
        println(String)
          Thread.currentThread().interrupt();
        format(Locale, String, Object...)
          Thread.currentThread().interrupt();
  jetty-servlets
    org.eclipse.jetty.servlets
      DoSFilter
        onRequestTimeout(HttpServletRequest, HttpServletResponse, Thread)
          handlingThread.interrupt();
  jetty-util
    org.eclipse.jetty.util
      LeakDetector
        doStop()
          thread.interrupt();
      SocketAddressResolver.Async
        resolve(String, int, Promise<List<InetSocketAddress>>)
          thread.interrupt();
    org.eclipse.jetty.util.component
      Graceful
        shutdown(ThrowingRunnable)
          thread.interrupt();
    org.eclipse.jetty.util.thread
      QueuedThreadPool
        doStop()
          thread.interrupt();
        interruptThread(long)
          thread.interrupt();
      ReservedThreadExecutor
        doStop()
          .forEach(Thread::interrupt);



What are you trying to do? or are concerned about?
Know that there's no expectation that 1 request/response exchange is handled by 1 thread in Jetty.
It can be 1..n threads over its lifetime (depends on the technology used during that request/response exchange)
Gets even more complex with your choice of protocols in use too. (websocket vs http/1.1)

Joakim Erdfelt / joakim@xxxxxxxxxxx


On Thu, Jul 28, 2022 at 8:31 AM Silvio Bierman <sbierman@xxxxxxxxxxxxxxxxxx> wrote:
Hi all,

Are there scenarios in which Jetty might call Thread.interrupt on
application code?

Cheers,

Silvio

_______________________________________________
jetty-users mailing list
jetty-users@xxxxxxxxxxx
To unsubscribe from this list, visit https://www.eclipse.org/mailman/listinfo/jetty-users

_______________________________________________
jetty-users mailing list
jetty-users@xxxxxxxxxxx
To unsubscribe from this list, visit https://www.eclipse.org/mailman/listinfo/jetty-users


Back to the top