Fix memory leak in BA mount service 96/81896/2
authorMaros Marsalek <mmarsalek@frinx.io>
Fri, 3 May 2019 12:04:56 +0000 (14:04 +0200)
committerRobert Varga <nite@hq.sk>
Tue, 7 May 2019 08:27:55 +0000 (08:27 +0000)
commit31b74822f34d55b438c689de76beaa0dc8f4fcae
treed8abfbff1bc5d2118bf59d244ac89d5e7f699eea
parent538d2da5d51da3dedf6c2150aeefef73fe608318
Fix memory leak in BA mount service

The cache used in BA mount service uses weakKeys() so the keys (DOM mountpoint)
could be GCed when no ono, except cache, referenced them).
However the values in the cache (BA mountpoint) also kept a reference to
the key, so the key was never weakly reachable and thus never GCed
resulting in a memory leak.

Which is especially visible in case of frequent reconnects of netconf
mountpoints where after every reconnect a new DOM mountpoint is created,
requiring a new BA mountpoint creating new entry in the cache of BA mount service...

Added also a simple test verifying proper cache cleanup

Change-Id: I9c109dd6d499d6185842d6a1ad5a59d75565af5c
Signed-off-by: Maros Marsalek <mmarsalek@frinx.io>
(cherry picked from commit 225e9ce237996d321f420291ff6ba59c48a70d9f)
opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/impl/BindingDOMMountPointServiceAdapter.java
opendaylight/md-sal/sal-binding-broker/src/test/java/org/opendaylight/controller/md/sal/binding/impl/BindingDOMMountPointServiceAdapterTest.java [new file with mode: 0644]