From 0735f709c996762a2ac65338459c465bffc4dbcf Mon Sep 17 00:00:00 2001 From: Robert Varga Date: Mon, 1 Feb 2021 21:06:02 +0100 Subject: [PATCH] Do not synchronize around ReactorStmtCtx.schemaPath The reactor is inherently single-threaded, hence there is no point in guarding this single field. Remove synchronization and add a few markes for future improvement. JIRA: YANGTOOLS-1218 Change-Id: Ic5017bb589ae5086bf8310995d7c03c80e12678a Signed-off-by: Robert Varga --- .../parser/stmt/reactor/ReactorStmtCtx.java | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/yang/yang-parser-reactor/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/reactor/ReactorStmtCtx.java b/yang/yang-parser-reactor/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/reactor/ReactorStmtCtx.java index a7f3941042..5e9f5983e2 100644 --- a/yang/yang-parser-reactor/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/reactor/ReactorStmtCtx.java +++ b/yang/yang-parser-reactor/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/reactor/ReactorStmtCtx.java @@ -154,8 +154,8 @@ abstract class ReactorStmtCtx, E extends Effec // SchemaPath cache for use with SubstatementContext and InferredStatementContext. This hurts RootStatementContext // a bit in terms of size -- but those are only a few and SchemaPath is on its way out anyway. - @Deprecated - private volatile SchemaPath schemaPath; + // FIXME: this should become 'QName' + private SchemaPath schemaPath; ReactorStmtCtx() { // Empty on purpose @@ -559,19 +559,13 @@ abstract class ReactorStmtCtx, E extends Effec // Exists only to support {SubstatementContext,InferredStatementContext}.schemaPath() @Deprecated final @Nullable SchemaPath substatementGetSchemaPath() { - SchemaPath local = schemaPath; - if (local == null) { - synchronized (this) { - local = schemaPath; - if (local == null) { - schemaPath = local = createSchemaPath((StatementContextBase) coerceParentContext()); - } - } + if (schemaPath == null) { + schemaPath = createSchemaPath((StatementContextBase) coerceParentContext()); } - - return local; + return schemaPath; } + // FIXME: 7.0.0: this method's logic needs to be moved to the respective StatementSupport classes @Deprecated private SchemaPath createSchemaPath(final StatementContextBase parent) { final SchemaPath parentPath = parent.getSchemaPath(); -- 2.36.6