You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@hc.apache.org by "Stepan Koltsov (JIRA)" <ji...@apache.org> on 2010/05/14 16:51:45 UTC
[jira] Created: (HTTPCLIENT-942) ClientConnectionRelease example is
incorrect
ClientConnectionRelease example is incorrect
--------------------------------------------
Key: HTTPCLIENT-942
URL: https://issues.apache.org/jira/browse/HTTPCLIENT-942
Project: HttpComponents HttpClient
Issue Type: Bug
Reporter: Stepan Koltsov
http://svn.apache.org/repos/asf/httpcomponents/httpclient/tags/4.0.1/httpclient/src/examples/org/apache/http/examples/client/ClientConnectionRelease.java
is incorrect: if error happens in BufferedReader constructor or in reader.readLine() (OutOfMemoryError, StackOverflowError), reader.close() is not called and connection is not released
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@hc.apache.org
For additional commands, e-mail: dev-help@hc.apache.org
[jira] Commented: (HTTPCLIENT-942) ClientConnectionRelease example
is incorrect
Posted by "Oleg Kalnichevski (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/HTTPCLIENT-942?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12878361#action_12878361 ]
Oleg Kalnichevski commented on HTTPCLIENT-942:
----------------------------------------------
> httpclient-3 allowed standard simple try { ... } finally { release something } pattern.
How is this less standard or more complex?
HttpEntity entity = response.getEntity();
if (entity != null) {
InputStream instream = entity.getContent();
try {
} finally {
instream.close();
}
}
> Do I really have to call httpget.abort() in case of unknown RuntimeException?
No, you do not.
> And why Error (like OutOfMemoryError) is not caught then?
One should never try to mess with Errors. They represent fatal, non-recoverable conditions. The best thing is to let the application terminate.
Oleg
> ClientConnectionRelease example is incorrect
> --------------------------------------------
>
> Key: HTTPCLIENT-942
> URL: https://issues.apache.org/jira/browse/HTTPCLIENT-942
> Project: HttpComponents HttpClient
> Issue Type: Bug
> Components: Examples
> Reporter: Stepan Koltsov
> Priority: Minor
> Fix For: 4.1 Alpha3
>
>
> http://svn.apache.org/repos/asf/httpcomponents/httpclient/tags/4.0.1/httpclient/src/examples/org/apache/http/examples/client/ClientConnectionRelease.java
> is incorrect:
> 1. if error happens in BufferedReader constructor (OutOfMemoryError, StackOverflowError), reader.close() is not called and connection is not released
> 2. if error happens in reader.readLine(), reader.close() is called, but httpget.abort() is not.
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@hc.apache.org
For additional commands, e-mail: dev-help@hc.apache.org
[jira] Resolved: (HTTPCLIENT-942) ClientConnectionRelease example
is incorrect
Posted by "Oleg Kalnichevski (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/HTTPCLIENT-942?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Oleg Kalnichevski resolved HTTPCLIENT-942.
------------------------------------------
Resolution: Fixed
Fixed in SVN trunk.
Oleg
> ClientConnectionRelease example is incorrect
> --------------------------------------------
>
> Key: HTTPCLIENT-942
> URL: https://issues.apache.org/jira/browse/HTTPCLIENT-942
> Project: HttpComponents HttpClient
> Issue Type: Bug
> Components: Examples
> Reporter: Stepan Koltsov
> Priority: Minor
> Fix For: 4.1 Alpha3
>
>
> http://svn.apache.org/repos/asf/httpcomponents/httpclient/tags/4.0.1/httpclient/src/examples/org/apache/http/examples/client/ClientConnectionRelease.java
> is incorrect:
> 1. if error happens in BufferedReader constructor (OutOfMemoryError, StackOverflowError), reader.close() is not called and connection is not released
> 2. if error happens in reader.readLine(), reader.close() is called, but httpget.abort() is not.
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@hc.apache.org
For additional commands, e-mail: dev-help@hc.apache.org
[jira] Commented: (HTTPCLIENT-942) ClientConnectionRelease example
is incorrect
Posted by "Stepan Koltsov (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/HTTPCLIENT-942?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12878430#action_12878430 ]
Stepan Koltsov commented on HTTPCLIENT-942:
-------------------------------------------
> How is this less standard or more complex?
I didn't know that httpget.abort() is not necessary.
However, if httpget.abort() is not necessary, then why not remove it from example?
> ClientConnectionRelease example is incorrect
> --------------------------------------------
>
> Key: HTTPCLIENT-942
> URL: https://issues.apache.org/jira/browse/HTTPCLIENT-942
> Project: HttpComponents HttpClient
> Issue Type: Bug
> Components: Examples
> Reporter: Stepan Koltsov
> Priority: Minor
> Fix For: 4.1 Alpha3
>
>
> http://svn.apache.org/repos/asf/httpcomponents/httpclient/tags/4.0.1/httpclient/src/examples/org/apache/http/examples/client/ClientConnectionRelease.java
> is incorrect:
> 1. if error happens in BufferedReader constructor (OutOfMemoryError, StackOverflowError), reader.close() is not called and connection is not released
> 2. if error happens in reader.readLine(), reader.close() is called, but httpget.abort() is not.
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@hc.apache.org
For additional commands, e-mail: dev-help@hc.apache.org
[jira] Commented: (HTTPCLIENT-942) ClientConnectionRelease example
is incorrect
Posted by "Oleg Kalnichevski (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/HTTPCLIENT-942?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12878433#action_12878433 ]
Oleg Kalnichevski commented on HTTPCLIENT-942:
----------------------------------------------
I just wanted to demonstrate all possible cases of connection release: (1) auto-release on exception (2) release without connection re-use on request abort (3) normal release with connection re-use.
Oleg
> ClientConnectionRelease example is incorrect
> --------------------------------------------
>
> Key: HTTPCLIENT-942
> URL: https://issues.apache.org/jira/browse/HTTPCLIENT-942
> Project: HttpComponents HttpClient
> Issue Type: Bug
> Components: Examples
> Reporter: Stepan Koltsov
> Priority: Minor
> Fix For: 4.1 Alpha3
>
>
> http://svn.apache.org/repos/asf/httpcomponents/httpclient/tags/4.0.1/httpclient/src/examples/org/apache/http/examples/client/ClientConnectionRelease.java
> is incorrect:
> 1. if error happens in BufferedReader constructor (OutOfMemoryError, StackOverflowError), reader.close() is not called and connection is not released
> 2. if error happens in reader.readLine(), reader.close() is called, but httpget.abort() is not.
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@hc.apache.org
For additional commands, e-mail: dev-help@hc.apache.org
[jira] Updated: (HTTPCLIENT-942) ClientConnectionRelease example is
incorrect
Posted by "Stepan Koltsov (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/HTTPCLIENT-942?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Stepan Koltsov updated HTTPCLIENT-942:
--------------------------------------
Description:
http://svn.apache.org/repos/asf/httpcomponents/httpclient/tags/4.0.1/httpclient/src/examples/org/apache/http/examples/client/ClientConnectionRelease.java
is incorrect:
1. if error happens in BufferedReader constructor (OutOfMemoryError, StackOverflowError), reader.close() is not called and connection is not released
2. if error happens in reader.readLine(), reader.close() is called, but httpget.abort() is not.
was:
http://svn.apache.org/repos/asf/httpcomponents/httpclient/tags/4.0.1/httpclient/src/examples/org/apache/http/examples/client/ClientConnectionRelease.java
is incorrect: if error happens in BufferedReader constructor or in reader.readLine() (OutOfMemoryError, StackOverflowError), reader.close() is not called and connection is not released
> ClientConnectionRelease example is incorrect
> --------------------------------------------
>
> Key: HTTPCLIENT-942
> URL: https://issues.apache.org/jira/browse/HTTPCLIENT-942
> Project: HttpComponents HttpClient
> Issue Type: Bug
> Reporter: Stepan Koltsov
>
> http://svn.apache.org/repos/asf/httpcomponents/httpclient/tags/4.0.1/httpclient/src/examples/org/apache/http/examples/client/ClientConnectionRelease.java
> is incorrect:
> 1. if error happens in BufferedReader constructor (OutOfMemoryError, StackOverflowError), reader.close() is not called and connection is not released
> 2. if error happens in reader.readLine(), reader.close() is called, but httpget.abort() is not.
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@hc.apache.org
For additional commands, e-mail: dev-help@hc.apache.org
[jira] Commented: (HTTPCLIENT-942) ClientConnectionRelease example
is incorrect
Posted by "Stepan Koltsov (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/HTTPCLIENT-942?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12878320#action_12878320 ]
Stepan Koltsov commented on HTTPCLIENT-942:
-------------------------------------------
Thank you.
Do I really have to call httpget.abort() in case of unknown RuntimeException? And why Error (like OutOfMemoryError) is not caught then?
httpclient-3 allowed standard simple try { ... } finally { release something } pattern.
method = ...
try {
httpclient.execute(method);
// do whatever I want
} finally {
method.releaseConnection();
}
It is sad, if it is not possible in httpclient-4 (ResponseHandler is not an option in some cases).
> ClientConnectionRelease example is incorrect
> --------------------------------------------
>
> Key: HTTPCLIENT-942
> URL: https://issues.apache.org/jira/browse/HTTPCLIENT-942
> Project: HttpComponents HttpClient
> Issue Type: Bug
> Components: Examples
> Reporter: Stepan Koltsov
> Priority: Minor
> Fix For: 4.1 Alpha3
>
>
> http://svn.apache.org/repos/asf/httpcomponents/httpclient/tags/4.0.1/httpclient/src/examples/org/apache/http/examples/client/ClientConnectionRelease.java
> is incorrect:
> 1. if error happens in BufferedReader constructor (OutOfMemoryError, StackOverflowError), reader.close() is not called and connection is not released
> 2. if error happens in reader.readLine(), reader.close() is called, but httpget.abort() is not.
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@hc.apache.org
For additional commands, e-mail: dev-help@hc.apache.org
[jira] Updated: (HTTPCLIENT-942) ClientConnectionRelease example is
incorrect
Posted by "Oleg Kalnichevski (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/HTTPCLIENT-942?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Oleg Kalnichevski updated HTTPCLIENT-942:
-----------------------------------------
Fix Version/s: 4.1 Alpha3
Priority: Minor (was: Major)
Component/s: Examples
> 1. if error happens in BufferedReader constructor (OutOfMemoryError, StackOverflowError), reader.close()
> is not called and connection is not released
If your application throws OutOfMemoryError or StackOverflowError, you have much more to worry about than a leaked connection, but strictly speaking you are correct
> 2. if error happens in reader.readLine(), reader.close() is called, but httpget.abort() is not.
This is incorrect. HttpClient will automatically release the underlying connection upon an I/O error. Calling HttpGet#abort is not necessary.
Oleg
> ClientConnectionRelease example is incorrect
> --------------------------------------------
>
> Key: HTTPCLIENT-942
> URL: https://issues.apache.org/jira/browse/HTTPCLIENT-942
> Project: HttpComponents HttpClient
> Issue Type: Bug
> Components: Examples
> Reporter: Stepan Koltsov
> Priority: Minor
> Fix For: 4.1 Alpha3
>
>
> http://svn.apache.org/repos/asf/httpcomponents/httpclient/tags/4.0.1/httpclient/src/examples/org/apache/http/examples/client/ClientConnectionRelease.java
> is incorrect:
> 1. if error happens in BufferedReader constructor (OutOfMemoryError, StackOverflowError), reader.close() is not called and connection is not released
> 2. if error happens in reader.readLine(), reader.close() is called, but httpget.abort() is not.
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@hc.apache.org
For additional commands, e-mail: dev-help@hc.apache.org