Skip to content

OpenApiContextLocator getInstance() is not thread safe #3016

@jlw0

Description

@jlw0

Summary

The OpenApiContextLocator getInstance() method is not thread safe and could cause a registered OpenApiContext to be lost during configuration.

Component

swagger-integration

Version

2.0.5

Description

The OpenApiContextLocator provides a static singleton instance via its getInstance() method. This method has the potential to create multiple OpenApiContextLocator instances when it is being accessed by more than one thread. This could cause a registered OpenApiContext to be lost during configuration.

Proposed Solution

Change this method so that it is synchronized. If performance is a concern double-checked locking may be used, but this approach is not normally recommended (see http://www.cs.umd.edu/~pugh/java/memoryModel/DoubleCheckedLocking.html)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions