He-Pin commented on code in PR #457:
URL:
https://github.com/apache/pekko-persistence-r2dbc/pull/457#discussion_r3654445327
##########
core/src/main/scala/org/apache/pekko/persistence/r2dbc/internal/R2dbcExecutor.scala:
##########
@@ -319,27 +346,65 @@ class R2dbcExecutor(val connectionFactory:
ConnectionFactory, log: Logger, logDb
result.failed.foreach { exc =>
log.debug("{} - DB call failed: {}", logPrefix: Any, exc: Any)
// auto-commit so nothing to rollback
- connection.close().asFutureDone()
+ val done = connection.close().asFutureDone()
+ timeoutTask.foreach { task => done.onComplete(_ => task.cancel()) }
}
result.flatMap { r =>
- connection.close().asFutureDone().map { _ =>
- val durationMicros = durationInMicros(startTime)
- if (durationMicros >= logDbCallsExceedingMicros)
- log.info("{} - DB call completed [{}] in [{}] µs", logPrefix,
Option(r).map(_.toString).orNull,
- durationMicros: java.lang.Long)
- r
- }
+ val done = connection
+ .close()
+ .asFutureDone()
+ .map { _ =>
+ val durationMicros = durationInMicros(startTime)
+ if (durationMicros >= logDbCallsExceedingMicros)
+ log.info("{} - DB call completed [{}] in [{}] µs", logPrefix,
Option(r).map(_.toString).orNull,
+ durationMicros: java.lang.Long)
+ r
+ }
+ timeoutTask.foreach { task => done.onComplete(_ => task.cancel()) }
+ done
}
}
}
}
private def commitAndClose(connection: Connection): Future[Done] = {
- connection.commitTransaction().asFutureDone().andThen { case _ =>
connection.close().asFutureDone() }
+ connection.commitTransaction().asFutureDone().andThen { case _ =>
+ try connection.close().asFutureDone()
+ catch ignoreConnectionClosedException
+ }
}
private def rollbackAndClose(connection: Connection): Future[Done] = {
- connection.rollbackTransaction().asFutureDone().andThen { case _ =>
connection.close().asFutureDone() }
+ try connection
+ .rollbackTransaction()
+ .asFutureDone()
+ .andThen { case _ =>
+ try connection.close().asFutureDone()
+ catch ignoreConnectionClosedException
+
+ }
Review Comment:
stray blank line before the catch
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]