You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@accumulo.apache.org by Christopher <ct...@apache.org> on 2013/11/01 23:31:21 UTC

InterruptedException handling

It was pointed out to me by a colleague that we're not properly
handling InterruptedException in many places.

He cited this article (I could only find it in Chinese, but Google
Translate works quite well converting it to English):
http://www.ibm.com/developerworks/cn/java/j-jtp05236.html

One place we do this a lot is UtilWaitThread. Should we be concerned
about this? How do we want to address it?

(Also, does anybody have a link to the English version of that article?)

--
Christopher L Tubbs II
http://gravatar.com/ctubbsii

Re: InterruptedException handling

Posted by Bill Havanki <bh...@cloudera.com>.
That's a great article! Brian Goetz's book Java Concurrency in Practice has
material like this and *tons* more. That book along with Effective Java by
Bloch oughta be on every Java developer's bookshelf. :)

UtilWaitThread looks to me like it exists just to provide a sleep that eats
InterruptedException so you don't have to deal with it, which is pretty
much a bad idea. It prevents threads who use it from properly dying out
when receiving an interrupt. Eventually the method should be eliminated so
that threads can correctly propagate interrupts as the article describes.

Bill


On Fri, Nov 1, 2013 at 10:52 PM, Ted Yu <yu...@gmail.com> wrote:

> There're two copies of UtilWaitThread:
>
> ./core/src/main/java/org/apache/accumulo/core/util/UtilWaitThread.java
> ./fate/src/main/java/org/apache/accumulo/fate/util/UtilWaitThread.java
>
> I think interrupted status should be restored in the sleep() method.
>
> Cheers
>
>
> On Fri, Nov 1, 2013 at 7:45 PM, Josh Elser <jo...@gmail.com> wrote:
>
> > Awesome. Thanks for the article, Christopher, and the English
> > translation, Ted!
> >
> > On 11/1/13, 6:42 PM, Ted Yu wrote:
> > > Luckily Google comes to the rescue:
> > >
> > >
> >
> http://webcache.googleusercontent.com/search?q=cache:940mX01ckwMJ:www.ibm.com/developerworks/java/library/j-jtp05236/index.html%3Fiframe%3Dtrue%26width%3D80%25%26height%3D80%25+&cd=1&hl=en&ct=clnk&gl=us
> > >
> > >
> > > On Fri, Nov 1, 2013 at 3:39 PM, Ted Yu <yu...@gmail.com> wrote:
> > >
> > >> In code reviews, I referred to the following article (I believe is the
> > >> same as the Chinese version) which isn't there anymore:
> > >> http://www.ibm.com/developerworks/java/library/j-jtp05236/index.html
> > >>
> > >> The following search returned nothing:
> > >>
> > >>
> > >>
> >
> http://www.ibm.com/developerworks/java/library/?sort_by=&show_abstract=true&show_all=&search_flag=&contentarea_by=Java+technology&search_by=InterruptedException&topic_by=-1&industry_by=-1&type_by=All+Types&ibm-search=Search
> > >>
> > >> However, code speaks by itself. I often refer people to:
> > >> 清单 3. 捕捉 InterruptedException 后恢复中断状态
> > >> which says "restore interrupt status after
> catchingInterruptedException"
> > >>
> > >> Cheers
> > >>
> > >>
> > >> On Fri, Nov 1, 2013 at 3:31 PM, Christopher <ct...@apache.org>
> > wrote:
> > >>
> > >>> It was pointed out to me by a colleague that we're not properly
> > >>> handling InterruptedException in many places.
> > >>>
> > >>> He cited this article (I could only find it in Chinese, but Google
> > >>> Translate works quite well converting it to English):
> > >>> http://www.ibm.com/developerworks/cn/java/j-jtp05236.html
> > >>>
> > >>> One place we do this a lot is UtilWaitThread. Should we be concerned
> > >>> about this? How do we want to address it?
> > >>>
> > >>> (Also, does anybody have a link to the English version of that
> > article?)
> > >>>
> > >>> --
> > >>> Christopher L Tubbs II
> > >>> http://gravatar.com/ctubbsii
> > >>>
> > >>
> > >>
> > >
> >
>



