andrew4699 commented on code in PR #402: URL: https://github.com/apache/polaris/pull/402#discussion_r1819368790
########## 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: Since it's a test, the exception technically doesn't have to be wrapped in a Supplier, but more generally exceptions generate their stack trace at construction time so using a Supplier makes the stack trace accurate. Regarding `Optional` vs. `null` vs. `() -> null`, I don't have a strong preference. They all seem equally (un)confusing and the reader can look at the comments to figure out the meaning. -- 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]
