Skip to content

Commit

Permalink
Merge pull request #15609 from gsmet/avoid-race-condition-when-creati…
Browse files Browse the repository at this point in the history
…ng-dev-routes

Avoid race condition when creating the Dev UI routes
  • Loading branch information
gsmet authored Mar 10, 2021
2 parents 5df1b6a + dda1c9e commit 19e87cc
Showing 1 changed file with 21 additions and 28 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -305,21 +305,37 @@ public ServiceStartBuildItem setupDeploymentSideHandling(List<DevTemplatePathBui
@Record(ExecutionTime.RUNTIME_INIT)
@Consume(LoggingSetupBuildItem.class)
@BuildStep(onlyIf = IsDevelopment.class)
public void setupDevConsoleRoutes(List<DevConsoleRouteBuildItem> routes,
BuildProducer<RouteBuildItem> routeBuildItemBuildProducer,
LogStreamRecorder recorder,
public void setupDevConsoleRoutes(
DevConsoleRecorder recorder,
LogStreamRecorder logStreamRecorder,
List<DevConsoleRouteBuildItem> routes,
CurateOutcomeBuildItem curateOutcomeBuildItem,
HistoryHandlerBuildItem historyHandlerBuildItem,
NonApplicationRootPathBuildItem nonApplicationRootPathBuildItem,
LaunchModeBuildItem launchModeBuildItem) {
LaunchModeBuildItem launchModeBuildItem,
ShutdownContextBuildItem shutdownContext,
BuildProducer<RouteBuildItem> routeBuildItemBuildProducer) throws IOException {
if (launchModeBuildItem.getDevModeType().orElse(null) != DevModeType.LOCAL) {
return;
}

// Add the static resources
AppArtifact devConsoleResourcesArtifact = WebJarUtil.getAppArtifact(curateOutcomeBuildItem, "io.quarkus",
"quarkus-vertx-http-deployment");

Path devConsoleStaticResourcesDeploymentPath = WebJarUtil.copyResourcesForDevOrTest(curateOutcomeBuildItem,
launchModeBuildItem,
devConsoleResourcesArtifact, STATIC_RESOURCES_PATH);

routeBuildItemBuildProducer.produce(nonApplicationRootPathBuildItem.routeBuilder()
.route("dev/resources/*")
.handler(recorder.devConsoleHandler(devConsoleStaticResourcesDeploymentPath.toString(), shutdownContext))
.build());

// Add the log stream
routeBuildItemBuildProducer.produce(nonApplicationRootPathBuildItem.routeBuilder()
.route("dev/logstream")
.handler(recorder.websocketHandler(historyHandlerBuildItem.value))
.handler(logStreamRecorder.websocketHandler(historyHandlerBuildItem.value))
.build());

for (DevConsoleRouteBuildItem i : routes) {
Expand Down Expand Up @@ -349,29 +365,6 @@ public void setupDevConsoleRoutes(List<DevConsoleRouteBuildItem> routes,
.build());
}

@BuildStep(onlyIf = IsDevelopment.class)
@Record(ExecutionTime.RUNTIME_INIT)
public void deployStaticResources(DevConsoleRecorder recorder, CurateOutcomeBuildItem curateOutcomeBuildItem,
LaunchModeBuildItem launchMode, ShutdownContextBuildItem shutdownContext,
BuildProducer<RouteBuildItem> routeBuildItemBuildProducer,
NonApplicationRootPathBuildItem nonApplicationRootPathBuildItem,
LaunchModeBuildItem launchModeBuildItem) throws IOException {

if (launchModeBuildItem.getDevModeType().orElse(DevModeType.LOCAL) != DevModeType.LOCAL) {
return;
}
AppArtifact devConsoleResourcesArtifact = WebJarUtil.getAppArtifact(curateOutcomeBuildItem, "io.quarkus",
"quarkus-vertx-http-deployment");

Path devConsoleStaticResourcesDeploymentPath = WebJarUtil.copyResourcesForDevOrTest(curateOutcomeBuildItem, launchMode,
devConsoleResourcesArtifact, STATIC_RESOURCES_PATH);

routeBuildItemBuildProducer.produce(nonApplicationRootPathBuildItem.routeBuilder()
.route("dev/resources/*")
.handler(recorder.devConsoleHandler(devConsoleStaticResourcesDeploymentPath.toString(), shutdownContext))
.build());
}

private Engine buildEngine(List<DevTemplatePathBuildItem> devTemplatePaths,
List<RouteBuildItem> allRoutes,
NonApplicationRootPathBuildItem nonApplicationRootPathBuildItem) {
Expand Down

0 comments on commit 19e87cc

Please sign in to comment.