[ 
https://issues.apache.org/jira/browse/HADOOP-19574?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18017896#comment-18017896
 ] 

ASF GitHub Bot commented on HADOOP-19574:
-----------------------------------------

stoty commented on PR #7892:
URL: https://github.com/apache/hadoop/pull/7892#issuecomment-3249122071

   I spent some time trying to implement that @szetszwo .
   
   At the core, we'd need a wrapper like this:
   
   ` 
     public static class SubjectInheritingWrapper extends Thread {
   
       private Thread wrapped;
       private Subject startSubject;
   
       public SubjectInheritingWrapper(Thread wrapped) {
         this.wrapped = wrapped;
       }
   
       @Override
       public synchronized void start() {
         startSubject = SubjectUtil.current();
         wrapped.start();
       }
   
       @Override
       public final void run() {
         SubjectUtil.doAs(startSubject, new PrivilegedAction<Void>() {
   
           @Override
           public Void run() {
             wrapped.run();
             return null;
           }
   
         });
       }
       
       public void interrupt() {
         wrapped.interrupt();
       }
       
       public boolean isInterrupted() {
         return wrapped.isInterrupted();
       }
       
       // setDaemon is final!!!
       public void setDaemon()...
     }`
     
   run() and start() are wrappable, but Thread is full of **final** methods 
which cannot be overriden, and would not work on the wrapper (which is never 
actually started, only the wrapped thread is).
   
   Say, we want to call setDaemon() on the wrapper. Since we cannot override 
it, it would set the daemon flag on the wrapper, not the wrapped thread, which 
is never even start() ed , and wouldn't work.
   
   So a wrapper like this would invisibly break the Thread contract in many 
ways.
   I don't think it's worth the risk of the hidden bugs that this could cause.
   




> Restore Subject propagation semantics for Java 22+
> --------------------------------------------------
>
>                 Key: HADOOP-19574
>                 URL: https://issues.apache.org/jira/browse/HADOOP-19574
>             Project: Hadoop Common
>          Issue Type: Improvement
>            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]

Reply via email to