-- 
// - - -
// Bill Havanki
// Solutions Architect, Cloudera
// - - -

Re: InterruptedException handling

Posted by Ted Yu <yu...@gmail.com>.
There're two copies of UtilWaitThread:

./core/src/main/java/org/apache/accumulo/core/util/UtilWaitThread.java
./fate/src/main/java/org/apache/accumulo/fate/util/UtilWaitThread.java

I think interrupted status should be restored in the sleep() method.

Cheers


On Fri, Nov 1, 2013 at 7:45 PM, Josh Elser <jo...@gmail.com> wrote:

> Awesome. Thanks for the article, Christopher, and the English
> translation, Ted!
>
> On 11/1/13, 6:42 PM, Ted Yu wrote:
> > Luckily Google comes to the rescue:
> >
> >
> http://webcache.googleusercontent.com/search?q=cache:940mX01ckwMJ:www.ibm.com/developerworks/java/library/j-jtp05236/index.html%3Fiframe%3Dtrue%26width%3D80%25%26height%3D80%25+&cd=1&hl=en&ct=clnk&gl=us
> >
> >
> > On Fri, Nov 1, 2013 at 3:39 PM, Ted Yu <yu...@gmail.com> wrote:
> >
> >> In code reviews, I referred to the following article (I believe is the
> >> same as the Chinese version) which isn't there anymore:
> >> http://www.ibm.com/developerworks/java/library/j-jtp05236/index.html
> >>
> >> The following search returned nothing:
> >>
> >>
> >>
> http://www.ibm.com/developerworks/java/library/?sort_by=&show_abstract=true&show_all=&search_flag=&contentarea_by=Java+technology&search_by=InterruptedException&topic_by=-1&industry_by=-1&type_by=All+Types&ibm-search=Search
> >>
> >> However, code speaks by itself. I often refer people to:
> >> 清单 3. 捕捉 InterruptedException 后恢复中断状态
> >> which says "restore interrupt status after catchingInterruptedException"
> >>
> >> Cheers
> >>
> >>
> >> On Fri, Nov 1, 2013 at 3:31 PM, Christopher <ct...@apache.org>
> wrote:
> >>
> >>> It was pointed out to me by a colleague that we're not properly
> >>> handling InterruptedException in many places.
> >>>
> >>> He cited this article (I could only find it in Chinese, but Google
> >>> Translate works quite well converting it to English):
> >>> http://www.ibm.com/developerworks/cn/java/j-jtp05236.html
> >>>
> >>> One place we do this a lot is UtilWaitThread. Should we be concerned
> >>> about this? How do we want to address it?
> >>>
> >>> (Also, does anybody have a link to the English version of that
> article?)
> >>>
> >>> --
> >>> Christopher L Tubbs II
> >>> http://gravatar.com/ctubbsii
> >>>
> >>
> >>
> >
>

Re: InterruptedException handling

Posted by Josh Elser <jo...@gmail.com>.
Awesome. Thanks for the article, Christopher, and the English
translation, Ted!

On 11/1/13, 6:42 PM, Ted Yu wrote:
> Luckily Google comes to the rescue:
> 
> http://webcache.googleusercontent.com/search?q=cache:940mX01ckwMJ:www.ibm.com/developerworks/java/library/j-jtp05236/index.html%3Fiframe%3Dtrue%26width%3D80%25%26height%3D80%25+&cd=1&hl=en&ct=clnk&gl=us
> 
> 
> On Fri, Nov 1, 2013 at 3:39 PM, Ted Yu <yu...@gmail.com> wrote:
> 
>> In code reviews, I referred to the following article (I believe is the
>> same as the Chinese version) which isn't there anymore:
>> http://www.ibm.com/developerworks/java/library/j-jtp05236/index.html
>>
>> The following search returned nothing:
>>
>>
>> http://www.ibm.com/developerworks/java/library/?sort_by=&show_abstract=true&show_all=&search_flag=&contentarea_by=Java+technology&search_by=InterruptedException&topic_by=-1&industry_by=-1&type_by=All+Types&ibm-search=Search
>>
>> However, code speaks by itself. I often refer people to:
>> 清单 3. 捕捉 InterruptedException 后恢复中断状态
>> which says "restore interrupt status after catchingInterruptedException"
>>
>> Cheers
>>
>>
>> On Fri, Nov 1, 2013 at 3:31 PM, Christopher <ct...@apache.org> wrote:
>>
>>> It was pointed out to me by a colleague that we're not properly
>>> handling InterruptedException in many places.
>>>
>>> He cited this article (I could only find it in Chinese, but Google
>>> Translate works quite well converting it to English):
>>> http://www.ibm.com/developerworks/cn/java/j-jtp05236.html
>>>
>>> One place we do this a lot is UtilWaitThread. Should we be concerned
>>> about this? How do we want to address it?
>>>
>>> (Also, does anybody have a link to the English version of that article?)
>>>
>>> --
>>> Christopher L Tubbs II
>>> http://gravatar.com/ctubbsii
>>>
>>
>>
> 

