Skip to content

Fix NPE in MercurialStatusCache during plugin startup

Bitbucket Importer requested to merge bitbucket/merged-pr-134 into branch/default

Created originally on Bitbucket by colin-hurley (Colin Hurley)

Was already merged in Bitbucket before import, marked as merged by the import user

The NPE was a result of the cache instance reference escaping into Eclipse callback mechanisms before the cache object was fully constructed. Namely, the cache object would be registered as a listener in the AbstractCache constructor, at which point the MercurialStatusCache constructor hasn't been run. Thus, Eclipse was able to invoke the listener callbacks while the object was in this partially-constructed state. Upon doing so, the NPE was generated because a final field hadn't been assigned its (non-null) value yet.

This issue was repaired by delaying registration of change listeners until after cache objects are fully constructed. Instead of automatically registering the listeners in the AbstractCache constructor, the sub-classes of AbstractCache now invoke the new 'initialize' method on the cache object to register the listeners after the object is fully-constructed.

fixes #613 (closed)

Merge request reports

Loading