Exception trace print eaten when using afterRollback?

Skip to first unread message

Hanns Holger Rutz

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 + ">" )

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

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


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

Nathan Bronson

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?

> --

Nathan Grasso Bronson
Reply all
Reply to author
0 new messages