[OPNFLWPLUG-513] Exception at removeUnreportedFlows in StatisticsManagerImpl Created: 08/Jul/15  Updated: 27/Sep/21  Resolved: 27/Nov/15

Status: Resolved
Project: OpenFlowPlugin
Component/s: General
Affects Version/s: None
Fix Version/s: None

Type: Bug
Reporter: Henry Fung Assignee: Monika Verma
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

Operating System: All
Platform: All


External issue ID: 3957

 Description   

This bug is found in stable/lithium and also main.

2015-07-07 14:37:15,748 | WARN | ds-oper-thread-0 | StatisticsManagerImpl | 264 - org.opendaylight.openflowplugin.applications.statistics-manager - 0.1.1.SNAPSHOT | Unhandled exception during processing statistics. Restarting transaction chain.
java.lang.NullPointerException
at org.opendaylight.openflowplugin.applications.statistics.manager.impl.StatListenCommitFlow$TableFlowUpdateState.removeUnreportedFlows(StatListenCommitFlow.java:464)[264:org.opendaylight.openflowplugin.applications.statistics-manager:0.1.1.SNAPSHOT]
at org.opendaylight.openflowplugin.applications.statistics.manager.impl.StatListenCommitFlow.statsFlowCommitAll(StatListenCommitFlow.java:262)[264:org.opendaylight.openflowplugin.applications.statistics-manager:0.1.1.SNAPSHOT]
at org.opendaylight.openflowplugin.applications.statistics.manager.impl.StatListenCommitFlow.access$000(StatListenCommitFlow.java:82)[264:org.opendaylight.openflowplugin.applications.statistics-manager:0.1.1.SNAPSHOT]
at org.opendaylight.openflowplugin.applications.statistics.manager.impl.StatListenCommitFlow$2.applyOperation(StatListenCommitFlow.java:208)[264:org.opendaylight.openflowplugin.applications.statistics-manager:0.1.1.SNAPSHOT]

After the exception, there were side-effect null pointer exceptions whenever there were statistics poll.

The fix is simple:
diff --git a/applications/statistics-manager/src/main/java/org/opendaylight/open
index 71d34dc..2180e09 100644
— a/applications/statistics-manager/src/main/java/org/opendaylight/openflowplu
+++ b/applications/statistics-manager/src/main/java/org/opendaylight/openflowplu
@@ -461,7 +461,7 @@ public class StatListenCommitFlow extends StatAbstractListen
final InstanceIdentifier<Flow> flowRef = tableRef.child(Flow.cl
if (nodeDeleteMap != null && flowKey.getId().getValue().startsW
final Integer lifeIndex = nodeDeleteMap.get(flowRef);

  • if (lifeIndex > 0) {
    + if (lifeIndex != null && lifeIndex > 0) { break; }

    else {
    nodeDeleteMap.remove(flowRef);



 Comments   
Comment by Partha Datta [ 03/Aug/15 ]

Reassigned to sunaina.khanna

Comment by Sunaina Khanna [ 04/Aug/15 ]

Hi Henry,
Can you please tell me how to replicate this bug.I tried to replicate the bug but no error is shown on deleting the unreported flow via rest on the karaf window.

Comment by Henry Fung [ 04/Aug/15 ]

Hi Sunaina,
I had many flows programmed, deleted, and reprogrammed via FRM. I know it is not easy to reproduce, but by code inspection, we can tell something wrong.

Comment by Michal Rehak [ 10/Aug/15 ]

https://git.opendaylight.org/gerrit/#/c/25111/ merged
(would be nice to have unit test proving this right)

Comment by Sunaina Khanna [ 12/Aug/15 ]

Sure,but I could not find the test cases for the class.Should I implement the test cases for the same?

Comment by Michal Rehak [ 13/Aug/15 ]

Well best practices claim that every fix should be accompanied by (unit) test proving that fix right. If such a test already exits then fix the test first so that it fails upon that issue.
If no test exists yet and if sticking to TTD then you can even first write the unit test failing upon the issue. And then add the fix so that your push will contain passing green test and fix.

In this case you can create new test class and focus on that particular method (removeUnreportedFlows()).

And of course if you feel confident in adding unit test coverage for class StatListenCommitFlow then you are welcome to cover even more of it.

Comment by Monika Verma [ 27/Nov/15 ]

Added the unit tests covering the method removeUnreportedFlows() and some part of method statsFlowCommitAll()
Gerrit ID: https://git.opendaylight.org/gerrit/#/c/30244/

Generated at Wed Feb 07 20:32:41 UTC 2024 using Jira 8.20.10#820010-sha1:ace47f9899e9ee25d7157d59aa17ab06aee30d3d.