[SNMP4J] How are TableUtils errors handled?

Christian Hecimovic checimovic at gmail.com
Sat Jul 14 19:19:23 CEST 2007


I have a question about the async version of TableUtils.getTable(). Consider
the following simple code:

synchronized(m_snmp)
{
    TableUtils tableUtils = new TableUtils(m_snmp, pduFactory);
    tableUtils.setMaxNumRowsPerPDU(m_maxRepetitions);
    tableUtils.getTable(m_target, oids, listener, m_snmp, null, null);

    try
    {
        m_snmp.wait();
    }
    catch (InterruptedException ex)
    {
        // Do nothing.
    }
}


Notice that the call to wait() does not have a timeout. Instead, the thread
is notified in the listener's finish(). I have noticed that if getTable()
has an error, finish() never appears to get called, and the calling thread
blocks forever.

Should I wake up the thread when I detect an error in next() (that is, when
next() is to return false)? Or should I always make the call to wait
something like this:

m_snmp(wait(m_target.getTimeout());

It seems to me that finished() should always be called, even when there is
an error inside getTable().

Thanks for any advice.

Christian



More information about the SNMP4J mailing list