stoty commented on code in PR #7892:
URL: https://github.com/apache/hadoop/pull/7892#discussion_r2309104177


##########
hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/util/concurrent/HadoopThread.java:
##########
@@ -0,0 +1,105 @@
+/**
+ * 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.concurrent;
+
+import java.security.PrivilegedAction;
+import javax.security.auth.Subject;
+
+import org.apache.hadoop.security.authentication.util.SubjectUtil;
+
+/**
+ * Helper class to restore Subject propagation behavior after the JEP411/JEP486
+ * changes
+ * 
+ * Runnables can be specified normally, but the work() method has to be
+ * overridden instead of run() when subclassing.
+ */
+public class HadoopThread extends Thread {
+
+  Subject startSubject;
+  Runnable hadoopTarget;
+
+  public HadoopThread() {
+    super();
+  }
+
+  public HadoopThread(Runnable target) {
+    super();
+    this.hadoopTarget = target;
+  }
+
+  public HadoopThread(ThreadGroup group, Runnable target) {
+    // The target passed to Thread has no effect, we only pass it
+    // because there is no super(group) constructor.
+    super(group, target);
+    this.hadoopTarget = target;
+  }
+
+  public HadoopThread(Runnable target, String name) {
+    super(name);
+    this.hadoopTarget = target;
+  }
+
+  public HadoopThread(String name) {
+    super(name);
+  }
+
+  public HadoopThread(ThreadGroup group, String name) {
+    super(group, name);
+  }
+
+  public HadoopThread(ThreadGroup group, Runnable target, String name) {
+    super(group, name);
+    this.hadoopTarget = target;
+  }

Review Comment:
   IMO that's out of scope for this ticket, @szetszwo .
   
   The current HadoopThread (now renamed to SubjectInheritingThread) 
intentionally follows the Thread syntax as close as possible for minimum 
changes in the callers.
   
   Adding a Builder and rewriting everything to use that in this patch would 
increase the patch size and would be error-prone IMO, while it wouldn't add 
anything to the Java 25 compatibility.
   
   I think that both a ThreadBuilder (in a separate class to avoid conflicts 
with the JDK21 native Thread.Builder) and rewriting the run()/work() overriding 
threads to use Runnables are good improvments, but they should be handled in a 
separate JIRA (or maybe even two separate JIRAs).



-- 
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

Reply via email to