Skip to content

armgit / solr

Public Imported from GitHub
0

Apache Solr 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.java
index 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 {
@Override
public void seek(long pos) {
- throw new RuntimeException("not allowed");
+ throw new UnsupportedOperationException();
}
@Override
diff --git a/lucene/core/src/java/org/apache/lucene/store/ChecksumIndexOutput.java b/lucene/core/src/java/org/apache/lucene/store/ChecksumIndexOutput.java
index 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 {
@Override
public 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.java
index 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.java
index 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.java
index 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.java
index 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 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/TestFileSwitchDirectory.java b/lucene/core/src/test/org/apache/lucene/store/TestFileSwitchDirectory.java
index 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.java
index 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();