From 6cbdeeb8bf274df6aef1ae352441c1d78e04b736 Mon Sep 17 00:00:00 2001 From: Stephane Epardaud Date: Thu, 7 Nov 2019 11:57:29 +0100 Subject: [PATCH] Fix #5274 for Mongo too --- .../PanacheMongoRepositoryEnhancer.java | 37 ++++++++++--------- 1 file changed, 20 insertions(+), 17 deletions(-) diff --git a/extensions/panache/mongodb-panache/deployment/src/main/java/io/quarkus/mongodb/panache/deployment/PanacheMongoRepositoryEnhancer.java b/extensions/panache/mongodb-panache/deployment/src/main/java/io/quarkus/mongodb/panache/deployment/PanacheMongoRepositoryEnhancer.java index 988a942d7420b..4e52f05f3fbba 100644 --- a/extensions/panache/mongodb-panache/deployment/src/main/java/io/quarkus/mongodb/panache/deployment/PanacheMongoRepositoryEnhancer.java +++ b/extensions/panache/mongodb-panache/deployment/src/main/java/io/quarkus/mongodb/panache/deployment/PanacheMongoRepositoryEnhancer.java @@ -50,23 +50,26 @@ protected String getPanacheOperationsBinaryName() { @Override public void visitEnd() { - // Bridge for findById - MethodVisitor mv = super.visitMethod(Opcodes.ACC_PUBLIC | Opcodes.ACC_SYNTHETIC | Opcodes.ACC_BRIDGE, - "findById", - "(Ljava/lang/Object;)Ljava/lang/Object;", - null, - null); - mv.visitParameter("id", 0); - mv.visitCode(); - mv.visitIntInsn(Opcodes.ALOAD, 0); - mv.visitIntInsn(Opcodes.ALOAD, 1); - mv.visitMethodInsn(Opcodes.INVOKEVIRTUAL, - daoBinaryName, - "findById", - "(Ljava/lang/Object;)" + entitySignature, false); - mv.visitInsn(Opcodes.ARETURN); - mv.visitMaxs(0, 0); - mv.visitEnd(); + // Bridge for findById, but only if we actually know the end entity (which we don't for intermediate + // abstract repositories that haven't fixed their entity type yet + if (!entitySignature.equals("Ljava/lang/Object;")) { + MethodVisitor mv = super.visitMethod(Opcodes.ACC_PUBLIC | Opcodes.ACC_SYNTHETIC | Opcodes.ACC_BRIDGE, + "findById", + "(Ljava/lang/Object;)Ljava/lang/Object;", + null, + null); + mv.visitParameter("id", 0); + mv.visitCode(); + mv.visitIntInsn(Opcodes.ALOAD, 0); + mv.visitIntInsn(Opcodes.ALOAD, 1); + mv.visitMethodInsn(Opcodes.INVOKEVIRTUAL, + daoBinaryName, + "findById", + "(Ljava/lang/Object;)" + entitySignature, false); + mv.visitInsn(Opcodes.ARETURN); + mv.visitMaxs(0, 0); + mv.visitEnd(); + } super.visitEnd(); }