Uploaded image for project: 'PUBLIC - Liferay Faces'
  1. PUBLIC - Liferay Faces
  2. FACES-2835

BridgeFactoryFinder's lazy-instantiation is not thread-safe

    Details

      Description

      {markdown}
      `BridgeFactoryFinder` uses a simple null check in its `getInstance()` method to lazily load the `BridgeFactoryFinder` singleton: {markdown}
      if (instance == null) {
      
      	ServiceLoader<BridgeFactoryFinder> serviceLoader = ServiceLoader.load(BridgeFactoryFinder.class);
      	Iterator<BridgeFactoryFinder> iterator = serviceLoader.iterator();
      
      	while ((instance == null) && iterator.hasNext()) {
      		instance = iterator.next();
      	}
      
      	if (instance == null) {
      		throw new FacesException("Unable locate service for " + BridgeFactoryFinder.class.getName());
      	}
      }
      
      {markdown}
      Since `BridgeFactoryFinder` may be accessed by multiple threads at the same time, the `getInstance()` method could potential return a partial constructed `BridgeFactoryFinder`.{markdown}

        Attachments

          Activity

            People

            • Assignee:
              kyle.stiemann Kyle Stiemann (Inactive)
              Reporter:
              kyle.stiemann Kyle Stiemann (Inactive)
              Participants of an Issue:
            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Packages

                Version Package
                bridge-api-2.0.0
                bridge-api-3.0.0
                bridge-api-4.0.0