[SNMP4SDN-12] Java.lang.NullPointerException error occured when executing command snmp4sdn:topodiscoverswitches Created: 30/Oct/15  Updated: 19/Oct/17  Resolved: 02/Mar/16

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

Type: Bug
Reporter: Nanfei Chen Assignee: Unassigned
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: 4559

 Description   

Three switches are used in my experiment, and the connection between them is as follows:

s1(GE1/0/1)-----(GE1/0/1)s2(GE1/0/2)-----(GE1/0/1)s3

Firstly, I use command snmp4sdn:readdb to read the device information of s1 and s2, and the detailed information is as follows:

MAC,IP,SNMP_Community,CLI_Username,CLI_Password
06:DF:44:64:01:00,177.0.0.104,public, ,
06:E4:80:8E:02:00,177.0.0.105,public, ,

Then, I use command snmp4sdn:topodiscoverswitches to discovery the two switches. But there is an ERROR log of java.lang.NullPointerException after executing the command snmp4sdn:topodiscoverswitches. The detailed information is as follows:

2015-10-29 20:07:24,671 | INFO | l for user karaf | CmethUtil | 270 - org.opendaylight.snmp4sdn - 0.2.1.Lithium-SR1 | enter CmethUtil.readDB()
2015-10-29 20:07:24,671 | INFO | l for user karaf | CmethUtil | 270 - org.opendaylight.snmp4sdn - 0.2.1.Lithium-SR1 | open file /odl/switch_login_db.csv
2015-10-29 20:07:34,182 | INFO | l for user karaf | Controller | 270 - org.opendaylight.snmp4sdn - 0.2.1.Lithium-SR1 | Add switch(00:00:06:e4:80:8e:02:00) to the Controller
2015-10-29 20:07:34,701 | INFO | l for user karaf | Controller | 270 - org.opendaylight.snmp4sdn - 0.2.1.Lithium-SR1 | Add to switch (ip: 177.0.0.105, mac: 00:00:06:e4:80:8e:02:00) a new port, port number = 2
2015-10-29 20:07:34,703 | INFO | l for user karaf | Controller | 270 - org.opendaylight.snmp4sdn - 0.2.1.Lithium-SR1 | Add to switch (ip: 177.0.0.105, mac: 00:00:06:e4:80:8e:02:00) a new port, port number = 3
2015-10-29 20:07:34,704 | INFO | l for user karaf | Controller | 270 - org.opendaylight.snmp4sdn - 0.2.1.Lithium-SR1 | Add to switch (ip: 177.0.0.105, mac: 00:00:06:e4:80:8e:02:00) a new port, port number = 4
2015-10-29 20:07:34,712 | INFO | l for user karaf | Controller | 270 - org.opendaylight.snmp4sdn - 0.2.1.Lithium-SR1 | Add switch(00:00:06:df:44:64:01:00) to the Controller
2015-10-29 20:07:35,229 | INFO | l for user karaf | Controller | 270 - org.opendaylight.snmp4sdn - 0.2.1.Lithium-SR1 | Add to switch (ip: 177.0.0.104, mac: 00:00:06:df:44:64:01:00) a new port, port number = 2
2015-10-29 20:07:35,229 | INFO | l for user karaf | Controller | 270 - org.opendaylight.snmp4sdn - 0.2.1.Lithium-SR1 | Add to switch (ip: 177.0.0.104, mac: 00:00:06:df:44:64:01:00) a new port, port number = 3
2015-10-29 20:07:35,399 | ERROR | Thread-43 | TopologyServiceShim | 270 - org.opendaylight.snmp4sdn - 0.2.1.Lithium-SR1 |
java.lang.NullPointerException
at org.opendaylight.snmp4sdn.internal.TopologyServiceShim$TopologyNotify.run(TopologyServiceShim.java:138)[270:org.opendaylight.snmp4sdn:0.2.1.Lithium-SR1]
at java.lang.Thread.run(Thread.java:745)[:1.7.0_80]



 Comments   
Comment by Christine Hsieh [ 15/Feb/16 ]

The topology could be collected as you experimented in SNMP4SDN-11. So, does the problem here occur always or sometimes?

Comment by Nanfei Chen [ 15/Feb/16 ]

When I did the experiments, the problem always occured when executing the command.

Comment by Nanfei Chen [ 23/Feb/16 ]

I have submitted a change for this bug.

https://git.opendaylight.org/gerrit/#/c/35253/

Comment by Christine Hsieh [ 28/Feb/16 ]

See the patch, agree that we missed to check null pointer. But I wonder why it fixes the problem, could you simply explain why?

Comment by Nanfei Chen [ 29/Feb/16 ]

Sorry about my careless of no description.

There was a problem in method run of class TopologyNotify.

When I traced the code, I found there was such a container whose

ITopologyServiceShimListener in map topologyServiceShimListeners was null.

And then, the method edgeUpdate of this null ITopologyServiceShimListener was called without checking whether it was null, so the Java.lang.NullPointerException error occured.

When I checked whether the ITopologyServiceShimListener corresponding to every container was null before calling its method edgeUpdate, there was not Java.lang.NullPointerException error any more.

Comment by Christine Hsieh [ 02/Mar/16 ]

I see, thanks for your fixing, code is merged now.

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