mirror of https://github.com/OpenIdentityPlatform/OpenDJ.git

Jean-Noel Rouvignac
23.10.2014 6578b821ff1b149c87831af6dbfecb2a2cf7b957
refs
author Jean-Noel Rouvignac <jean-noel.rouvignac@forgerock.com>
Tuesday, December 23, 2014 17:10 +0100
committer Jean-Noel Rouvignac <jean-noel.rouvignac@forgerock.com>
Tuesday, December 23, 2014 17:10 +0100
commit6578b821ff1b149c87831af6dbfecb2a2cf7b957
tree 3e9dec24675adad6a060c0bdf0431db45a1a24e3 tree | zip | gz
parent e522dda9a803e272e1a5f0cf80c1e4609f7d602c view | diff
OPENDJ-1706 Persistit: online import fails with NPE

Code review: Matthew Swift


Problem happened when disabling the backend before online import.
Before applying the change, the config backend was iterating over the list of listeners for this configuration.
It is important to note that the list was a CopyOnWriteArrayList, and we used its iterator.
When disabling the backend, the first listener is the backend itself. This ends up calling pluggable.BackendImpl.finalizeBackend() which calls RootContainer.close(), EntryContainer.close(), AttributeIndex.close(), etc.
The net effect is that the RootContainer, EntryContainer, and AttributeIndex deregister themselves as change listeners of that config.
In the end, before the first iteration (on the backend), there are 9 config change listeners to notify. After the first loop iteration, there is only one config change listener remaining on the list of listeners: it is actually the backend we just iterated over!
However, remember the loop is performed on the CopyOnWriteArrayList iterator, which was initilized when the list had 9 elements. So it keeps notifying listeners which are no longer interested in the change.
The code then end up trying to update the indexes, by opening a transaction on the database. Problem is that the database has been closed by the call to pluggable.BackendImpl.finalizeBackend() => and BOOM! NullPointerException!

The fix consists in verifying that each listener to be notified is still interested in the config change; i.e. did it deregister itself from listening?


ConfigFileHandler.java:
In addEntry(), replaceEntry(), deleteEntry(), always verify the listener is still interested in the config change before notifying it.
1 files modified
35 ■■■■■ changed files
opendj3-server-dev/src/server/org/opends/server/extensions/ConfigFileHandler.java 35 ●●●●● diff | view | raw | blame | history