Skip to content

Commit

Permalink
Substitute getUnsafe of shaded protobuf.UnsafeUtil in kafka
Browse files Browse the repository at this point in the history
Duplicate of the substitution in `GrpcSubstitutions` of the unshaded
class.

Fixes: quarkusio#40100
  • Loading branch information
zakkak committed May 17, 2024
1 parent 455ec6c commit b8094eb
Showing 1 changed file with 17 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
package io.smallrye.reactive.kafka.graal;

import java.lang.reflect.Field;
import java.lang.reflect.InvocationTargetException;

import com.oracle.svm.core.annotate.Substitute;
import com.oracle.svm.core.annotate.TargetClass;

import sun.misc.Unsafe;

@TargetClass(className = "org.apache.kafka.common.network.SaslChannelBuilder")
final class Target_org_apache_kafka_common_network_SaslChannelBuilder {

Expand All @@ -17,6 +20,20 @@ private static String defaultKerberosRealm() throws ClassNotFoundException, NoSu

}

@TargetClass(className = "org.apache.kafka.shaded.com.google.protobuf.UnsafeUtil")
final class Target_org_apache_kafka_shaded_com_google_protobuf_UnsafeUtil {
@Substitute
static sun.misc.Unsafe getUnsafe() {
try {
Field theUnsafe = Unsafe.class.getDeclaredField("theUnsafe");
theUnsafe.setAccessible(true);
return (Unsafe) theUnsafe.get(null);
} catch (Exception e) {
throw new RuntimeException(e);
}
}
}

class KafkaSubstitutions {

}

0 comments on commit b8094eb

Please sign in to comment.