Hi,

We have found quite a critical bug in 
org.snmp4j.util.ThreadPool.execute(WorkerTask task) method. It has an execute 
method below

    public synchronized void execute(WorkerTask task)
    {
        while (true)
        {
            // here we check if some TaskManager-thread is free to execute the 
task.
            try
            {
                wait(); // wait until some TaskManager-thread notify that it 
finished a previous task
            }
            catch (InterruptedException ex)
            {
                Thread.currentThread().interrupt();
            }
        }
     }

If  InterruptedException is thrown, so our thread goes into cycle and keep the 
lock on the ThreadPool object, so TaskManager-threads cannot notify that they 
became free as soon as they blocked on the ThreadPool. So if the interrupt was 
called when NO TaskManager-threads were free to execute the task, so the 
process just hangs.

There is a simple way to fix it. We need just to break the cycle if the process 
was interrupted and not to execute task like below.

    public synchronized void execute(WorkerTask task)
    {
       try
        {

           while (true)
           {
               // here we check if some TaskManager-thread is free to execute 
the task
               wait();// wait until some TaskManager-thread notify that it 
finished a previous task
           }
        catch (InterruptedException ex)
        {
           Thread.currentThread().interrupt();
        }

    }

Thanks,

Dmitrii Krendelev



________________________________
The information transmitted herein is intended only for the person or entity to 
which it is addressed and may contain confidential, proprietary and/or 
privileged material. Any review, retransmission, dissemination or other use of, 
or taking of any action in reliance upon, this information by persons or 
entities other than the intended recipient is prohibited. If you received this 
in error, please contact the sender and delete the material from any computer.
_______________________________________________
SNMP4J mailing list
[email protected]
https://oosnmp.net/mailman/listinfo/snmp4j

Reply via email to