Reactor-core: OnErrorContinue throws already handled Exceptions

Created on 6 May 2020  路  8Comments  路  Source: reactor/reactor-core


I am using reactor with MongoDB and when saving to Mongo I get the following exception when using OnErrorContinue

org.springframework.transaction.reactive.TransactionContextManager$NoTransactionInContextException: No transaction in context

However, the data has been saved correctly in MongoDB. It seems that already handled Exceptions are still being catch by onErrorContinue.

I found the following link describing that behaviour.
https://github.com/spring-projects/spring-data-r2dbc/issues/211

My question is, what is the semactic of onErrorContinue? Should it received already handled exceptions? Is it a bug? I could not find any description of onErrorContinue on the documentation.

Expected Behavior


Already handled Exception should not be handled by onErrorContinue

Actual Behavior


Actually onErrorContinue is getting already handled Exceptions.

Steps to Reproduce

        mongoRepository
                .save(data)
                .onErrorContinue { e, _ -> logger.warn("Error saving data to repository: $e") }


Then code above prints the following error:
org.springframework.transaction.reactive.TransactionContextManager$NoTransactionInContextException: No transaction in context

Although, the data is being saved in MongoDB.

Possible Solution

Your Environment


  • Reactor version(s) used: reactor-core 3.3.2
  • Other relevant libraries versions (eg. netty, ...):
  • JVM version (javar -version): 1.8
  • OS and version (eg uname -a): Linux Ubuntu 18
fouser-attention statudeclined statuhas-workaround

Most helpful comment

I'm having same issue here

All 8 comments

I'm having same issue here

@mp911de does that ring a bell? In particular the data being visible in mongo despite the apparent transaction error ?

@ovu what happens if you DON'T use onErrorContinue? eg. replace it with a .log()?

By the way, this operatore is one that you should refrain from using if you don't fully understand the implications of it.

NoTransactionInContextException isn鈥檛 an error, it鈥檚 the signal Spring's transaction infrastructure uses to signal that no transaction is in progress.

mmh this makes me fear that onErrorContinue could impair some sources, like the mongo reactive repository in the present case, because it propagates through Context to the whole upstream chain 馃う

@ovu what happens if you DON'T use onErrorContinue? eg. replace it with a .log()?

can you answer the question? have you tried using onErrorReturn or onErrorResume rather than onErrorContinue ?

@simonbasle Sorry for the delay.

Changing the code to use onErrorReturn or onErrorResume the code worked as it should be. The issue is only related to onErrorContinue together with the MongoDB integration. Only onErrorContinue throws the error NoTransactionInContextException even the data was saved in Mongo. It looks like a bug in the MongoDb integration.

Some work will be done around #2184. in the meantime, onErrorContinue is probably not the best tool for you to use right now (double-edged sword) => please favor the other standard error handling options.

Was this page helpful?
0 / 5 - 0 ratings