Exception trace print eaten when using afterRollback?

20 views
Skip to first unread message

Hanns Holger Rutz

unread,
Oct 16, 2012, 4:42:59 AM10/16/12
to scala-stm-e...@googlegroups.com
Hi there,

I am having some trouble with exceptions not being printed under certain circumstances; I wonder if I'm doing something wrong?

I am coupling a Scala-STM transaction to a database transaction, as soon as database I/O is involved. This looks roughly like this:

val dbTxnRef = TxnLocal( initialValue = { implicit tx =>
Txn.setExternalDecider( this )
val dbTxn = dbEnv.beginTransaction( null, dbTxnCfg )
val dbTxnID = res.getId
log( "database txn begin <" + dbTxnID + ">" )
Txn.afterRollback({ status =>
log( "database txn rollback <" + dbTxnID + ">" )
dbTxn.abort()
})
dbTxn
})

Now, the above rollback hook is properly entered with the following:

RolledBack(UncaughtExceptionCause(java.lang.UnsupportedOperationException: init of empty finger tree))

But the wrapped exception is not printed to Console.err; I think this normally happens when I don't have the above TxnLocal initialized.

Is this expected behaviour? Should I just print the exception myself in the afterRollback hook?

best, .h.h.

Hanns Holger Rutz

unread,
Oct 16, 2012, 5:12:50 AM10/16/12
to scala-stm-e...@googlegroups.com
It seems fine when I explicitly print the exception

https://github.com/Sciss/LucreSTM/commit/730b9b2c2bf7fdfbbbdb109d1e6f99f2df6ccdd5

... so it's just to know if the 'swallowing' is expected when using afterRollback
> --
>
>
>

Nathan Bronson

unread,
Oct 16, 2012, 5:06:14 PM10/16/12
to scala-stm-e...@googlegroups.com
afterRollback shouldn't swallow. When I execute

atomic { implicit txn =>
Txn.afterRollback { s => println("in afterRollback: " + s) }
println("in txn")
throw new Exception
}

in the REPL the exception is not swallowed. Can you give me a bit more info?

Thanks,
Nathan
> --
>
>
>



--
Nathan Grasso Bronson
ngbr...@gmail.com
Reply all
Reply to author
Forward
0 new messages