From 7c48a8d56a178e6036e8da2b30e6232f27ffa4ce Mon Sep 17 00:00:00 2001 From: Henrique Prange Date: Tue, 24 Jun 2014 18:28:48 -0300 Subject: [PATCH 1/3] Unlock editing contexts disposed by the ERXRouteController The ERXRouteController disposes the editing context at the end of the request handling. If the editing context is autoLocked during the request, at least one lock will remain open at disposal time (because of the coalesceAutoLocks property). This change unlocks the editing context before disposing it, avoiding inaccurate warnings when the tracing open locks option is enabled. --- .../EOF/ERRest/Sources/er/rest/routes/ERXRouteController.java | 1 + 1 file changed, 1 insertion(+) diff --git a/Frameworks/EOF/ERRest/Sources/er/rest/routes/ERXRouteController.java b/Frameworks/EOF/ERRest/Sources/er/rest/routes/ERXRouteController.java index 30cd52d9e86..38e1f799b8c 100644 --- a/Frameworks/EOF/ERRest/Sources/er/rest/routes/ERXRouteController.java +++ b/Frameworks/EOF/ERRest/Sources/er/rest/routes/ERXRouteController.java @@ -1822,6 +1822,7 @@ public T controller(Class controllerClass) { */ public void dispose() { if (_shouldDisposeEditingContext && _editingContext != null) { + ERXEC.unlockAllContextsForCurrentThread(); _editingContext.dispose(); _editingContext = null; } From 0d8991b2208a4bc84490026d65cdfa20c25c67c2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=90=D0=BD=D0=B4=D1=80=D0=B5=D0=B8=CC=86=20=D0=A1=D1=82?= =?UTF-8?q?=D0=B0=D0=B2=D1=80=D0=B8=D0=BD=D0=BE=D0=B2?= Date: Mon, 30 Jun 2014 15:55:45 +0400 Subject: [PATCH 2/3] Revert change caused "Should pop, but ec not found in Vector" errors in RestAPI. - ERXApplication._endRequest() will call ERXEC.unlockAllContextsForCurrentThread() at proper time - It's became to be possible to have unlocked ECs, not being disposed by this RouteController. It's causes unexpected side effects --- .../EOF/ERRest/Sources/er/rest/routes/ERXRouteController.java | 1 - 1 file changed, 1 deletion(-) diff --git a/Frameworks/EOF/ERRest/Sources/er/rest/routes/ERXRouteController.java b/Frameworks/EOF/ERRest/Sources/er/rest/routes/ERXRouteController.java index 38e1f799b8c..30cd52d9e86 100644 --- a/Frameworks/EOF/ERRest/Sources/er/rest/routes/ERXRouteController.java +++ b/Frameworks/EOF/ERRest/Sources/er/rest/routes/ERXRouteController.java @@ -1822,7 +1822,6 @@ public T controller(Class controllerClass) { */ public void dispose() { if (_shouldDisposeEditingContext && _editingContext != null) { - ERXEC.unlockAllContextsForCurrentThread(); _editingContext.dispose(); _editingContext = null; } From ebff5a6de3edc032e57b2dd1769db11e6a842754 Mon Sep 17 00:00:00 2001 From: Henrique Prange Date: Mon, 30 Jun 2014 13:57:46 -0300 Subject: [PATCH 3/3] Unlock the editing context disposed by the ERXRouteController The ERXRouteController disposes the editing context at the end of the route request handling. If the editing context is autoLocked during the request, at least one lock will remain open at disposal time (because of the coalesceAutoLocks property). This change unlocks the editing context before disposing it, avoiding inaccurate warnings when the tracing open locks option is enabled. `ERROR er.extensions.eof.ERXEC - ERXEC@1877591773 Disposed with 1 locks (finalizing = false)` Which was created by the ERXRouteController: ``` ERROR er.extensions.eof.ERXEC - ERXEC@1877591773 Created: java.lang.Exception: Creation at er.extensions.eof.ERXEC.(ERXEC.java:471) at sun.reflect.GeneratedConstructorAccessor28.newInstance(Unknown Source) at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) at java.lang.reflect.Constructor.newInstance(Constructor.java:525) at er.extensions.eof.ERXEC$DefaultFactory._createEditingContext(ERXEC.java:1807) at er.extensions.eof.ERXEC$DefaultFactory._newEditingContext(ERXEC.java:1741) at br.com.doit.eof.DOitEditingContextFactory._newEditingContext(DOitEditingContextFactory.java:28) at er.extensions.eof.ERXEC$DefaultFactory._newEditingContext(ERXEC.java:1720) at er.extensions.eof.ERXEC.newEditingContext(ERXEC.java:1874) at er.rest.routes.ERXRouteController.newEditingContext(ERXRouteController.java:264) at er.rest.routes.ERXRouteController.editingContext(ERXRouteController.java:252) ``` This solution is more specific than the solution provided in the pull request #593 and reverted by the pull request #594. It unlocks ONLY the editing context created by the ERXRouteController, rather than unlocking all editing contexts in the current thread. --- .../EOF/ERRest/Sources/er/rest/routes/ERXRouteController.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Frameworks/EOF/ERRest/Sources/er/rest/routes/ERXRouteController.java b/Frameworks/EOF/ERRest/Sources/er/rest/routes/ERXRouteController.java index 30cd52d9e86..b67ffaf5460 100644 --- a/Frameworks/EOF/ERRest/Sources/er/rest/routes/ERXRouteController.java +++ b/Frameworks/EOF/ERRest/Sources/er/rest/routes/ERXRouteController.java @@ -1822,6 +1822,10 @@ public T controller(Class controllerClass) { */ public void dispose() { if (_shouldDisposeEditingContext && _editingContext != null) { + if(_editingContext instanceof ERXEC && ((ERXEC) _editingContext).isAutoLocked()) { + _editingContext.unlock(); + } + _editingContext.dispose(); _editingContext = null; }