I was concerned that calling Thread.currentThread().interrupt(); to not 
cause any issues with Jenkins, like crash the job or something like that.
It's clear that it will stop the job, as it should. Just that it was not 
clear to me how Jenkins handles this and if me doing this won't break 
Jenkins in any way.

Thank you. 



On Friday, May 25, 2018 at 6:48:36 PM UTC+3, Matt Sicker wrote:
>
> try {
>   Thread.sleep(...);
> } catch (InterruptedException ex) {
>   Thread.currentThread().interrupt();
> }
>
> That's the normal Java idiom at least. The InterruptedException is checked 
> purely so you are forced to deal with it like this because it's the safer 
> way of killing a thread.
>
> On Fri, May 25, 2018 at 9:21 AM, Daniel Anechitoaie <danie...@gmail.com 
> <javascript:>> wrote:
>
>> Hi,
>>
>> I have a plugin that calls a MasterToSlaveCallable with the following 
>> signature "private static class DataImportCallable extends 
>> MasterToSlaveCallable<Void, IOException>".
>> Inside this MasterToSlaveCallable I zip some files and then upload them 
>> to a server using Apache HTTPClient and then make some REST API calls where 
>> I need to periodically (every 1 minute)
>> check if work is done with the ZIP I have uploaded.
>>
>> My problem is that MasterToSlaveCallable seems to only be allowing one 
>> exception to be thrown and calling Thread.sleep(...) can throw 
>> InterruptedException which does not match the signature of my 
>> MasterToSlaveCallable.
>>
>> How can I "sleep" the thread inside the MasterToSlaveCallable until work 
>> is done?
>>
>> -- 
>> You received this message because you are subscribed to the Google Groups 
>> "Jenkins Developers" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to jenkinsci-de...@googlegroups.com <javascript:>.
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/jenkinsci-dev/75e070c4-2011-465b-8fc9-e7c3b2face10%40googlegroups.com
>>  
>> <https://groups.google.com/d/msgid/jenkinsci-dev/75e070c4-2011-465b-8fc9-e7c3b2face10%40googlegroups.com?utm_medium=email&utm_source=footer>
>> .
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>
>
> -- 
> Matt Sicker
> Software Engineer, CloudBees
>

-- 
You received this message because you are subscribed to the Google Groups 
"Jenkins Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to jenkinsci-dev+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/jenkinsci-dev/c6b75cf6-51a2-408b-b3c7-e289eb14207c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to