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

Interrupting a synchronous remote call should `Thread.interrupt` the corresponding thread on the remote side

XMLWordPrintable

      Interrupting a synchronous remote call should `Thread.interrupt` the corresponding thread on the remote side. 

      I'm working on a plugin (builder) that I want to make compatible with master/slave setup and looks like if a user cancels the build from the master my plugin does not get interrupted and still gets executed until the end and only then the job is marked as canceled even tough it still finished doing everything.

       
      The flow of the plugin is basically like this:
       

      public void perform(@Nonnull Run<?, ?> build, @Nonnull FilePath workspace, @Nonnull Launcher launcher, @Nonnull TaskListener listener) throws IOException {
           launcher.getChannel().call(deployCallable);
      }

       
      deployCallable is an instance of a inner class described bellow:
       

      private static class DeployCallable extends MasterToSlaveCallable<Boolean, InterruptedException> { // So it works in master/slave setup
          private static final long serialVersionUID = 1L;
      
          public Boolean call() throws InterruptedException { 
              for folder in path { 
                  zip(folder); 
              } 
      
              for zip in zipFiles {
                  upload(zip); // Using Apache HTTP Client
              }
          }
      }
      

       
      In this case the problem is that that if I click cancel on the job it still runs until the build step is finished and all files are zipped and uploaded and only then it marks the build as aborted. 

            Unassigned Unassigned
            danechitoaie Daniel Anechitoaie
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated: