Skip to content

Apache Lucene open-source search software

LUCENE-10420: Remove deprecated interfaces and methods in IOUtils in main (#680)

Uwe Schindler70c152bf321f
diff --git a/lucene/core/src/java/org/apache/lucene/util/IOConsumer.java b/lucene/core/src/java/org/apache/lucene/util/IOConsumer.java
index f9564c3797e..cadf10bf259 100644
--- a/lucene/core/src/java/org/apache/lucene/util/IOConsumer.java
+++ b/lucene/core/src/java/org/apache/lucene/util/IOConsumer.java
@@ -25,14 +25,12 @@ import java.io.IOException;
* @param <T> the consumer's input type.
*/
@FunctionalInterface
-@SuppressWarnings("removal")
-public interface IOConsumer<T> extends IOUtils.IOConsumer<T> {
+public interface IOConsumer<T> {
/**
* Performs this operation on the given argument.
*
* @param input the input argument
* @throws IOException if producing the result throws an {@link IOException}
*/
- @Override
void accept(T input) throws IOException;
}
diff --git a/lucene/core/src/java/org/apache/lucene/util/IOFunction.java b/lucene/core/src/java/org/apache/lucene/util/IOFunction.java
index c21379f38a5..9cbd39c7d30 100644
--- a/lucene/core/src/java/org/apache/lucene/util/IOFunction.java
+++ b/lucene/core/src/java/org/apache/lucene/util/IOFunction.java
@@ -26,8 +26,7 @@ import java.io.IOException;
* @param <R> the type of the result of the function
*/
@FunctionalInterface
-@SuppressWarnings("removal")
-public interface IOFunction<T, R> extends IOUtils.IOFunction<T, R> {
+public interface IOFunction<T, R> {
/**
* Applies this function to the given argument.
*
@@ -35,6 +34,5 @@ public interface IOFunction<T, R> extends IOUtils.IOFunction<T, R> {
* @return the function result
* @throws IOException if producing the result throws an {@link IOException}
*/
- @Override
R apply(T t) throws IOException;
}
diff --git a/lucene/core/src/java/org/apache/lucene/util/IOUtils.java b/lucene/core/src/java/org/apache/lucene/util/IOUtils.java
index 2e443f45951..0b4273dd4d5 100644
--- a/lucene/core/src/java/org/apache/lucene/util/IOUtils.java
+++ b/lucene/core/src/java/org/apache/lucene/util/IOUtils.java
@@ -174,43 +174,6 @@ public final class IOUtils {
return resource;
}
- /**
- * Opens a Reader for the given resource using a {@link CharsetDecoder}. Unlike Java's defaults
- * this reader will throw an exception if your it detects the read charset doesn't match the
- * expected {@link Charset}.
- *
- * <p>Decoding readers are useful to load configuration files, stopword lists or synonym files to
- * detect character set problems. However, it's not recommended to use as a common purpose reader.
- *
- * @param clazz the class used to locate the resource
- * @param resource the resource name to load
- * @param charSet the expected charset
- * @return a reader to read the given file
- * @deprecated {@link Class#getResourceAsStream(String)} is caller sensitive and cannot load
- * resources across Java Modules. Please call the {@code getResourceAsStream()} directly and
- * use {@link #requireResourceNonNull(Object,String)} to signal missing resources {@code null}
- */
- @Deprecated(forRemoval = true, since = "9.1")
- public static Reader getDecodingReader(Class<?> clazz, String resource, Charset charSet)
- throws IOException {
- var argModule = clazz.getModule();
- if (argModule.isNamed() && argModule != IOUtils.class.getModule()) {
- throw new UnsupportedOperationException(
- "getDecodingReader(class,...) does not work when Java Module System is enabled.");
- }
- InputStream stream = requireResourceNonNull(clazz.getResourceAsStream(resource), resource);
- boolean success = false;
- try {
- final Reader reader = getDecodingReader(stream, charSet);
- success = true;
- return reader;
- } finally {
- if (!success) {
- IOUtils.close(stream);
- }
- }
- }
-
/**
* Deletes all given files, suppressing all thrown IOExceptions.
*
@@ -505,30 +468,4 @@ public final class IOUtils {
collection.stream().filter(Objects::nonNull).map(t -> (Closeable) () -> consumer.accept(t))
::iterator);
}
-
- /**
- * An IO operation with a single input.
- *
- * @see java.util.function.Consumer
- * @deprecated was replaced by {@link org.apache.lucene.util.IOConsumer}.
- */
- @FunctionalInterface
- @Deprecated(forRemoval = true, since = "9.1")
- public interface IOConsumer<T> {
- /** Performs this operation on the given argument. */
- void accept(T input) throws IOException;
- }
-
- /**
- * A Function that may throw an IOException
- *
- * @see java.util.function.Function
- * @deprecated was replaced by {@link org.apache.lucene.util.IOFunction}.
- */
- @FunctionalInterface
- @Deprecated(forRemoval = true, since = "9.1")
- public interface IOFunction<T, R> {
- /** Applies this function to the given argument. */
- R apply(T t) throws IOException;
- }
}