Remove synchronization locking 08/105808/7
authorSamuel Schneider <samuel.schneider@pantheon.tech>
Wed, 18 Oct 2023 12:16:43 +0000 (14:16 +0200)
committerIvan Hrasko <ivan.hrasko@pantheon.tech>
Fri, 20 Oct 2023 08:28:33 +0000 (08:28 +0000)
All sal-restconf-docgen API methods were synchronized
due to bug causing thread access to the SchemaContext
be not synchronized properly. The bug should be no longer
present as SchemaContext is declared to be safe for usage
in multi threaded environment.

JIRA: NETCONF-1049
Change-Id: I86818ee3c93f68f4a5f5bbd8d8fb6e8f6a8ee21c
Signed-off-by: tobias.pobocik <tobias.pobocik@pantheon.tech>
Signed-off-by: Samuel Schneider <samuel.schneider@pantheon.tech>
restconf/restconf-openapi/src/main/java/org/opendaylight/restconf/openapi/impl/OpenApiServiceImpl.java

index b758618408f18a7e35ed6fa5efaea2e0b373433b..4b8b31c3d4f0fd08a08073e79f1f847bb3ead27f 100644 (file)
@@ -32,13 +32,6 @@ import org.osgi.service.component.annotations.Reference;
  * <a href="https://helloreverb.com/developers/swagger"
  * >https://helloreverb.com/developers/swagger</a>) compliant documentation for
  * RESTCONF APIs. The output of this is used by embedded Swagger UI.
- *
- * <p>
- * NOTE: These API's need to be synchronized due to bug 1198. Thread access to
- * the SchemaContext is not synchronized properly and thus you can end up with
- * missing definitions without this synchronization. There are likely otherways
- * to work around this limitation, but given that this API is a dev only tool
- * and not dependent UI, this was the fastest work around.
  */
 @Component
 @Singleton
@@ -75,7 +68,7 @@ public final class OpenApiServiceImpl implements OpenApiService {
     }
 
     @Override
-    public synchronized Response getAllModulesDoc(final UriInfo uriInfo) {
+    public Response getAllModulesDoc(final UriInfo uriInfo) {
         final DefinitionNames definitionNames = new DefinitionNames();
         final OpenApiObject doc = openApiGeneratorRFC8040.getControllerModulesDoc(uriInfo, definitionNames);
         return Response.ok(doc).build();
@@ -85,7 +78,7 @@ public final class OpenApiServiceImpl implements OpenApiService {
      * Generates Swagger compliant document listing APIs for module.
      */
     @Override
-    public synchronized Response getDocByModule(final String module, final String revision, final UriInfo uriInfo) {
+    public Response getDocByModule(final String module, final String revision, final UriInfo uriInfo) {
         return Response.ok(
             openApiGeneratorRFC8040.getApiDeclaration(module, revision, uriInfo))
             .build();
@@ -95,12 +88,12 @@ public final class OpenApiServiceImpl implements OpenApiService {
      * Redirects to embedded swagger ui.
      */
     @Override
-    public synchronized Response getApiExplorer(final UriInfo uriInfo) {
+    public Response getApiExplorer(final UriInfo uriInfo) {
         return Response.seeOther(uriInfo.getBaseUriBuilder().path("../explorer/index.html").build()).build();
     }
 
     @Override
-    public synchronized Response getListOfMounts(final UriInfo uriInfo) {
+    public Response getListOfMounts(final UriInfo uriInfo) {
         final List<MountPointInstance> entity = mountPointOpenApiRFC8040
                 .getInstanceIdentifiers().entrySet().stream()
                 .map(entry -> new MountPointInstance(entry.getKey(), entry.getValue()))
@@ -109,7 +102,7 @@ public final class OpenApiServiceImpl implements OpenApiService {
     }
 
     @Override
-    public synchronized Response getMountDocByModule(final String instanceNum, final String module,
+    public Response getMountDocByModule(final String instanceNum, final String module,
                                                      final String revision, final UriInfo uriInfo) {
         final OpenApiObject api = mountPointOpenApiRFC8040.getMountPointApi(uriInfo, Long.parseLong(instanceNum),
             module, revision);
@@ -117,7 +110,7 @@ public final class OpenApiServiceImpl implements OpenApiService {
     }
 
     @Override
-    public synchronized Response getMountDoc(final String instanceNum, final UriInfo uriInfo) {
+    public Response getMountDoc(final String instanceNum, final UriInfo uriInfo) {
         final String stringPageNum = uriInfo.getQueryParameters().getFirst(PAGE_NUM);
         final OpenApiObject api = mountPointOpenApiRFC8040.getMountPointApi(uriInfo,
                 Long.parseLong(instanceNum), stringPageNum);