Improve registering signal handlers in	java.lang.Terminator.setup()
    David Holmes 
    david.holmes at oracle.com
       
    Mon Aug  6 01:51:24 UTC 2012
    
    
  
Hi Frank,
On 3/08/2012 5:39 PM, Frank Ding wrote:
> Hi guys,
> I found that in java.lang.Terminator, setup() method,
> The following code of registering default signal handlers can be improved:
> / try {
> Signal.handle(new Signal("INT"), sh);
> Signal.handle(new Signal("TERM"), sh);
> } catch (IllegalArgumentException e) {
> }/
> The revised code is illustrated below:
> / try {
> Signal.handle(new Signal("INT"), sh);
> } catch (IllegalArgumentException e) {
> }
> try {
> Signal.handle(new Signal("TERM"), sh);
> } catch (IllegalArgumentException e) {
> }
> /The improved version makes more sense since exception thrown from first
> Signal.handle call does not affect subsequent calls. This is more
> consistent with its original intention.
> A patch I made is available @
> http://cr.openjdk.java.net/~youdwei/ojdk-430/webrev.00//
>
> /Could anybody please take a look at it? Thanks in advance/
Can you explain the context for this change. It seems to me that there 
is an expectation that the group of signals act homogenously: all or 
none, whereas your change make it appear that the success/failure for 
each signal is independent. Understanding exactly when/why the 
IllegalArgumentException is thrown is important here.
I don't like seeing the duplicated comment, perhaps that can be factored 
out to the head of the block of code?
Thanks,
David Holmes
> Best regards,
> Frank
> /
    
    
More information about the core-libs-dev
mailing list