Synchronize SegmentedJournal.open() 14/104714/1
authorRobert Varga <robert.varga@pantheon.tech>
Thu, 2 Mar 2023 11:37:29 +0000 (12:37 +0100)
committerRobert Varga <robert.varga@pantheon.tech>
Thu, 2 Mar 2023 11:39:40 +0000 (12:39 +0100)
SpotBugs is pointing out a problem with synchronization to
currentSegment. This is a false positive, as we only call this method
from the constructor, but slap a synchronized keyword on it anyway.

JIRA: CONTROLLER-2071
Change-Id: Iaf3a13c4122a3321b615eb5629327494165c0bed
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
third-party/atomix/storage/src/main/java/io/atomix/storage/journal/SegmentedJournal.java

index fed7ab8d3e6c19fc69df5fe3cdc6bd7ff26196f3..45490757f8685b5bd529fa7888c2dab716afb52e 100644 (file)
@@ -230,7 +230,7 @@ public final class SegmentedJournal<E> implements Journal<E> {
   /**
    * Opens the segments.
    */
-  private void open() {
+  private synchronized void open() {
     // Load existing log segments from disk.
     for (JournalSegment<E> segment : loadSegments()) {
       segments.put(segment.descriptor().index(), segment);