[SNMP4J] IllegalStateException
Frank Fock
fock at agentpp.com
Tue Aug 17 22:22:29 CEST 2004
Hello Brian,
You are probably using very small timeout values?
Nevertheless, the SNMP4J code can be improved as
follows to avoid this exception:
if (pendingRequests.get(key) != null) {
logger.debug("running pending request with handle" + key);
PendingRequest nextRetry = new PendingRequest(this);
long delay =
timeoutModel.getRetryTimeout(target.getRetries()-retryCount,
target.getRetries(),
target.getTimeout());
timer.schedule(nextRetry, delay);
// register pending request not before it is scheduled
pendingRequests.put(key, nextRetry);
}
Please let me know if this fixes the problem.
Thanks in advance,
Frank
Brian_Teravskis at cargill.com wrote:
>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.
>_______________________________________________
>SNMP4J mailing list
>SNMP4J at agentpp.org
>http://p15141779.pureserver.info/mailman/listinfo/snmp4j
>
>
>
More information about the SNMP4J
mailing list