LUCENE-5972: IndexFormatTooOldException and IndexFormatTooNewException now extend from IOException

git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1626914 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Ryan Ernst 2014-09-22 22:49:46 +00:00
parent c599b96748
commit 98060ec0f5
4 changed files with 25 additions and 17 deletions

View File

@ -122,6 +122,10 @@ API Changes
* LUCENE-5965: CorruptIndexException requires a String or DataInput resource. * LUCENE-5965: CorruptIndexException requires a String or DataInput resource.
(Robert Muir) (Robert Muir)
* LUCENE-5972: IndexFormatTooOldException and IndexFormatTooNewException now
extend from IOException.
(Ryan Ernst, Robert Muir)
Bug Fixes Bug Fixes
* LUCENE-5650: Enforce read-only access to any path outside the temporary * LUCENE-5650: Enforce read-only access to any path outside the temporary

View File

@ -44,6 +44,6 @@ public class CorruptIndexException extends IOException {
/** Create exception with message and root cause. */ /** Create exception with message and root cause. */
public CorruptIndexException(String message, String resourceDescription, Throwable cause) { public CorruptIndexException(String message, String resourceDescription, Throwable cause) {
super(message + " (resource=" + resourceDescription + ")", cause); super(Objects.toString(message) + " (resource=" + resourceDescription + ")", cause);
} }
} }

View File

@ -17,13 +17,16 @@
package org.apache.lucene.index; package org.apache.lucene.index;
import java.io.IOException;
import java.util.Objects;
import org.apache.lucene.store.DataInput; import org.apache.lucene.store.DataInput;
/** /**
* This exception is thrown when Lucene detects * This exception is thrown when Lucene detects
* an index that is newer than this Lucene version. * an index that is newer than this Lucene version.
*/ */
public class IndexFormatTooNewException extends CorruptIndexException { public class IndexFormatTooNewException extends IOException {
/** Creates an {@code IndexFormatTooNewException} /** Creates an {@code IndexFormatTooNewException}
* *
@ -34,9 +37,8 @@ public class IndexFormatTooNewException extends CorruptIndexException {
* *
* @lucene.internal */ * @lucene.internal */
public IndexFormatTooNewException(String resourceDesc, int version, int minVersion, int maxVersion) { public IndexFormatTooNewException(String resourceDesc, int version, int minVersion, int maxVersion) {
super("Format version is not supported: " super("Format version is not supported (resource " + resourceDesc + "): "
+ version + " (needs to be between " + minVersion + " and " + maxVersion + ")", resourceDesc); + version + " (needs to be between " + minVersion + " and " + maxVersion + ")");
assert resourceDesc != null;
} }
/** Creates an {@code IndexFormatTooNewException} /** Creates an {@code IndexFormatTooNewException}
@ -48,7 +50,8 @@ public class IndexFormatTooNewException extends CorruptIndexException {
* *
* @lucene.internal */ * @lucene.internal */
public IndexFormatTooNewException(DataInput in, int version, int minVersion, int maxVersion) { public IndexFormatTooNewException(DataInput in, int version, int minVersion, int maxVersion) {
this(in.toString(), version, minVersion, maxVersion); this(Objects.toString(in), version, minVersion, maxVersion);
} }
} }

View File

@ -17,13 +17,16 @@
package org.apache.lucene.index; package org.apache.lucene.index;
import java.io.IOException;
import java.util.Objects;
import org.apache.lucene.store.DataInput; import org.apache.lucene.store.DataInput;
/** /**
* This exception is thrown when Lucene detects * This exception is thrown when Lucene detects
* an index that is too old for this Lucene version * an index that is too old for this Lucene version
*/ */
public class IndexFormatTooOldException extends CorruptIndexException { public class IndexFormatTooOldException extends IOException {
/** Creates an {@code IndexFormatTooOldException}. /** Creates an {@code IndexFormatTooOldException}.
* *
@ -32,21 +35,20 @@ public class IndexFormatTooOldException extends CorruptIndexException {
* *
* @lucene.internal */ * @lucene.internal */
public IndexFormatTooOldException(String resourceDesc, String version) { public IndexFormatTooOldException(String resourceDesc, String version) {
super("Format version is not supported: " + super("Format version is not supported (resource " + resourceDesc + "): " +
version + ". This version of Lucene only supports indexes created with release 4.0 and later.", resourceDesc); version + ". This version of Lucene only supports indexes created with release 4.0 and later.");
assert resourceDesc != null;
} }
/** Creates an {@code IndexFormatTooOldException}. /** Creates an {@code IndexFormatTooOldException}.
* *
* @param in the open file that's too old * @param in the open file that's too old
* @param version the version of the file that was too old * @param version the version of the file that was too old
* *
* @lucene.internal */ * @lucene.internal */
public IndexFormatTooOldException(DataInput in, String version) { public IndexFormatTooOldException(DataInput in, String version) {
this(in.toString(), version); this(Objects.toString(in), version);
} }
/** Creates an {@code IndexFormatTooOldException}. /** Creates an {@code IndexFormatTooOldException}.
* *
* @param resourceDesc describes the file that was too old * @param resourceDesc describes the file that was too old
@ -56,10 +58,9 @@ public class IndexFormatTooOldException extends CorruptIndexException {
* *
* @lucene.internal */ * @lucene.internal */
public IndexFormatTooOldException(String resourceDesc, int version, int minVersion, int maxVersion) { public IndexFormatTooOldException(String resourceDesc, int version, int minVersion, int maxVersion) {
super("Format version is not supported: " + super("Format version is not supported (resource " + resourceDesc + "): " +
version + " (needs to be between " + minVersion + " and " + maxVersion + version + " (needs to be between " + minVersion + " and " + maxVersion +
"). This version of Lucene only supports indexes created with release 4.0 and later.", resourceDesc); "). This version of Lucene only supports indexes created with release 4.0 and later.");
assert resourceDesc != null;
} }
/** Creates an {@code IndexFormatTooOldException}. /** Creates an {@code IndexFormatTooOldException}.
@ -71,6 +72,6 @@ public class IndexFormatTooOldException extends CorruptIndexException {
* *
* @lucene.internal */ * @lucene.internal */
public IndexFormatTooOldException(DataInput in, int version, int minVersion, int maxVersion) { public IndexFormatTooOldException(DataInput in, int version, int minVersion, int maxVersion) {
this(in.toString(), version, minVersion, maxVersion); this(Objects.toString(in), version, minVersion, maxVersion);
} }
} }