Opened 13 years ago

Closed 13 years ago

#576 closed defect (fixed)

LuceneIndexWriterFactory not thread safe

Reported by: jesseeichar Owned by: geonetwork-devel@…
Priority: major Milestone: v2.6.5
Component: General Version: v2.6.3
Keywords: Cc:

Description

There are two instances where the class is not thread safe.

If a field is accessed outside of a synchronized block that field may be cached in the thread specific cache and therefore if one thread updates the field the other threads may not get that update until some unknown point in the future. The solutions are to only access fields shared between threads in synchronized blocks or to set the field as volatile.

In Geonetwork code _writer was modified in a synchronized block but accessed outside of it. In my patch I made _writer be volatile so that each thread will always obtain the most recent version.

Second _optimized was also non-volatile and accessed inside and outside of a synchronized block again resulting in cases where optimization could be triggered multiple times by different threads. In my patch I change it to use a java.util.concurrent.Lock so that it reduces geonetwork code.

Attachments (1)

576_Index_Writer_potential_thread_issues.patch (1.8 KB ) - added by jesseeichar 13 years ago.

Download all attachments as: .zip

Change History (2)

comment:1 by simonp, 13 years ago

Resolution: fixed
Status: newclosed

Fixed in svn commit #8113 - thanks Jesse

Note: See TracTickets for help on using tickets.