Bug 267 : @Transactional with a TxType ... enhanced with wrong type
Priority 
High
Reported Version 
 
Logged By 
Rob
Status 
Fixed
Fixed Version 
2.6.0
Assigned To 
 
Product 
Ebean - core
Duplicate Of 
 
Created 
08/04/2010
Updated 
08/04/2010
Type 
Bug
 
Attachments 
No attachments
public class TestDAO {

    public TestDAO() {
    }

    @Transactional(type=TxType.REQUIRED)
    public void transactional() {
        // bla
    }
}

The problem:

We couldn't instantiate a new instance of it after it was enhanced, "new TestDAO();" would fail on an IllegalArgumentException. We fixed the problem in ScopeTransAdapter.setTxType(Object TxType). We changed it from:

private void setTxType(Object txType){
       
        mv.visitVarInsn(ALOAD, posTxScope);
        mv.visitLdcInsn(txType.toString());
        mv.visitMethodInsn(INVOKESTATIC, C_TXTYPE, "valueOf", "(Ljava/lang/String;)L"+C_TXTYPE+";");
        mv.visitMethodInsn(INVOKEVIRTUAL, C_TXSCOPE, "setType", "(L"+C_TXSCOPE+";)L"+C_TXSCOPE+";");
        mv.visitInsn(POP);
    }

Into:

private void setTxType(Object txType){
       
        mv.visitVarInsn(ALOAD, posTxScope);
        mv.visitLdcInsn(txType.toString());
        mv.visitMethodInsn(INVOKESTATIC, C_TXTYPE, "valueOf", "(Ljava/lang/String;)L"+C_TXTYPE+";");
        mv.visitMethodInsn(INVOKEVIRTUAL, C_TXSCOPE, "setType", "(L"+C_TXTYPE+";)L"+C_TXSCOPE+";");
        mv.visitInsn(POP);
    }
 
Rob 08 Apr 21:11
Note:

Note the issue is with the argument type of C_TXSCOPE which should be C_TXTYPE.

Rob 08 Apr 21:16
FYI:

The stack trace that occurs is:

java.lang.VerifyError: (class: com/avaje/tests/model/basic/xtra/TestDao, method: doSomething signature: ()V) Incompatible argument to function
at com.avaje.tests.unitinternal.TestTxTypeOnTransactional.test(TestTxTypeOnTransactional.java:11)
...

Rob 08 Apr 21:18
Suggested fix from Rien confirmed

Suggested fix from Rien confirmed - and now fixed in HEAD.

woResponse

Upload a file