restlet-framework-java icon indicating copy to clipboard operation
restlet-framework-java copied to clipboard

Restlet hangs on Engine.getInstance

Open jonfinanger opened this issue 4 years ago • 2 comments

I have to modules (different threads) accessing restlet api in my java application. The first module uses the ClientResource and connects to a remte server. The other acts as a restserver using new Component() waiting for requests.....

The modules starts about at the same time. Once a while i experience a "freeze" in the startup of the modules. And the stacktrace shows this every time it hangs:

Module 1: #46 daemon prio=5 os_prio=0 tid=0x15e72000 nid=0x3444 waiting for monitor entry [0x1684f000] java.lang.Thread.State: BLOCKED (on object monitor) at org.restlet.engine.Engine.getInstance(Engine.java:249) - waiting to lock <0x09938838> (a java.lang.Class for org.restlet.engine.Engine) at org.restlet.data.Method.<clinit>(Method.java:337) at org.restlet.resource.ClientResource.<init>(ClientResource.java:396)

Module2: #50 daemon prio=5 os_prio=0 tid=0x15e6f400 nid=0x3774 in Object.wait() [0x167bf000] java.lang.Thread.State: RUNNABLE at org.restlet.engine.connector.HttpProtocolHelper.registerMethods(HttpProtocolHelper.java:39) at org.restlet.engine.connector.ProtocolHelper.<init>(ProtocolHelper.java:42) at org.restlet.engine.connector.HttpProtocolHelper.<init>(HttpProtocolHelper.java:35) at org.restlet.engine.Engine.registerDefaultProtocols(Engine.java:867) at org.restlet.engine.Engine.discoverProtocols(Engine.java:680) at org.restlet.engine.Engine.<init>(Engine.java:492) at org.restlet.engine.Engine.register(Engine.java:382) - locked <0x09938838> (a java.lang.Class for org.restlet.engine.Engine) at org.restlet.engine.Engine.register(Engine.java:368) - locked <0x09938838> (a java.lang.Class for org.restlet.engine.Engine) at org.restlet.engine.Engine.getInstance(Engine.java:252) - locked <0x09938838> (a java.lang.Class for org.restlet.engine.Engine) at org.restlet.Restlet.<init>(Restlet.java:122) at org.restlet.Restlet.<init>(Restlet.java:99) at org.restlet.Component.<init>(Component.java:173)

The first thread is waiting for the second in a blocked state. It looks to me that the second thread is causing the blocking, but i'm not clear on why the second thread never releases the monitor

jonfinanger avatar Aug 07 '20 14:08 jonfinanger