Index: lucene/core/src/java/org/apache/lucene/codecs/lucene3x/Lucene3xNormsProducer.java =================================================================== --- lucene/core/src/java/org/apache/lucene/codecs/lucene3x/Lucene3xNormsProducer.java (revision 1242924) +++ lucene/core/src/java/org/apache/lucene/codecs/lucene3x/Lucene3xNormsProducer.java (working copy) @@ -18,6 +18,7 @@ */ import java.io.IOException; +import java.util.Collections; import java.util.HashMap; import java.util.IdentityHashMap; import java.util.Map; @@ -37,7 +38,6 @@ import org.apache.lucene.store.IndexInput; import org.apache.lucene.util.BytesRef; import org.apache.lucene.util.IOUtils; -import org.apache.lucene.util.MapBackedSet; import org.apache.lucene.util.StringHelper; /** @@ -60,7 +60,7 @@ final Map norms = new HashMap(); // any .nrm or .sNN files we have open at any time. // TODO: just a list, and double-close() separate norms files? - final Set openFiles = new MapBackedSet(new IdentityHashMap()); + final Set openFiles = Collections.newSetFromMap(new IdentityHashMap()); // points to a singleNormFile IndexInput singleNormStream; final int maxdoc; Index: lucene/core/src/java/org/apache/lucene/store/MMapDirectory.java =================================================================== --- lucene/core/src/java/org/apache/lucene/store/MMapDirectory.java (revision 1242924) +++ lucene/core/src/java/org/apache/lucene/store/MMapDirectory.java (working copy) @@ -27,6 +27,7 @@ import java.nio.channels.FileChannel; import java.nio.channels.FileChannel.MapMode; +import java.util.Collections; import java.util.Set; import java.util.WeakHashMap; @@ -35,7 +36,6 @@ import java.security.PrivilegedActionException; import java.lang.reflect.Method; -import org.apache.lucene.util.MapBackedSet; import org.apache.lucene.util.Constants; /** File-based {@link Directory} implementation that uses @@ -261,7 +261,7 @@ private ByteBuffer curBuf; // redundant for speed: buffers[curBufIndex] private boolean isClone = false; - private final Set clones = new MapBackedSet(new WeakHashMap()); + private final Set clones = Collections.newSetFromMap(new WeakHashMap()); MMapIndexInput(String resourceDescription, RandomAccessFile raf, long offset, long length, int chunkSizePower) throws IOException { super(resourceDescription); Index: lucene/core/src/java/org/apache/lucene/util/MapBackedSet.java =================================================================== --- lucene/core/src/java/org/apache/lucene/util/MapBackedSet.java (revision 1242924) +++ lucene/core/src/java/org/apache/lucene/util/MapBackedSet.java (working copy) @@ -1,69 +0,0 @@ -package org.apache.lucene.util; - -/** - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import java.util.AbstractSet; -import java.util.Iterator; -import java.util.Map; - -/** - * A Set implementation that wraps an actual Map based - * implementation. - * - * @lucene.internal - */ -public final class MapBackedSet extends AbstractSet { - private final Map map; - - /** - * Creates a new instance which wraps the specified {@code map}. - */ - public MapBackedSet(Map map) { - this.map = map; - } - - @Override - public int size() { - return map.size(); - } - - @Override - public boolean contains(Object o) { - return map.containsKey(o); - } - - @Override - public boolean add(E o) { - return map.put(o, Boolean.TRUE) == null; - } - - @Override - public boolean remove(Object o) { - return map.remove(o) != null; - } - - @Override - public void clear() { - map.clear(); - } - - @Override - public Iterator iterator() { - return map.keySet().iterator(); - } -} Index: modules/facet/src/test/org/apache/lucene/facet/taxonomy/directory/TestIndexClose.java =================================================================== --- modules/facet/src/test/org/apache/lucene/facet/taxonomy/directory/TestIndexClose.java (revision 1242924) +++ modules/facet/src/test/org/apache/lucene/facet/taxonomy/directory/TestIndexClose.java (working copy) @@ -1,6 +1,7 @@ package org.apache.lucene.facet.taxonomy.directory; import java.io.IOException; +import java.util.Collections; import java.util.HashSet; import java.util.IdentityHashMap; import java.util.Set; @@ -10,13 +11,11 @@ import org.apache.lucene.index.IndexWriter; import org.apache.lucene.index.IndexWriterConfig; import org.apache.lucene.index.IndexWriterConfig.OpenMode; -import org.apache.lucene.store.AlreadyClosedException; import org.apache.lucene.store.Directory; import org.apache.lucene.store.LockObtainFailedException; import org.junit.Test; import org.apache.lucene.util.LuceneTestCase; -import org.apache.lucene.util.MapBackedSet; import org.apache.lucene.analysis.MockAnalyzer; import org.apache.lucene.analysis.MockTokenizer; import org.apache.lucene.facet.taxonomy.CategoryPath; @@ -95,7 +94,7 @@ } private static class LeakChecker { - Set readers = new MapBackedSet(new IdentityHashMap()); + Set readers = Collections.newSetFromMap(new IdentityHashMap()); int iwriter=0; Set openWriters = new HashSet();