C0urante commented on code in PR #16522: URL: https://github.com/apache/kafka/pull/16522#discussion_r1704784407
########## clients/src/main/java/org/apache/kafka/common/internals/SecurityManagerCompatibility.java: ########## @@ -0,0 +1,355 @@ +/* + * 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.kafka.common.internals; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; +import java.security.PrivilegedAction; +import java.security.PrivilegedActionException; +import java.security.PrivilegedExceptionAction; +import java.util.Objects; +import java.util.concurrent.Callable; +import java.util.concurrent.CompletionException; +import java.util.concurrent.atomic.AtomicReference; +import java.util.function.Function; + +import javax.security.auth.Subject; + +/** + * This is a compatibility class to provide dual-support for JREs with and without SecurityManager support. + * <p>Users should call {@link #get()} to retrieve a singleton instance, and call instance methods + * {@link #doPrivileged(PrivilegedAction)}, {@link #current()}, and {@link #callAs(Subject, Callable)}. + * <p>This class's motivation and expected behavior is defined in + * <a href="https://cwiki.apache.org/confluence/display/KAFKA/KIP-1006%3A+Remove+SecurityManager+Support">KIP-1006</a> + */ +public interface SecurityManagerCompatibility { + + static SecurityManagerCompatibility get() { + return Composite.INSTANCE; + } + + <T> T doPrivileged(PrivilegedAction<T> action); + + Subject current(); Review Comment: I dunno, it's a simple IDE find+replace to update this in the future, and `Subject::current` has meaning to it that `SecurityManagerCompatibility.get().current()` does not. I don't think it's worth the hit in readability for the (very long) interim period where we use this class instead of the JDK APIs that will eventually replace it. But I won't block on it. -- 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]
