Skip to content

Commit

Permalink
Kafka client apply SubjectSubstitution only for graal version < 22.1
Browse files Browse the repository at this point in the history
Fixes #23411
  • Loading branch information
ozangunalp committed Feb 17, 2022
1 parent 4694cab commit c4748bf
Showing 1 changed file with 16 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,20 @@
import java.security.AccessControlContext;
import java.security.AccessController;
import java.util.concurrent.TimeUnit;
import java.util.function.BooleanSupplier;

import javax.security.auth.AuthPermission;
import javax.security.auth.Subject;
import javax.security.auth.SubjectDomainCombiner;

import org.graalvm.home.Version;

import com.github.benmanes.caffeine.cache.Cache;
import com.github.benmanes.caffeine.cache.Caffeine;
import com.oracle.svm.core.annotate.Substitute;
import com.oracle.svm.core.annotate.TargetClass;

@TargetClass(className = "javax.security.auth.Subject")
@TargetClass(className = "javax.security.auth.Subject", onlyWith = Target_javax_security_auth_Subject.Graal22_0OrEarlier.class)
final class Target_javax_security_auth_Subject {

@Substitute
Expand Down Expand Up @@ -96,4 +99,16 @@ final static class SubjectHolder {
.expireAfterAccess(1, TimeUnit.SECONDS)
.build();
}

/**
* 22.1.0 => false
* 22.0.0.2 => true
* 21.3.0 => true
*/
public static final class Graal22_0OrEarlier implements BooleanSupplier {
@Override
public boolean getAsBoolean() {
return Version.getCurrent().compareTo(22, 1) < 0;
}
}
}

0 comments on commit c4748bf

Please sign in to comment.