You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@hc.apache.org by "Asankha C. Perera (JIRA)" <ji...@apache.org> on 2007/01/12 19:23:27 UTC
[jira] Created: (HTTPCORE-23) Threading issue with NIO extensions
for client side code
Threading issue with NIO extensions for client side code
--------------------------------------------------------
Key: HTTPCORE-23
URL: https://issues.apache.org/jira/browse/HTTPCORE-23
Project: HttpComponents Core
Issue Type: Bug
Components: HttpCore NIO
Affects Versions: 4.0-alpha3
Reporter: Asankha C. Perera
I would like to write a non-blocking client based on the NIO extensions, but encounter an issue, which could be reproduced with a modified NHttpClient example code as follows:
I want to start off a ConnectingIOReactor, and leave it running continuously. Now, whenever I want to send a request through this reactor, I would want to execute something like
ioReactor.connect(
new InetSocketAddress("www.yahoo.com", 80),
null,
new HttpHost("www.yahoo.com"));
However, if I execute the above before I execute ioReactor.execute(ioEventDispatch), i.e position 1, then everything works fine. If I try it after (i.e. position 2) the outcome is unpredictable - i.e. works sometimes, NPE, etc..
It is not clear to me why connecting to the reactor after its execute() method is invoked should be any different..?
public static void main(String[] args) throws Exception {
HttpParams params = new DefaultHttpParams(null);
.....
NHttpClientHandler handler = new MyNHttpClientHandler(params);
final IOEventDispatch ioEventDispatch = new DefaultClientIOEventDispatch(handler, params);
// position 1 Thread t = new Thread(new Runnable() {
public void run() {
try {
ioReactor.execute(ioEventDispatch);
} catch (Exception e) {
e.printStackTrace();
}
}
}
);
t.start();
// position 2
}
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: https://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
---------------------------------------------------------------------
To unsubscribe, e-mail: httpcomponents-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: httpcomponents-dev-help@jakarta.apache.org
[jira] Resolved: (HTTPCORE-23) Threading issue with NIO extensions
for client side code
Posted by "Oleg Kalnichevski (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/HTTPCORE-23?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Oleg Kalnichevski resolved HTTPCORE-23.
---------------------------------------
Patch reviewed and checked in
Many thanks, Asankha
Oleg
> Threading issue with NIO extensions for client side code
> --------------------------------------------------------
>
> Key: HTTPCORE-23
> URL: https://issues.apache.org/jira/browse/HTTPCORE-23
> Project: HttpComponents Core
> Issue Type: Bug
> Components: HttpCore NIO
> Affects Versions: 4.0-alpha3
> Reporter: Asankha C. Perera
> Assigned To: Oleg Kalnichevski
> Priority: Critical
> Fix For: 4.0-alpha4
>
> Attachments: nio_patch_1.patch
>
>
> I would like to write a non-blocking client based on the NIO extensions, but encounter an issue, which could be reproduced with a modified NHttpClient example code as follows:
> I want to start off a ConnectingIOReactor, and leave it running continuously. Now, whenever I want to send a request through this reactor, I would want to execute something like
> ioReactor.connect(
> new InetSocketAddress("www.yahoo.com", 80),
> null,
> new HttpHost("www.yahoo.com"));
> However, if I execute the above before I execute ioReactor.execute(ioEventDispatch), i.e position 1, then everything works fine. If I try it after (i.e. position 2) the outcome is unpredictable - i.e. works sometimes, NPE, etc..
> It is not clear to me why connecting to the reactor after its execute() method is invoked should be any different..?
> public static void main(String[] args) throws Exception {
> HttpParams params = new DefaultHttpParams(null);
> .....
> NHttpClientHandler handler = new MyNHttpClientHandler(params);
> final IOEventDispatch ioEventDispatch = new DefaultClientIOEventDispatch(handler, params);
> // position 1 Thread t = new Thread(new Runnable() {
> public void run() {
> try {
> ioReactor.execute(ioEventDispatch);
> } catch (Exception e) {
> e.printStackTrace();
> }
> }
> }
> );
> t.start();
> // position 2
> }
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: https://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
---------------------------------------------------------------------
To unsubscribe, e-mail: httpcomponents-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: httpcomponents-dev-help@jakarta.apache.org
[jira] Assigned: (HTTPCORE-23) Threading issue with NIO extensions
for client side code
Posted by "Oleg Kalnichevski (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/HTTPCORE-23?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Oleg Kalnichevski reassigned HTTPCORE-23:
-----------------------------------------
Assignee: Oleg Kalnichevski
> Threading issue with NIO extensions for client side code
> --------------------------------------------------------
>
> Key: HTTPCORE-23
> URL: https://issues.apache.org/jira/browse/HTTPCORE-23
> Project: HttpComponents Core
> Issue Type: Bug
> Components: HttpCore NIO
> Affects Versions: 4.0-alpha3
> Reporter: Asankha C. Perera
> Assigned To: Oleg Kalnichevski
> Fix For: 4.0-alpha4
>
> Attachments: nio_patch_1.patch
>
>
> I would like to write a non-blocking client based on the NIO extensions, but encounter an issue, which could be reproduced with a modified NHttpClient example code as follows:
> I want to start off a ConnectingIOReactor, and leave it running continuously. Now, whenever I want to send a request through this reactor, I would want to execute something like
> ioReactor.connect(
> new InetSocketAddress("www.yahoo.com", 80),
> null,
> new HttpHost("www.yahoo.com"));
> However, if I execute the above before I execute ioReactor.execute(ioEventDispatch), i.e position 1, then everything works fine. If I try it after (i.e. position 2) the outcome is unpredictable - i.e. works sometimes, NPE, etc..
> It is not clear to me why connecting to the reactor after its execute() method is invoked should be any different..?
> public static void main(String[] args) throws Exception {
> HttpParams params = new DefaultHttpParams(null);
> .....
> NHttpClientHandler handler = new MyNHttpClientHandler(params);
> final IOEventDispatch ioEventDispatch = new DefaultClientIOEventDispatch(handler, params);
> // position 1 Thread t = new Thread(new Runnable() {
> public void run() {
> try {
> ioReactor.execute(ioEventDispatch);
> } catch (Exception e) {
> e.printStackTrace();
> }
> }
> }
> );
> t.start();
> // position 2
> }
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: https://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
---------------------------------------------------------------------
To unsubscribe, e-mail: httpcomponents-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: httpcomponents-dev-help@jakarta.apache.org
[jira] Updated: (HTTPCORE-23) Threading issue with NIO extensions
for client side code
Posted by "Asankha C. Perera (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/HTTPCORE-23?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Asankha C. Perera updated HTTPCORE-23:
--------------------------------------
Attachment: nio_patch_1.patch
> Threading issue with NIO extensions for client side code
> --------------------------------------------------------
>
> Key: HTTPCORE-23
> URL: https://issues.apache.org/jira/browse/HTTPCORE-23
> Project: HttpComponents Core
> Issue Type: Bug
> Components: HttpCore NIO
> Affects Versions: 4.0-alpha3
> Reporter: Asankha C. Perera
> Attachments: nio_patch_1.patch
>
>
> I would like to write a non-blocking client based on the NIO extensions, but encounter an issue, which could be reproduced with a modified NHttpClient example code as follows:
> I want to start off a ConnectingIOReactor, and leave it running continuously. Now, whenever I want to send a request through this reactor, I would want to execute something like
> ioReactor.connect(
> new InetSocketAddress("www.yahoo.com", 80),
> null,
> new HttpHost("www.yahoo.com"));
> However, if I execute the above before I execute ioReactor.execute(ioEventDispatch), i.e position 1, then everything works fine. If I try it after (i.e. position 2) the outcome is unpredictable - i.e. works sometimes, NPE, etc..
> It is not clear to me why connecting to the reactor after its execute() method is invoked should be any different..?
> public static void main(String[] args) throws Exception {
> HttpParams params = new DefaultHttpParams(null);
> .....
> NHttpClientHandler handler = new MyNHttpClientHandler(params);
> final IOEventDispatch ioEventDispatch = new DefaultClientIOEventDispatch(handler, params);
> // position 1 Thread t = new Thread(new Runnable() {
> public void run() {
> try {
> ioReactor.execute(ioEventDispatch);
> } catch (Exception e) {
> e.printStackTrace();
> }
> }
> }
> );
> t.start();
> // position 2
> }
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: https://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
---------------------------------------------------------------------
To unsubscribe, e-mail: httpcomponents-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: httpcomponents-dev-help@jakarta.apache.org
[jira] Updated: (HTTPCORE-23) Threading issue with NIO extensions
for client side code
Posted by "Oleg Kalnichevski (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/HTTPCORE-23?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Oleg Kalnichevski updated HTTPCORE-23:
--------------------------------------
Fix Version/s: 4.0-alpha4
Priority: Critical (was: Major)
> Threading issue with NIO extensions for client side code
> --------------------------------------------------------
>
> Key: HTTPCORE-23
> URL: https://issues.apache.org/jira/browse/HTTPCORE-23
> Project: HttpComponents Core
> Issue Type: Bug
> Components: HttpCore NIO
> Affects Versions: 4.0-alpha3
> Reporter: Asankha C. Perera
> Assigned To: Oleg Kalnichevski
> Priority: Critical
> Fix For: 4.0-alpha4
>
> Attachments: nio_patch_1.patch
>
>
> I would like to write a non-blocking client based on the NIO extensions, but encounter an issue, which could be reproduced with a modified NHttpClient example code as follows:
> I want to start off a ConnectingIOReactor, and leave it running continuously. Now, whenever I want to send a request through this reactor, I would want to execute something like
> ioReactor.connect(
> new InetSocketAddress("www.yahoo.com", 80),
> null,
> new HttpHost("www.yahoo.com"));
> However, if I execute the above before I execute ioReactor.execute(ioEventDispatch), i.e position 1, then everything works fine. If I try it after (i.e. position 2) the outcome is unpredictable - i.e. works sometimes, NPE, etc..
> It is not clear to me why connecting to the reactor after its execute() method is invoked should be any different..?
> public static void main(String[] args) throws Exception {
> HttpParams params = new DefaultHttpParams(null);
> .....
> NHttpClientHandler handler = new MyNHttpClientHandler(params);
> final IOEventDispatch ioEventDispatch = new DefaultClientIOEventDispatch(handler, params);
> // position 1 Thread t = new Thread(new Runnable() {
> public void run() {
> try {
> ioReactor.execute(ioEventDispatch);
> } catch (Exception e) {
> e.printStackTrace();
> }
> }
> }
> );
> t.start();
> // position 2
> }
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: https://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
---------------------------------------------------------------------
To unsubscribe, e-mail: httpcomponents-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: httpcomponents-dev-help@jakarta.apache.org