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

This commit is contained in:
Uwe Schindler 2022-02-14 17:05:34 +01:00 committed by GitHub
parent db8fcb84bb
commit 70c152bf32
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 2 additions and 69 deletions

View File

@ -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;
}

View File

@ -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;
}

View File

@ -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;
}
}