tanvipenumudy commented on code in PR #4383: URL: https://github.com/apache/ozone/pull/4383#discussion_r1137804795
########## hadoop-hdds/common/src/main/java/org/apache/hadoop/util/GenericCheckedSupplier.java: ########## @@ -0,0 +1,29 @@ +/* + * 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.hadoop.util; + +/** + * Similar to {@link java.util.function.Supplier}, this class presents a block + * of code generating a value with a possibility of throwing a generic + * Exception. + */ + +@FunctionalInterface +public interface GenericCheckedSupplier<T, E extends Exception> { Review Comment: Since `captureLatencyNs` method only declares `IOException` as a checked exception, in order to handle the `OS3Exception` thrown by the `createS3Bucket` method (for instance), the `catch` block can catch the exception and throw a `RuntimeException` instead. I think this could be done as an alternative because `RuntimeException` is an unchecked exception and does not need to be explicitly declared in the `throws` clause of the method signature. By throwing a `RuntimeException`, we avoid the need to modify the signature of the `captureLatencyNs` method to include `OS3Exception` in its throws clause (the import was causing a circular dependency on the modules) and it can instead be handled at a higher level in the call stack. Please let me know your thoughts on the same, thanks. -- 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] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
