Apache Lucene open-source search software
LUCENE-3680: more exception consistency in o.a.l.store
Robert Muira461a6399217
diff --git a/lucene/core/src/java/org/apache/lucene/store/ChecksumIndexInput.java b/lucene/core/src/java/org/apache/lucene/store/ChecksumIndexInput.javaindex e3ac0e42179..313d34c2213 100644--- a/lucene/core/src/java/org/apache/lucene/store/ChecksumIndexInput.java+++ b/lucene/core/src/java/org/apache/lucene/store/ChecksumIndexInput.java@@ -67,7 +67,7 @@ public class ChecksumIndexInput extends IndexInput {@Overridepublic void seek(long pos) {- throw new RuntimeException("not allowed");+ throw new UnsupportedOperationException();}@Overridediff --git a/lucene/core/src/java/org/apache/lucene/store/ChecksumIndexOutput.java b/lucene/core/src/java/org/apache/lucene/store/ChecksumIndexOutput.javaindex 18058938764..ca3a17b03ff 100644--- a/lucene/core/src/java/org/apache/lucene/store/ChecksumIndexOutput.java+++ b/lucene/core/src/java/org/apache/lucene/store/ChecksumIndexOutput.java@@ -68,7 +68,7 @@ public class ChecksumIndexOutput extends IndexOutput {@Overridepublic void seek(long pos) {- throw new RuntimeException("not allowed");+ throw new UnsupportedOperationException();}/**diff --git a/lucene/core/src/java/org/apache/lucene/store/CompoundFileWriter.java b/lucene/core/src/java/org/apache/lucene/store/CompoundFileWriter.javaindex e4d17503a64..8134b8cba47 100644--- a/lucene/core/src/java/org/apache/lucene/store/CompoundFileWriter.java+++ b/lucene/core/src/java/org/apache/lucene/store/CompoundFileWriter.java@@ -153,7 +153,7 @@ final class CompoundFileWriter implements Closeable{*/public void close() throws IOException {if (closed) {- throw new IllegalStateException("already closed");+ return;}IOException priorException = null;IndexOutput entryTableOut = null;@@ -192,7 +192,7 @@ final class CompoundFileWriter implements Closeable{private final void ensureOpen() {if (closed) {- throw new IllegalStateException("CFS Directory is already closed");+ throw new AlreadyClosedException("CFS Directory is already closed");}}@@ -260,7 +260,7 @@ final class CompoundFileWriter implements Closeable{} else {entry.dir = this.directory;if (directory.fileExists(name)) {- throw new IOException("File already exists");+ throw new IllegalArgumentException("File " + name + " already exists");}out = new DirectCFSIndexOutput(directory.createOutput(name, context), entry,true);diff --git a/lucene/core/src/java/org/apache/lucene/store/NativeFSLockFactory.java b/lucene/core/src/java/org/apache/lucene/store/NativeFSLockFactory.javaindex f4f63e6d2fc..85f473e8ed7 100755--- a/lucene/core/src/java/org/apache/lucene/store/NativeFSLockFactory.java+++ b/lucene/core/src/java/org/apache/lucene/store/NativeFSLockFactory.java@@ -171,6 +171,7 @@ class NativeFSLock extends Lock {throw new IOException("Cannot create directory: " +lockDir.getAbsolutePath());} else if (!lockDir.isDirectory()) {+ // TODO: NoSuchDirectoryException instead?throw new IOException("Found regular file where directory expected: " +lockDir.getAbsolutePath());}diff --git a/lucene/core/src/java/org/apache/lucene/store/SimpleFSLockFactory.java b/lucene/core/src/java/org/apache/lucene/store/SimpleFSLockFactory.javaindex 1f532aa509f..e75b7accd3b 100755--- a/lucene/core/src/java/org/apache/lucene/store/SimpleFSLockFactory.java+++ b/lucene/core/src/java/org/apache/lucene/store/SimpleFSLockFactory.java@@ -121,6 +121,7 @@ class SimpleFSLock extends Lock {throw new IOException("Cannot create directory: " +lockDir.getAbsolutePath());} else if (!lockDir.isDirectory()) {+ // TODO: NoSuchDirectoryException instead?throw new IOException("Found regular file where directory expected: " +lockDir.getAbsolutePath());}diff --git a/lucene/core/src/test/org/apache/lucene/index/TestCompoundFile.java b/lucene/core/src/test/org/apache/lucene/index/TestCompoundFile.javaindex 7dca18e31ac..56f03875b18 100644--- a/lucene/core/src/test/org/apache/lucene/index/TestCompoundFile.java+++ b/lucene/core/src/test/org/apache/lucene/index/TestCompoundFile.java@@ -682,7 +682,7 @@ public class TestCompoundFile extends LuceneTestCasetry {newDir.copy(csw, "d1", "d1", newIOContext(random));fail("file does already exist");- } catch (IOException e) {+ } catch (IllegalArgumentException e) {//}out.close();diff --git a/lucene/core/src/test/org/apache/lucene/store/TestFileSwitchDirectory.java b/lucene/core/src/test/org/apache/lucene/store/TestFileSwitchDirectory.javaindex 0e82e45d632..15d0f6fc593 100644--- a/lucene/core/src/test/org/apache/lucene/store/TestFileSwitchDirectory.java+++ b/lucene/core/src/test/org/apache/lucene/store/TestFileSwitchDirectory.java@@ -125,7 +125,7 @@ public class TestFileSwitchDirectory extends LuceneTestCase {try {newDir.copy(csw, "d1", "d1", newIOContext(random));fail("file does already exist");- } catch (IOException e) {+ } catch (IllegalArgumentException e) {//}out.close();diff --git a/lucene/core/src/test/org/apache/lucene/store/TestNRTCachingDirectory.java b/lucene/core/src/test/org/apache/lucene/store/TestNRTCachingDirectory.javaindex df87d8ac820..f8dfb2edd29 100644--- a/lucene/core/src/test/org/apache/lucene/store/TestNRTCachingDirectory.java+++ b/lucene/core/src/test/org/apache/lucene/store/TestNRTCachingDirectory.java@@ -156,7 +156,7 @@ public class TestNRTCachingDirectory extends LuceneTestCase {try {newDir.copy(csw, "d1", "d1", newIOContext(random));fail("file does already exist");- } catch (IOException e) {+ } catch (IllegalArgumentException e) {//}out.close();