NodeModel optional in/out ports bug!?

Dear KNIME Team:

during a new node implementation I encountered a problem with IN/OUT ports. Checkout lines below from `NodeModel` class:

// here you accept somewhat that in inPortTypes can be null
if (inPortTypes == null) {
    m_inPortTypes = new PortType[0];
} else {
    m_inPortTypes = new PortType[inPortTypes.length];
}

// but here you try to iterate over object which can be null
for (int i = 0; i < inPortTypes.length; i++) {
    if (inPortTypes[i] == null) {
        throw new NullPointerException("InPortType[" + i
                + "] must not be null!");
    }
    m_inPortTypes[i] = inPortTypes[i];
}

// same happens for outPortTypes

// null check
if (outPortTypes == null) {
    m_outPortTypes = new PortType[0];
} else {
    m_outPortTypes = new PortType[outPortTypes.length];
}

// and iterate over null object
for (int i = 0; i < outPortTypes.length; i++) {
    if (outPortTypes[i] == null) {
        throw new NullPointerException("OutPortType[" + i
                + "] must not be null!");
    }
    m_outPortTypes[i] = outPortTypes[i];
}

What I suggest (first and simplest idea that comes to my mind) is to change it like this:

// here you make sure you're ready for both null and not null cases as it was
if (inPortTypes == null) {
    m_inPortTypes = new PortType[0];
} else {
    m_inPortTypes = new PortType[inPortTypes.length];
}

// but here you iterate over well initialized array object
for (int i = 0; i < m_inPortTypes.length; i++) {
    if (inPortTypes[i] == null) {
        throw new NullPointerException("InPortType[" + i
                + "] must not be null!");
    }
    m_inPortTypes[i] = inPortTypes[i];
}

// same for outPortTypes

// null checking as it was
if (outPortTypes == null) {
    m_outPortTypes = new PortType[0];
} else {
    m_outPortTypes = new PortType[outPortTypes.length];
}

// and iterate over proper array object
for (int i = 0; i < m_outPortTypes.length; i++) {
    if (outPortTypes[i] == null) {
        throw new NullPointerException("OutPortType[" + i
                + "] must not be null!");
    }
    m_outPortTypes[i] = outPortTypes[i];
}


Best,
SM