Skip to content

Commit

Permalink
Make MockMakerRegistry initialization lazy (#1826)
Browse files Browse the repository at this point in the history
  • Loading branch information
AndreasTu authored Nov 12, 2023
1 parent 2c0731d commit 1329afc
Showing 1 changed file with 12 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -78,15 +78,9 @@ private void start() {
ConfigurationBuilder builder = new ConfigurationBuilder();
builder.build(globalExtensionRegistry, configurationScript);
}
initMockMakerRegistry();
globalExtensionRegistry.startGlobalExtensions();
}

private void initMockMakerRegistry() {
MockMakerConfiguration configuration = globalExtensionRegistry.getConfigurationByType(MockMakerConfiguration.class);
this.mockMakerRegistry = MockMakerRegistry.createFromServiceLoader(configuration);
}

void stop() {
globalExtensionRegistry.stopGlobalExtensions();
}
Expand All @@ -105,9 +99,21 @@ public ExtensionRunner createExtensionRunner(SpecInfo spec) {
}

public MockMakerRegistry getMockMakerRegistry() {
initMockMakerRegistry();
return Objects.requireNonNull(mockMakerRegistry);
}

private void initMockMakerRegistry() {
if (mockMakerRegistry == null) {
synchronized (this) {
if (mockMakerRegistry == null) {
MockMakerConfiguration configuration = globalExtensionRegistry.getConfigurationByType(MockMakerConfiguration.class);
mockMakerRegistry = MockMakerRegistry.createFromServiceLoader(configuration);
}
}
}
}

public PlatformParameterizedSpecRunner createSpecRunner(SpecInfo spec) {
return new PlatformParameterizedSpecRunner(
new MasterRunSupervisor(spec, createStackTraceFilter(spec), diffedObjectRenderer));
Expand Down

0 comments on commit 1329afc

Please sign in to comment.