You are viewing a plain text version of this content. The canonical link for it is here.
Posted to xmlrpc-dev@ws.apache.org by Stanislav Miklik <st...@gmail.com> on 2006/08/02 17:54:37 UTC
Bug in xml-rpc rc1
Hello,
I have probably found a bug in WebServer.shutdown().
This call has frozen, but I don't know why.
Conditions that might affecting this:
1. I started the server with enabled extensions and enabled keepalive
(others default, if not mentioned)
2. In the same program (in another thread of course) I create client
connected to this server with enabled extensions
3. this client sends in loop requests to server (delayed for 2 seconds)
4. then I called shutdown on the server (e.g. after 10 seconds)
When I try to debug it, my debugger (Eclipse) freeze on command
pool.shutdown(); in method shutdown().
Hopefully this description will help.
Bye
Stano
Re: Bug in xml-rpc rc1
Posted by Jochen Wiedmann <jo...@gmail.com>.
Stanislav,
I believe that this problem is now fixed in the trunk and the shutdown
should be reliable now. I had to rework the WebServer/ThreadPool
framework seriously, so won't apply my changes to the stable 3.0 branch.
Jochen
---------------------------------------------------------------------
To unsubscribe, e-mail: xmlrpc-dev-unsubscribe@ws.apache.org
For additional commands, e-mail: xmlrpc-dev-help@ws.apache.org
Re: Bug in xml-rpc rc1
Posted by Stanislav Miklik <st...@gmail.com>.
On 8/2/06, Jochen Wiedmann <jo...@gmail.com> wrote:
>
>
> Following your description, I have written the small test program below.
> It works fine for me.
>
>
> Jochen
As I write before, the server was set to enabled for keapalive. I rewrite
little bit your test to more match my case. And it hasn't stopped.
package sk.sodik.server;
import java.net.URL;
import org.apache.xmlrpc.client.XmlRpcClient;
import org.apache.xmlrpc.client.XmlRpcClientConfigImpl;
import org.apache.xmlrpc.server.PropertyHandlerMapping;
import org.apache.xmlrpc.server.XmlRpcServerConfigImpl;
import org.apache.xmlrpc.webserver.WebServer;
public class ShutdownTest {
/**
* @param args
*/
public static void main(String[] args) {
try {
new ShutdownTest().testShutdown();
} catch (Exception e) {
e.printStackTrace();
}
}
public static class Adder {
public int add(int p1, int p2) {
return p1 + p2;
}
}
private WebServer setupServer() throws Exception {
WebServer server = new WebServer(0);
PropertyHandlerMapping mapping = new PropertyHandlerMapping();
mapping.addHandler("Adder", Adder.class);
server.getXmlRpcServer().setHandlerMapping(mapping);
XmlRpcServerConfigImpl config = new XmlRpcServerConfigImpl();
config.setEnabledForExtensions(true);
config.setKeepAliveEnabled(true);
server.getXmlRpcServer().setConfig(config);
server.start();
return server;
}
public void testShutdown() throws Exception {
final WebServer server = setupServer();
final int port = server.getPort();
new Thread() {
public void run() {
try {
XmlRpcClient client = new XmlRpcClient();
XmlRpcClientConfigImpl config = new XmlRpcClientConfigImpl();
config.setServerURL(new URL("http://127.0.0.1:" + port
+ "/"));
client.setConfig(config);
for (int i = 0; i < 10; i++) {
Integer result = (Integer) client
.execute("Adder.add", new Object[] {
new Integer(3), new Integer(5) });
System.out.println("Resut:"+result);
Thread.sleep(2000);
}
} catch (Exception e) {
e.printStackTrace();
}
}
}.start();
Thread.sleep(5000);
System.out.println("Shuting down...");
server.shutdown();
System.out.println("done");
}
}
Re: Bug in xml-rpc rc1
Posted by Jochen Wiedmann <jo...@gmail.com>.
Stanislav Miklik wrote:
> I have probably found a bug in WebServer.shutdown().
> This call has frozen, but I don't know why.
> Conditions that might affecting this:
> 1. I started the server with enabled extensions and enabled keepalive
> (others default, if not mentioned)
> 2. In the same program (in another thread of course) I create client
> connected to this server with enabled extensions
> 3. this client sends in loop requests to server (delayed for 2 seconds)
> 4. then I called shutdown on the server (e.g. after 10 seconds)
>
> When I try to debug it, my debugger (Eclipse) freeze on command
> pool.shutdown(); in method shutdown().
>
> Hopefully this description will help.
Following your description, I have written the small test program below.
It works fine for me.
Jochen
package org.apache.xmlrpc.test;
import java.net.URL;
import org.apache.xmlrpc.client.XmlRpcClient;
import org.apache.xmlrpc.client.XmlRpcClientConfigImpl;
import org.apache.xmlrpc.server.PropertyHandlerMapping;
import org.apache.xmlrpc.webserver.WebServer;
import junit.framework.TestCase;
/** Tests the web servers shutdown feature.
*/
public class ShutdownTest extends TestCase {
public static class Adder {
public int add(int p1, int p2) {
return p1 + p2;
}
}
private WebServer setupServer() throws Exception {
WebServer server = new WebServer(0);
PropertyHandlerMapping mapping = new PropertyHandlerMapping();
mapping.addHandler("Adder", Adder.class);
server.getXmlRpcServer().setHandlerMapping(mapping);
server.start();
return server;
}
public void testShutdown() throws Exception {
final WebServer server = setupServer();
int port = server.getPort();
XmlRpcClient client = new XmlRpcClient();
XmlRpcClientConfigImpl config = new XmlRpcClientConfigImpl();
config.setServerURL(new URL("http://127.0.0.1:" + port + "/"));
client.setConfig(config);
for (int i = 0; i < 10; i++) {
Integer result = (Integer) client.execute("Adder.add", new
Object[]{ new Integer(3), new Integer(5) });
assertEquals(8, result.intValue());
Thread.sleep(2000);
}
server.shutdown();
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: xmlrpc-dev-unsubscribe@ws.apache.org
For additional commands, e-mail: xmlrpc-dev-help@ws.apache.org