[SNMP4J] ConcurrentModificationException in tabular data
Frank Fock
fock at agentpp.com
Tue Mar 21 00:28:28 CET 2006
Hi Fabian,
Indeed something strange must have happened.
The following change within the TableUtils
class should avoid the exception:
class InternalTableListener implements TableListener {
private List rows = new LinkedList();
public boolean next(TableEvent event) {
rows.add(event);
return true;
}
public synchronized void finished(TableEvent event) {
if ((event.getStatus() != TableEvent.STATUS_OK) ||
(event.getIndex() != null)) {
rows.add(event);
}
rows = new ArrayList(rows);
notify();
}
public List getRows() {
return rows;
}
}
The change should be also in the next nightly build
available from http://www.agentpp.org/~katzwww/snapshot/
(Note: The CVS snapshots are still experimental)
Best regards,
Frank
Fabian Nart wrote:
> Hi,
>
> I'm having trouble while retrieving tabular SNMP-data and proceed it
> with an Iterator. When I iterate through the received list of
> tableevents I get a ConcurrentModificationException. However, I'm pretty
> sure that my code doesn't touch the list at all (see code below).
>
> The exception occurs in the line marked with ###. The _snmp is a
> reference to the single Snmp-object in my system. Is it possible that
> somewhere inside SNMP4j the returned List is modified after I've created
> my Iterator? (I've looked at the source but didn't see anything suspect,
> but maybe I overlooked something)
>
> Unfortunately, I cannot reproduce this failure, it just showed up a few
> times -- but it should never occur, of course.
>
> I'm grateful for any comments
> Fabian
>
>
> --- Code ----------------------------------------------------
>
> TableUtils tu= new TableUtils(_snmp, new DefaultPDUFactory(PDU.GETBULK));
>
> List rows= tu.getTable(_target, oids, lowerBoundIndex, upperBoundIndex);
>
> for (Iterator i= rows.iterator(); i.hasNext();) {
> TableEvent row= (TableEvent) i.next(); // ###
> (...)
> }
>
> --- / Code --------------------------------------------------
> _______________________________________________
> SNMP4J mailing list
> SNMP4J at agentpp.org
> http://lists.agentpp.org/mailman/listinfo/snmp4j
--
AGENT++
http://www.agentpp.com
http://www.mibexplorer.com
http://www.mibdesigner.com
More information about the SNMP4J
mailing list