[SNMP4J] IllegalStateException

Brian_Teravskis at cargill.com Brian_Teravskis at cargill.com
Tue Aug 17 18:23:24 CEST 2004


Hello,

I'm using snmp4j for ARP cache gathering of network devices, and the
poller I wrote generated the following error message to the console:

java.lang.IllegalStateException: Task already scheduled or cancelled
        at java.util.Timer.sched(Unknown Source)
        at java.util.Timer.schedule(Unknown Source)
        at org.snmp4j.Snmp$PendingRequest.run(Snmp.java:670)
        at java.util.TimerThread.mainLoop(Unknown Source)
        at java.util.TimerThread.run(Unknown Source)

The origin of the problem seems to be:

    public void run() {
      if (retryCount > 0) {
        retryCount--;
        try {
          send(pdu, target);
          if (pendingRequests.get(key) != null) {
            logger.debug("running pending request with handle" + key);
            PendingRequest nextRetry = new PendingRequest(this);
            pendingRequests.put(key, nextRetry);
            long delay =
 
timeoutModel.getRetryTimeout(target.getRetries()-retryCount,
                                             target.getRetries(),
                                             target.getTimeout());
 -->        timer.schedule(nextRetry, delay);
          }
        }

It appears that this exception is not being caught and handled, and
therefore the error. My thread is catching IOException and then
Exception, and is not seeing this exception being thrown by the SNMP4J
routines. The thread I wrote appears to hang when this exception happens
waiting for a reponse. This is not a repeatable event. I've run this
poller several times without any issues. I'm doing the SNMP getnext with
a timeout of 5000 and a retry of 2.

If any further information is required let me know.



More information about the SNMP4J mailing list