You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@curator.apache.org by "Paolo Antinori (JIRA)" <ji...@apache.org> on 2015/05/11 17:56:59 UTC

[jira] [Commented] (CURATOR-208) InterProcessSemaphoreV2 swallows InterruptedException

    [ https://issues.apache.org/jira/browse/CURATOR-208?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14538088#comment-14538088 ] 

Paolo Antinori commented on CURATOR-208:
----------------------------------------

Hi I have recently hit the same problem and I don't think the suggested code can fix it.

The highlighted block is in a sublass of {{Lease}} that extends {{Closable}} that is the original place where {{close()}} is defined.

The original definition is:

{code:java}
public interface Closeable extends AutoCloseable {

    /**
     * Closes this stream and releases any system resources associated
     * with it. If the stream is already closed then invoking this
     * method has no effect.
     *
     * @throws IOException if an I/O error occurs
     */
    public void close() throws IOException;
}
{code}

So we cannot add an additional checked Exception to its signature.

I did a test thrown an unchecked exception and fixed the problem for me, despite being not particularly tidy.

> InterProcessSemaphoreV2 swallows InterruptedException
> -----------------------------------------------------
>
>                 Key: CURATOR-208
>                 URL: https://issues.apache.org/jira/browse/CURATOR-208
>             Project: Apache Curator
>          Issue Type: Bug
>          Components: Recipes
>    Affects Versions: 2.6.0, 2.7.1
>            Reporter: Alexei Osipov
>            Priority: Minor
>              Labels: easyfix
>
> {{InterProcessSemaphoreV2}} incorrectly processes {{InterruptedException}}.
> Method `InterProcessSemaphoreV2#makeLease(final String path)` contains code block
> {code}
>                 try
>                 {
>                     client.delete().guaranteed().forPath(path);
>                 }
>                 catch ( KeeperException.NoNodeException e )
>                 {
>                     log.warn("Lease already released", e);
>                 }
>                 catch ( Exception e )
>                 {
>                     throw new IOException(e);
>                 }
> {code}
> The problem is that code in {{try}} block may throw an {{InterruptedException}} and this exception gets wrapped into {{IOException}} so it becomes very problematic to handle it properly.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)