Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions server/src/main/java/io/druid/segment/realtime/FireHydrant.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public class FireHydrant
private final int count;
private volatile IncrementalIndex index;
private volatile ReferenceCountingSegment adapter;
private Object swapLock = new Object();
private final Object swapLock = new Object();

public FireHydrant(
IncrementalIndex index,
Expand Down Expand Up @@ -82,16 +82,17 @@ public boolean hasSwapped()
public void swapSegment(Segment adapter)
{
synchronized (swapLock) {
if (this.adapter != null) {
ReferenceCountingSegment oldAdapter = this.adapter;
this.adapter = new ReferenceCountingSegment(adapter);
this.index = null;
if (oldAdapter != null) {
try {
this.adapter.close();
oldAdapter.close();
}
catch (IOException e) {
throw Throwables.propagate(e);
}
}
this.adapter = new ReferenceCountingSegment(adapter);
this.index = null;
}
}

Expand Down