junegunn commented on code in PR #6917: URL: https://github.com/apache/hbase/pull/6917#discussion_r3247752071
########## hbase-client/src/main/java/org/apache/hadoop/hbase/ipc/ShadedPrefixUtil.java: ########## @@ -0,0 +1,129 @@ +/* + * 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.hbase.ipc; + +import java.util.concurrent.ConcurrentHashMap; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +class ShadedPrefixUtil { + private static final Logger LOG = LoggerFactory.getLogger(ShadedPrefixUtil.class); + + // Marked with '!' to prevent shading tools from replacing this value + static final String ORIGINAL_BASE = "org!apache!hadoop!hbase".replace('!', '.'); + + private static final ShadedPrefixUtil INSTANCE = + newInstance(ShadedPrefixUtil.class.getPackage().getName()); + + /** + * The shaded equivalent of "org.apache.hadoop.hbase", or null if not in a shaded environment. + * <ul> + * <li>Prefix-prepend shading (e.g., current package "a.b.c.org.apache.hadoop.hbase.ipc"): + * "a.b.c.org.apache.hadoop.hbase"</li> + * <li>Full-replacement shading (e.g., current package "shaded.hbase1.ipc"): "shaded.hbase1"</li> + * </ul> + */ + private final String shadedBase; + + /** + * Cache from original class name to its resolved (shaded or original) equivalent. Class.forName + * for a missing class is expensive as it searches all classloaders, so we memoize the result to Review Comment: Sorry to nitpick, but maybe we can just drop the second sentence. The `Class.forName` cost detail feels a little out of place and not really needed here. `Class.forName` is already mentioned in the comment near the call site. -- 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]
