[
https://issues.apache.org/jira/browse/HADOOP-19574?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18016855#comment-18016855
]
ASF GitHub Bot commented on HADOOP-19574:
-----------------------------------------
stoty commented on code in PR #7892:
URL: https://github.com/apache/hadoop/pull/7892#discussion_r2308198971
##########
hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/util/concurrent/TestSubjectPropagation.java:
##########
@@ -0,0 +1,125 @@
+/**
+ * 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
+ * <p>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p>
+ * 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 static org.junit.jupiter.api.Assertions.assertEquals;
+
+import java.util.concurrent.Callable;
+
+import javax.security.auth.Subject;
+
+import org.apache.hadoop.security.authentication.util.SubjectUtil;
+import org.apache.hadoop.util.Daemon;
+import org.junit.jupiter.api.Test;
+
+public class TestSubjectPropagation {
+
+ private Subject childSubject = null;
+
+ @Test
+ public void testWork() {
+ Subject parentSubject = new Subject();
+ childSubject = null;
+
+ SubjectUtil.callAs(parentSubject, new Callable<Void>() {
+ public Void call() throws InterruptedException {
+ HadoopThread t = new HadoopThread() {
+ public void work() {
+ childSubject = SubjectUtil.current();
+ }
+ };
+ t.start();
+ t.join(1000);
+ return (Void) null;
+ }
+ });
+
+ assertEquals(parentSubject, childSubject);
+ }
+
+ @Test
+ public void testRunnable() {
+ Subject parentSubject = new Subject();
+ childSubject = null;
+
+ SubjectUtil.callAs(parentSubject, new Callable<Void>() {
+ public Void call() throws InterruptedException {
+ Runnable r = new Runnable() {
+ @Override
+ public void run() {
+ childSubject = SubjectUtil.current();
+ }
+ };
+
+ HadoopThread t = new HadoopThread(r);
Review Comment:
Done
> 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: [email protected]
For additional commands, e-mail: [email protected]