Re: InterruptedException handling

Posted by Ted Yu <yu...@gmail.com>.
Luckily Google comes to the rescue:

http://webcache.googleusercontent.com/search?q=cache:940mX01ckwMJ:www.ibm.com/developerworks/java/library/j-jtp05236/index.html%3Fiframe%3Dtrue%26width%3D80%25%26height%3D80%25+&cd=1&hl=en&ct=clnk&gl=us


On Fri, Nov 1, 2013 at 3:39 PM, Ted Yu <yu...@gmail.com> wrote:

> In code reviews, I referred to the following article (I believe is the
> same as the Chinese version) which isn't there anymore:
> http://www.ibm.com/developerworks/java/library/j-jtp05236/index.html
>
> The following search returned nothing:
>
>
> http://www.ibm.com/developerworks/java/library/?sort_by=&show_abstract=true&show_all=&search_flag=&contentarea_by=Java+technology&search_by=InterruptedException&topic_by=-1&industry_by=-1&type_by=All+Types&ibm-search=Search
>
> However, code speaks by itself. I often refer people to:
> 清单 3. 捕捉 InterruptedException 后恢复中断状态
> which says "restore interrupt status after catchingInterruptedException"
>
> Cheers
>
>
> On Fri, Nov 1, 2013 at 3:31 PM, Christopher <ct...@apache.org> wrote:
>
>> It was pointed out to me by a colleague that we're not properly
>> handling InterruptedException in many places.
>>
>> He cited this article (I could only find it in Chinese, but Google
>> Translate works quite well converting it to English):
>> http://www.ibm.com/developerworks/cn/java/j-jtp05236.html
>>
>> One place we do this a lot is UtilWaitThread. Should we be concerned
>> about this? How do we want to address it?
>>
>> (Also, does anybody have a link to the English version of that article?)
>>
>> --
>> Christopher L Tubbs II
>> http://gravatar.com/ctubbsii
>>
>
>

Re: InterruptedException handling

Posted by Ted Yu <yu...@gmail.com>.
In code reviews, I referred to the following article (I believe is the same
as the Chinese version) which isn't there anymore:
http://www.ibm.com/developerworks/java/library/j-jtp05236/index.html

The following search returned nothing:

http://www.ibm.com/developerworks/java/library/?sort_by=&show_abstract=true&show_all=&search_flag=&contentarea_by=Java+technology&search_by=InterruptedException&topic_by=-1&industry_by=-1&type_by=All+Types&ibm-search=Search

However, code speaks by itself. I often refer people to:
清单 3. 捕捉 InterruptedException 后恢复中断状态
which says "restore interrupt status after catchingInterruptedException"

Cheers


On Fri, Nov 1, 2013 at 3:31 PM, Christopher <ct...@apache.org> wrote:

> It was pointed out to me by a colleague that we're not properly
> handling InterruptedException in many places.
>
> He cited this article (I could only find it in Chinese, but Google
> Translate works quite well converting it to English):
> http://www.ibm.com/developerworks/cn/java/j-jtp05236.html
>
> One place we do this a lot is UtilWaitThread. Should we be concerned
> about this? How do we want to address it?
>
> (Also, does anybody have a link to the English version of that article?)
>
> --
> Christopher L Tubbs II
> http://gravatar.com/ctubbsii
>