Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IllegalArgumentException thrown when List<Deferred<T>>.awaitAll() is used on List<TransactionResult<T>> #658

Closed
emanguy opened this issue Oct 16, 2019 · 2 comments
Labels

Comments

@emanguy
Copy link

emanguy commented Oct 16, 2019

Assume augmentItem(item) is just a private function which executes 3 queries across various tables and I have nested transactions enabled on the DB.

If I do:

newSuspendedTransaction(Dispatchers.IO) {
  val listOfItems = /* Transaction extension, invokes suspendedTransaction and does a query */
  val results = listOfItems.suspendedTransactionAsync { augmentItem(item) }.awaitAll()
}

It will fail on the awaitAll, saying the transaction is already closed.

On the other hand, the following works:

newSuspendedTransaction(Dispatchers.IO) {
  val listOfItems = /* Transaction extension, invokes suspendedTransaction and does a query */
  val results = listOfItems.suspendedTransactionAsync { augmentItem(item) }.map { it.await() }
}

I'm 99% certain this is a bug given TransactionResult inherits from Deferred. This occurs on Exposed 1.17.6.

@Tapac Tapac added the bug label Oct 23, 2019
@Tapac
Copy link
Contributor

Tapac commented Oct 23, 2019

I'm 99% certain this is a bug given TransactionResult inherits from Deferred.

You are right. After some debug I faced that only inheritors of async could work normally with awaitAll while TransactionResult just delegates to async.

I thinking about remove TransactionResult and just use a simple async instead. What do you think?

@emanguy
Copy link
Author

emanguy commented Nov 1, 2019

Yeah, that seems to be a good way to move forward. Let me know if I can do anything to help.

Tapac added a commit that referenced this issue Nov 3, 2019
@Tapac Tapac closed this as completed Nov 3, 2019
Tapac added a commit that referenced this issue Nov 3, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants