Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Restlet hangs on Engine.getInstance #1370

Open
jonfinanger opened this issue Aug 7, 2020 · 2 comments
Open

Restlet hangs on Engine.getInstance #1370

jonfinanger opened this issue Aug 7, 2020 · 2 comments

Comments

@jonfinanger
Copy link

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

@Tembrel
Copy link
Collaborator

Tembrel commented Aug 10, 2020

What Restlet version is this? I see some problems with the most recent code, but I don't see an Object.wait in HttpProtocolHelper.registerMethods.

To work around this, call Engine.getInstance in each thread before calling any other Restlet methods.

Restlet folks: Probably best not to use static synchronized to guard access to the singleton. Also, the call to an abstract method in the constructor of ProtocolHelper looks a bit dicey.

@cyberquarks

This comment has been minimized.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants