stoty commented on code in PR #7892: URL: https://github.com/apache/hadoop/pull/7892#discussion_r2308195101
########## 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(""); + } + + @Override + public final void run() { + SubjectUtil.doAs(startSubject, new PrivilegedAction<Void>() { Review Comment: Reformatted the class -- 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: common-issues-unsubscr...@hadoop.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: common-issues-unsubscr...@hadoop.apache.org For additional commands, e-mail: common-issues-h...@hadoop.apache.org