Uploaded image for project: 'Jenkins'
  1. Jenkins
  2. JENKINS-73980

Killing threads not possible while using Java21

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Minor Minor
    • monitoring-plugin
    • None
    • Jenkins 2.462.1 Java 21

      Hello,

      When I click kill thread button on /monitoring page, I got following error:

      Caught unhandled exception with ID 53bf818a-5713-408c-aebe-0578be8d7232
      java.lang.UnsupportedOperationException
      	at java.base/java.lang.Thread.stop(Unknown Source)
      	at PluginClassLoader for monitoring//net.bull.javamelody.internal.model.Action.stopThread(Action.java:554)
      	at PluginClassLoader for monitoring//net.bull.javamelody.internal.model.Action.killThread(Action.java:540)
      	at PluginClassLoader for monitoring//net.bull.javamelody.internal.model.Action.execute(Action.java:292)

      Issue does not occur when I click same button on Jenkins instance based on Java 17

      Looks like Thread.stop method was removed from Java 21

      https://docs.oracle.com/en/java/javase/21/docs/api/java.base/java/lang/doc-files/threadPrimitiveDeprecation.html

       

          [JENKINS-73980] Killing threads not possible while using Java21

          evernat added a comment -

          evernat added a comment - Indeed Thread.stop throws UnsupportedOperation since Java 20 https://bugs.openjdk.org/browse/JDK-8289610 https://github.com/openjdk/jdk/commit/acd5bcfc8897908d82e9008ee2def9476f046a4d

          evernat added a comment -

          evernat added a comment - fixed by removing the Kill thread buttons. https://github.com/javamelody/javamelody/commit/52c39b4 https://github.com/javamelody/javamelody/commit/b913c6c

          Jan Gałda added a comment -

          Thanks for checking, would it be possible to replace `stop` button with `interrupt` button?
          `.interrupt()` method allows to stop hung threads

          Jan Gałda added a comment - Thanks for checking, would it be possible to replace `stop` button with `interrupt` button? `.interrupt()` method allows to stop hung threads

          evernat added a comment -

          jgalda There is already an interrupt button in the list of threads to send the interrupt signal to a java thread :

          So the answer is yes and it is already done.

          evernat added a comment - jgalda There is already an interrupt button in the list of threads to send the interrupt signal to a java thread : So the answer is yes and it is already done.

          evernat added a comment - - edited

          the fix to remove the kill/stop button when Java 21+ will be released in version 2.4.0 in some time.

          evernat added a comment - - edited the fix to remove the kill/stop button when Java 21+ will be released in version 2.4.0 in some time.

            evernat evernat
            jgalda Jan Gałda
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: