[SNMP4J] Issue when a PDU contains two SETs for a table row status with a value of 6 to destroy when one row exists and the other row does not exist

Broderick, Don donb at mitre.org
Wed Aug 9 16:54:29 CEST 2017


SNMP4J version 2.5.6
SNMP4J-Agent version 2.6.0

I have discovered the following behavior inconsistency where I would expect no error to be returned in both cases.

When a PDU is sent containing one SET of a row status to 6 for destroy for a row that exists the row is destroyed and no error is returned.  Performing the same operation in a separate PDU for a row that does not exist again returns no error.  When a PDU containing 2 SETs, one for a row that exists and one for a row that does not exist (both in the same table) a commit failed error is returned and the row that existed is destroyed.

In the line highlighted below of DefaultMOTable the variable "row" has a null value when this event occurs and causes a null pointer exception.

  public void commit(SubRequest request) {
    OID cellOID = request.getVariableBinding().getOid();
    MOTableCellInfo cell = getCellInfo(cellOID);
    MOMutableColumn col = (MOMutableColumn) getColumn(cell.getColumn());
    if (logger.isDebugEnabled()) {
      logger.debug("Committing sub-request ("+
                   request.getVariableBinding()+") for column: "+col);
    }
    // Make sure changes are atomic -> sync whole table model
    synchronized (model) {
      R row;
      if (hasNewRows(request.getRequest())) {
        row = getNewRows(request.getRequest()).get(cell.getIndex());
        // check if row has been added already
        if (!model.containsRow(row.getIndex())) {
          if (!addRow(row)) {
            request.setErrorStatus(PDU.resourceUnavailable);
            return;
          }
        }
      }
      else {
        row = model.getRow(cell.getIndex());
      }

-DonB


More information about the SNMP4J mailing list