mirror of https://github.com/apache/lucene.git
LUCENE-2650: Added extra safety to MMapIndexInput clones
git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@999223 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
3e3d6d61b8
commit
d204e7331c
|
@ -526,6 +526,9 @@ Bug fixes
|
|||
* LUCENE-2634: isCurrent on an NRT reader was failing to return false
|
||||
if the writer had just committed (Nikolay Zamosenchuk via Mike McCandless)
|
||||
|
||||
* LUCENE-2650: Added extra safety to MMapIndexInput clones to prevent accessing
|
||||
an unmapped buffer if the input is closed (Mike McCandless, Uwe Schindler, Robert Muir)
|
||||
|
||||
New features
|
||||
|
||||
* LUCENE-2128: Parallelized fetching document frequencies during weight
|
||||
|
|
|
@ -259,6 +259,8 @@ public class MMapDirectory extends FSDirectory {
|
|||
|
||||
@Override
|
||||
public Object clone() {
|
||||
if (buffer == null)
|
||||
throw new AlreadyClosedException("MMapIndexInput already closed");
|
||||
MMapIndexInput clone = (MMapIndexInput)super.clone();
|
||||
clone.isClone = true;
|
||||
clone.buffer = buffer.duplicate();
|
||||
|
@ -267,9 +269,9 @@ public class MMapDirectory extends FSDirectory {
|
|||
|
||||
@Override
|
||||
public void close() throws IOException {
|
||||
if (isClone || buffer == null) return;
|
||||
// unmap the buffer (if enabled) and at least unset it for GC
|
||||
try {
|
||||
if (isClone || buffer == null) return;
|
||||
cleanMapping(buffer);
|
||||
} finally {
|
||||
buffer = null;
|
||||
|
@ -382,6 +384,8 @@ public class MMapDirectory extends FSDirectory {
|
|||
|
||||
@Override
|
||||
public Object clone() {
|
||||
if (buffers == null)
|
||||
throw new AlreadyClosedException("MultiMMapIndexInput already closed");
|
||||
MultiMMapIndexInput clone = (MultiMMapIndexInput)super.clone();
|
||||
clone.isClone = true;
|
||||
clone.buffers = new ByteBuffer[buffers.length];
|
||||
|
@ -403,8 +407,8 @@ public class MMapDirectory extends FSDirectory {
|
|||
|
||||
@Override
|
||||
public void close() throws IOException {
|
||||
if (isClone || buffers == null) return;
|
||||
try {
|
||||
if (isClone || buffers == null) return;
|
||||
for (int bufNr = 0; bufNr < buffers.length; bufNr++) {
|
||||
// unmap the buffer (if enabled) and at least unset it for GC
|
||||
try {
|
||||
|
|
Loading…
Reference in New Issue