Bug: Incorrect lazy initialization and update of static field

org.eclipse.ui.internal.intro.impl.util.IntroEvaluationContext.context
in org.eclipse.ui.internal.intro.impl.util.IntroEvaluationContext.getContext()

This method contains an unsynchronized lazy initialization of a static
field. After the field is set, the object stored into that location is
further updated or accessed. The setting of the field is visible to
other threads as soon as it is set. If the further accesses in the
method that set the field serve to initialize the object, then you have
a very serious multithreading bug, unless something else prevents any
other thread from accessing the stored object until it is fully
initialized.

Even if you feel confident that the method is never called by multiple
threads, it might be better to not set the static field until the value
you are setting it to is fully populated/initialized.

Rank: Scary (8), confidence: Normal
Pattern: LI_LAZY_INIT_UPDATE_STATIC
Type: LI, Category: MT_CORRECTNESS (Multithreaded correctness)

Change-Id: Ie7de05325b5f7a47db07de4447650c47ee4fc1c4
Signed-off-by: Carsten Hammer <carsten.hammer@t-online.de>
Reviewed-on: https://git.eclipse.org/r/c/platform/eclipse.platform.ua/+/173448
Tested-by: Platform Bot <platform-bot@eclipse.org>
Reviewed-by: Alexander Kurtakov <akurtako@redhat.com>
1 file changed