From 0190a5c85a12961a3111b5434d5e291930b600c3 Mon Sep 17 00:00:00 2001 From: Florian Mounier Date: Fri, 13 Dec 2024 16:39:15 +0100 Subject: [PATCH] [FIX] endpoint_route_handler: Rollback dedicated routing cursor --- endpoint_route_handler/models/ir_http.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/endpoint_route_handler/models/ir_http.py b/endpoint_route_handler/models/ir_http.py index fae37027..0f983472 100644 --- a/endpoint_route_handler/models/ir_http.py +++ b/endpoint_route_handler/models/ir_http.py @@ -58,7 +58,8 @@ def routing_map(cls, key=None): # which will in turn use the updated value of the oauth token to compute # the session token, and the security check will not fail. registry = registry_get(http.request.env.cr.dbname) - with registry.cursor() as cr: + cr = registry.cursor() + try: last_version = cls._get_routing_map_last_version(cr) if not hasattr(cls, "_routing_map"): _logger.debug( @@ -71,6 +72,13 @@ def routing_map(cls, key=None): cls._routing_map = {} cls._rewrite_len = {} cls._endpoint_route_last_version = last_version + finally: + # No commit is needed here as nothing should be modified since + # this cursor is only here to read the last version of the routing + # map in a different cursor than the request one, see above comment. + cr.rollback() + cr.close() + return super().routing_map(key=key) @classmethod