BUG-7464: Fix StackOverflowError on hash collisions 93/49893/12
authorRobert Varga <rovarga@cisco.com>
Sat, 31 Dec 2016 16:52:12 +0000 (17:52 +0100)
committerRobert Varga <nite@hq.sk>
Tue, 10 Jan 2017 19:02:44 +0000 (19:02 +0000)
commitc168c28f4027aa972940d32450eb9c9ee1cdfacf
treea07e936a49334d79cb38a22d23c6731f64736a2e
parent62f6b314ee1c5ae6fd49d9133eed2105886e560c
BUG-7464: Fix StackOverflowError on hash collisions

If LNodes get saturated due to poor key hash function, the ListMap
chain can grow large. Since ListMap.get() was implemented using recursion
this can easily trigger StackOverflowError. The same problem impacts
ListMap.contains(), which is triggered in the add() path.

Turn recursion into a loop, which provides defence against the error,
while not alleviating the performance impact.

Change-Id: Id04d30b9cb4d75dc4535ff20bd11a16ed96ab0ff
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
third-party/triemap/src/main/java/org/opendaylight/yangtools/triemap/ListMap.java
third-party/triemap/src/test/java/org/opendaylight/yangtools/triemap/ListMapTest.java [new file with mode: 0644]