[ https://issues.apache.org/jira/browse/HADOOP-19574?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18016850#comment-18016850 ]
ASF GitHub Bot commented on HADOOP-19574: ----------------------------------------- stoty commented on code in PR #7892: URL: https://github.com/apache/hadoop/pull/7892#discussion_r2308192881 ########## hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/util/Daemon.java: ########## @@ -18,16 +18,59 @@ package org.apache.hadoop.util; +import java.security.PrivilegedAction; import java.util.concurrent.ThreadFactory; +import javax.security.auth.Subject; + import org.apache.hadoop.classification.InterfaceAudience; import org.apache.hadoop.classification.InterfaceStability; +import org.apache.hadoop.security.authentication.util.SubjectUtil; -/** A thread that has called {@link Thread#setDaemon(boolean) } with true.*/ +/** A thread that has called {@link Thread#setDaemon(boolean) } with true. + * + * The runnable code must either be specified in the runnable parameter or + * in the override work() method. + * + * The subject propagation is already added in either case. + * + * */ @InterfaceAudience.LimitedPrivate({"HDFS", "MapReduce"}) @InterfaceStability.Unstable public class Daemon extends Thread { + Subject startSubject; + + @Override + public final void start() { + startSubject = SubjectUtil.current(); + super.start(); + } + + /** + * Override this instead of run() + */ + public void work() { + throw new IllegalArgumentException(""); Review Comment: I changed the logic to match the the one in Thread. > Restore Subject propagation semantics for Java 22+ > -------------------------------------------------- > > Key: HADOOP-19574 > URL: https://issues.apache.org/jira/browse/HADOOP-19574 > Project: Hadoop Common > Issue Type: Bug > Reporter: Istvan Toth > Assignee: Istvan Toth > Priority: Critical > Labels: pull-request-available > > Java 22 breaks Subject propagation for new Threads (when SecurityManager is > not enabled). > Previously, the Subject set by Subject.doAs() / Subject.callAs() > automatically propagated to any new Threads created (via new Thread(), not > Executors). > With JDK22, this is no longer the case, new Threads do NOT inherit the > Subject. > As Hadoop heavily relies on the original behavior, we somehow need to solve > this problem. -- This message was sent by Atlassian Jira (v8.20.10#820010) --------------------------------------------------------------------- To unsubscribe, e-mail: common-issues-unsubscr...@hadoop.apache.org For additional commands, e-mail: common-issues-h...@hadoop.apache.org