RestComm / jain-sip

Disclaimer: This repository is a git-svn mirror of the project found at http://java.net/projects/jsip whose original repository is developed collaboratively by the Advanced Networking Technologies Division at the National Institute of Standards and Technology (NIST) - an agency of the United States Department of Commerce and by a community of individual and enterprise contributors. TeleStax, Inc. will perform some productization work, new features experimentation branches, etc for its TelScale jSIP product that doesn't concern the community from the main repository hence this git repository.
http://www.restcomm.com/
144 stars 152 forks source link

EventScanner hands infinitely on stack shutdown #198

Open RomanValov opened 1 year ago

RomanValov commented 1 year ago

Hi

please consider following minimal code example:

import javax.sip.*;

class Test implements SipListener {

    public static void main(String[] args) {
        try {
            SipFactory sipFactory = SipFactory.getInstance();
            sipFactory.setPathName("gov.nist");
            java.util.Properties properties = new java.util.Properties();
            properties.setProperty("javax.sip.STACK_NAME", "test");

            SipStack sipStack = sipFactory.createSipStack(properties);
            sipStack.stop();
        } catch (Exception ex) {
            ex.printStackTrace();
        }
    }

    @Override
    public void processRequest(RequestEvent requestEvent) {
    }

    @Override
    public void processResponse(ResponseEvent responseEvent) {
    }

    @Override
    public void processTimeout(javax.sip.TimeoutEvent timeoutEvent) {
    }

    @Override
    public void processIOException(IOExceptionEvent exceptionEvent) {
    }

    @Override
    public void processTransactionTerminated(
            TransactionTerminatedEvent transactionTerminatedEvent) {
    }

    @Override
    public void processDialogTerminated(
            DialogTerminatedEvent dialogTerminatedEvent) {
    }
}

When executed this code hands forever. Thread dump shows that EventScanner thread is stuck:

"EventScannerThread" #11 prio=5 os_prio=0 cpu=0.82ms elapsed=2.13s tid=0x00007fc04c3e4000 nid=0x17 waiting on condition  [0x00007fc025efd000]
   java.lang.Thread.State: WAITING (parking)
    at jdk.internal.misc.Unsafe.park(java.base@11.0.18/Native Method)
    - parking to wait for  <0x00000000b64cb608> (a java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject)
    at java.util.concurrent.locks.LockSupport.park(java.base@11.0.18/LockSupport.java:194)
    at java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.await(java.base@11.0.18/AbstractQueuedSynchronizer.java:2081)
    at java.util.concurrent.LinkedBlockingQueue.take(java.base@11.0.18/LinkedBlockingQueue.java:433)
    at gov.nist.javax.sip.EventScanner.run(EventScanner.java:512)
    at java.lang.Thread.run(java.base@11.0.18/Thread.java:829)

Registering listener and listening points doesn't affect the issue.