Skip to content

Commit d9cabe4

Browse files
committed
Downcast to the class of the check method.
In our unit test, we have a mock checker that doesn't extend EntitlementChecker, so downcasting to that would require us to needlessly rework the unit test.
1 parent 0a04b2e commit d9cabe4

File tree

1 file changed

+3
-6
lines changed
  • libs/entitlement/asm-provider/src/main/java/org/elasticsearch/entitlement/instrumentation/impl

1 file changed

+3
-6
lines changed

libs/entitlement/asm-provider/src/main/java/org/elasticsearch/entitlement/instrumentation/impl/InstrumenterImpl.java

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
import static org.objectweb.asm.Opcodes.INVOKEINTERFACE;
4242
import static org.objectweb.asm.Opcodes.INVOKESTATIC;
4343

44-
public class InstrumenterImpl implements Instrumenter {
44+
public final class InstrumenterImpl implements Instrumenter {
4545
private static final Logger logger = LogManager.getLogger(InstrumenterImpl.class);
4646

4747
private final String getCheckerClassMethodDescriptor;
@@ -272,7 +272,8 @@ public void visitCode() {
272272
}
273273

274274
private void pushEntitlementChecker() {
275-
InstrumenterImpl.this.pushEntitlementChecker(mv);
275+
mv.visitMethodInsn(INVOKESTATIC, handleClass, "instance", getCheckerClassMethodDescriptor, false);
276+
mv.visitTypeInsn(CHECKCAST, checkMethod.className());
276277
}
277278

278279
private void pushCallerClass() {
@@ -320,11 +321,7 @@ private void invokeInstrumentationMethod() {
320321
true
321322
);
322323
}
323-
}
324324

325-
protected void pushEntitlementChecker(MethodVisitor mv) {
326-
mv.visitMethodInsn(INVOKESTATIC, handleClass, "instance", getCheckerClassMethodDescriptor, false);
327-
mv.visitTypeInsn(CHECKCAST, "org/elasticsearch/entitlement/bridge/EntitlementChecker");
328325
}
329326

330327
record ClassFileInfo(String fileName, byte[] bytecodes) {}

0 commit comments

Comments
 (0)