Skip to content

Restlet hangs on Engine.getInstance #1370

Open

Description

@jonfinanger

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

Activity

  1. Tembrel commented on Aug 10, 2020

    @Tembrel
    Collaborator

    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.

  2. cyberquarks commented on Mar 25, 2021

    @cyberquarks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions