[SNMP4J] restart of TestAgent failed when loading a previous saved configuration

bernhard.kling at sdm.de bernhard.kling at sdm.de
Thu May 10 21:23:13 CEST 2007




Hi,

I made some tests with snmp4j TestAgent and found the following behavior:
Test agent did not start correctly, when a config file is present.

The reason is an infinite loop in DefaultMOTable.removeAll() during loading the previous saved configuration.  
 

Further analysis showed the following:
	
During loadConfig(...) removeAll was called for vacmContextTable, which is using VacmContextTableModel.
This caused an infinite loop in the following code snippet of DefaultMOTable.removeAll()
    
	while (model.getRowCount() > 0) {
    		MOTableRow row = model.firstRow();
      	if (row != null) {
		...
	}

	
Although model.getRowCount() returned '1', model.firstRow() returned 'null'.
The reason for model.firstRow() returned 'null' can be found in the method firstIndex() of class VacmContextTableModel in VacmMIB.java. 
	
	public OID firstIndex() {
      	OctetString[] contexts = server.getContexts();
            if ((contexts == null) || (contexts.length > 0)) {
	        return null;
      	} 
	...


I tested, to change 
	'if ((contexts == null) || (contexts.length > 0))' 
to 
	if ((contexts == null) || (contexts.length == 0))

This eliminated the infinite loop, but caused another problem.
The following cast 
	((MOMutableTableModel)model).removeRow(row.getIndex());
in DefaultMOTable.removeAll()resulted in a class cast exception, because VacmContextTableModel implements MOTableModel, but not MOMutableTableModel.


Whats wrong with my test?
Is there any way to load a previous saved configuration?

Thanks,
Bernhard


 



 



More information about the SNMP4J mailing list