From c65d99e35d53e5283484ba0f1f7216f92acda54e Mon Sep 17 00:00:00 2001 From: dankito Date: Wed, 27 Nov 2024 03:35:19 +0100 Subject: [PATCH] Removed unnecessary async { } --- .../codinux/invoicing/email/EmailsFetcher.kt | 26 +++++++++---------- 1 file changed, 12 insertions(+), 14 deletions(-) diff --git a/e-invoice-domain/src/main/kotlin/net/codinux/invoicing/email/EmailsFetcher.kt b/e-invoice-domain/src/main/kotlin/net/codinux/invoicing/email/EmailsFetcher.kt index e7a73a2..8cfb9b3 100644 --- a/e-invoice-domain/src/main/kotlin/net/codinux/invoicing/email/EmailsFetcher.kt +++ b/e-invoice-domain/src/main/kotlin/net/codinux/invoicing/email/EmailsFetcher.kt @@ -117,23 +117,21 @@ open class EmailsFetcher( return@runBlocking emptyList() } - async(coroutineDispatcher) { - val startUid = max(status.options.lastRetrievedMessageId?.let { it + 1 } ?: 0, 1) // message numbers start at 1 + val startUid = max(status.options.lastRetrievedMessageId?.let { it + 1 } ?: 0, 1) // message numbers start at 1 - folder.getMessagesByUID(startUid, UIDFolder.MAXUID).mapNotNull { message -> - async(coroutineDispatcher) { - try { - getEmail(message, status) - } catch (e: Throwable) { - log.error(e) { "Could not get email $message" } - status.addError(FetchEmailsErrorType.GetEmail, message, e) - null - } + folder.getMessagesByUID(startUid, UIDFolder.MAXUID).mapNotNull { message -> + async(coroutineDispatcher) { + try { + getEmail(message, status) + } catch (e: Throwable) { + log.error(e) { "Could not get email $message" } + status.addError(FetchEmailsErrorType.GetEmail, message, e) + null } } - .awaitAll() - .filterNotNull() - }.await() + } + .awaitAll() + .filterNotNull() } protected open fun getEmail(message: Message, status: FetchEmailsStatus): Email? {