[SNMP4J] SNMP.close() throws java.util.ConcurrentModificationException

Frank Fock fock at agentpp.com
Wed Mar 3 23:04:55 CET 2010


Hi Andy,

The following code as replacement of the
Snmp.close() method should fix the problem:

   public void close() throws IOException {
     for (Iterator it = messageDispatcher.getTransportMappings().iterator();
          it.hasNext(); ) {
       TransportMapping tm = (TransportMapping) it.next();
       if (tm.isListening()) {
         tm.close();
       }
     }
     CommonTimer t = timer;
     timer = null;
     if (t != null) {
       t.cancel();
     }
     // close all notification listeners
     if (notificationDispatcher != null) {
       notificationDispatcher.closeAll();
     }
     List pr;
     synchronized (pendingRequests) {
       pr = new ArrayList(pendingRequests.values());
     }
     for (Iterator it = pr.iterator(); it.hasNext(); ) {
       PendingRequest pending = (PendingRequest) it.next();
       ResponseEvent e =
           new ResponseEvent(this, null, pending.pdu, null, 
pending.userObject,
                             new InterruptedException(
           "Snmp session has been closed"));
       ResponseListener l = pending.listener;
       if (l != null) {
         l.onResponse(e);
       }
     }
   }

Best regards,
Frank


On 03.03.2010 11:33, Andreas Kessler wrote:
> Hi all
>
> I use the snmp4j in JBoss, I created a resource adapter (JCA) who get
> used by several threads. If I stop the JBoss, it tries tos top the
> resource adapter, then I got this Exception:
>
> 2010-03-03 11:15:18.846 WARN [org.jboss.logging.Log4jLoggerPlugin] -
> Stopping failed jboss.jca:service=RARDeployment,name='snmp-outbound-ra.rar'
>
> java.util.ConcurrentModificationException: null
>
> at java.util.Hashtable$Enumerator.next(Hashtable.java:1031) [na:1.6.0_17]
>
> at org.snmp4j.Snmp.close(Unknown Source) [SNMP4J.jar:na]
>
> at
> ch.sohard.jca.snmp.outbound.SnmpOutboundResourceAdapter.stop(SnmpOutboundResourceAdapter.java:52)
> [snmp-outbound-ra.jar:na]
>
> at
> org.jboss.resource.deployment.RARDeployment.stopService(RARDeployment.java:114)
> [jboss-jca.jar:4.2.2.GA (build: SVNTag=JBoss_4_2_2_GA date=200710221139)]
>
> Any help would be nice!
>
> Greez Andy
>
> _______________________________________________
> SNMP4J mailing list
> SNMP4J at agentpp.org
> http://lists.agentpp.org/mailman/listinfo/snmp4j

-- 
AGENT++
http://www.agentpp.com
http://www.snmp4j.com
http://www.mibexplorer.com
http://www.mibdesigner.com




More information about the SNMP4J mailing list