You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@hc.apache.org by "Gabriel Klein (JIRA)" <ji...@apache.org> on 2006/09/08 01:17:22 UTC

[jira] Commented: (HTTPCORE-12) "finally" bug in samples

    [ http://issues.apache.org/jira/browse/HTTPCORE-12?page=comments#action_12433269 ] 
            
Gabriel Klein commented on HTTPCORE-12:
---------------------------------------

1      {
2         .....
3                if (!connStrategy.keepAlive(response, context)) {
4                    conn.close();
5               } else {
6                    System.out.println("Connection kept alive...");
7                }
8            }
9        } finally {
10            conn.close();
11        } 

You want to close => 1,2,3,4,6,8,9,10 => 2 times conn.close
You don't want to close => 1,2,3,5,6,7,8,9,10 => 1 time conn.close

> "finally" bug in samples
> ------------------------
>
>                 Key: HTTPCORE-12
>                 URL: http://issues.apache.org/jira/browse/HTTPCORE-12
>             Project: HttpComponents Core
>          Issue Type: Bug
>          Components: Examples
>         Environment: All
>            Reporter: Gabriel Klein
>
> In code
> http://svn.apache.org/repos/asf/jakarta/httpcomponents/httpcore/trunk/module-main/src/examples/org/apache/http/examples/ElementalHttpGet.java
> and
> http://svn.apache.org/repos/asf/jakarta/httpcomponents/httpcore/trunk/module-main/src/examples/org/apache/http/examples/ElementalHttpPost.java
> You have
>       {
>           .....
>                 if (!connStrategy.keepAlive(response, context)) {
>                     conn.close();
>                 } else {
>                     System.out.println("Connection kept alive...");
>                 }
>             }
>         } finally {
>             conn.close();
>         }   
> The problem is that "conn.close();" is called everytime... even if you "System.out.println("Connection kept alive...");".

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

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