hc-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Sebb (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (HTTPCORE-363) Unnecessary call to isOpen() before calling close
Date Sun, 24 Nov 2013 22:12:36 GMT

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

Sebb commented on HTTPCORE-363:
-------------------------------

The Javadoc for Channel#close() says:

"If this channel is already closed then invoking this method has no effect."

The code already catches IOException.

So I doubt that removing the check would have any effect.

> Unnecessary call to isOpen() before calling close
> -------------------------------------------------
>
>                 Key: HTTPCORE-363
>                 URL: https://issues.apache.org/jira/browse/HTTPCORE-363
>             Project: HttpComponents HttpCore
>          Issue Type: Improvement
>            Reporter: Sebb
>            Priority: Minor
>
> There are some instances of the following code:
> final Channel channel = this.key.channel();
> if (channel.isOpen()) {
>     try {
>         channel.close();
>     } catch (final IOException ignore) {}
> }
> Eclipse generates a warning that the channel might not be closed.
> Obviously that is a false positive, but why bother checking the state?
> Surely channel.close() can be repeated without harm?



--
This message was sent by Atlassian JIRA
(v6.1#6144)

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@hc.apache.org
For additional commands, e-mail: dev-help@hc.apache.org


Mime
View raw message