flyrain commented on code in PR #402: URL: https://github.com/apache/polaris/pull/402#discussion_r1818158388
########## polaris-service/src/test/java/org/apache/polaris/service/catalog/io/TestFileIO.java: ########## @@ -0,0 +1,145 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.polaris.service.catalog.io; + +import java.util.Map; +import java.util.Optional; +import java.util.function.Supplier; +import org.apache.iceberg.DataFile; +import org.apache.iceberg.DeleteFile; +import org.apache.iceberg.ManifestFile; +import org.apache.iceberg.io.FileIO; +import org.apache.iceberg.io.InputFile; +import org.apache.iceberg.io.OutputFile; + +/** + * File IO wrapper used for tests. It measures the number of bytes read, files written, and files + * deleted. It can inject exceptions during InputFile and OutputFile creation. + */ +public class TestFileIO implements FileIO { + private final FileIO io; + + // When present, the following will be used to throw exceptions at various parts of the IO + private final Optional<Supplier<RuntimeException>> newInputFileExceptionSupplier; + private final Optional<Supplier<RuntimeException>> newOutputFileExceptionSupplier; Review Comment: Using `Optional` here adds cognitive burden for the reader, especially since `Optional` is typically used to facilitate fluent method chaining. This additional complexity can be confusing, particularly for someone quickly scanning the code. Plus, it doesn't add any benefit here. > On the other hand, if we rely on null, they can either pass a null supplier or a supplier that yields null. Which is it? `() -> null` is not a null supplier, right? -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
