From: Robert Varga Date: Mon, 1 Feb 2021 20:06:02 +0000 (+0100) Subject: Do not synchronize around ReactorStmtCtx.schemaPath X-Git-Tag: v7.0.0~230 X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=commitdiff_plain;h=0735f709c996762a2ac65338459c465bffc4dbcf;p=yangtools.git 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 --- 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();