mirror of https://github.com/apache/kafka.git
KAFKA-8162: IBM JDK Class not found error when handling SASL (#6524)
Attempt to load multiple IBM classes but fallback on loading the Sun class if the IBM one is not found. Reviewers: Mickael Maison <mickael.maison@gmail.com>, Ismael Juma <ismael@juma.me.uk>
This commit is contained in:
parent
fa7047ad9a
commit
d37d95b359
|
|
@ -49,7 +49,10 @@ public enum KerberosError {
|
|||
|
||||
static {
|
||||
try {
|
||||
if (Java.isIbmJdk()) {
|
||||
// different IBM JDKs versions include different security implementations
|
||||
if (Java.isIbmJdk() && canLoad("com.ibm.security.krb5.KrbException")) {
|
||||
KRB_EXCEPTION_CLASS = Class.forName("com.ibm.security.krb5.KrbException");
|
||||
} else if (Java.isIbmJdk() && canLoad("com.ibm.security.krb5.internal.KrbException")) {
|
||||
KRB_EXCEPTION_CLASS = Class.forName("com.ibm.security.krb5.internal.KrbException");
|
||||
} else {
|
||||
KRB_EXCEPTION_CLASS = Class.forName("sun.security.krb5.KrbException");
|
||||
|
|
@ -60,6 +63,15 @@ public enum KerberosError {
|
|||
}
|
||||
}
|
||||
|
||||
private static boolean canLoad(String clazz) {
|
||||
try {
|
||||
Class.forName(clazz);
|
||||
return true;
|
||||
} catch (Exception e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
private final int errorCode;
|
||||
private final boolean retriable;
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue