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

Frank Fock fock at agentpp.com
Fri May 11 00:03:14 CEST 2007


Hi Bernhard,

The context table should be a volatile table. Then the removeAll()
would not be called. Nevertheless, I have fixed it towards not throwing
an exception if called though.

The VacmMIB implementation can fixed with the following patch:

@@ -191,6 +191,7 @@
      this.vacmContextTable =
          new DefaultMOTable(vacmContextEntryOID, vacmContextTableIndex,
                             vacmContextColumns);
+    this.vacmContextTable.setVolatile(true);
      this.vacmContextTable.setModel(new VacmContextTableModel());
    }

@@ -820,7 +821,7 @@

      public OID firstIndex() {
        OctetString[] contexts = server.getContexts();
-      if ((contexts == null) || (contexts.length > 0)) {
+      if ((contexts == null) || (contexts.length == 0)) {
          return null;
        }
        Arrays.sort(contexts, new LexicographicOctetStringComparator());

Best regards,
Frank

bernhard.kling at sdm.de wrote:
> 
> 
> 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
> 
> 
>  
> 
> 
> 
>  
> _______________________________________________
> 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