Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: check for client route conflicts #20188

Open
wants to merge 23 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -48,13 +48,15 @@
import com.vaadin.flow.internal.DevModeHandler;
import com.vaadin.flow.internal.NetworkUtil;
import com.vaadin.flow.internal.UrlUtil;
import com.vaadin.flow.router.internal.RouteUtil;
import com.vaadin.flow.server.ExecutionFailedException;
import com.vaadin.flow.server.HandlerHelper;
import com.vaadin.flow.server.HttpStatusCode;
import com.vaadin.flow.server.InitParameters;
import com.vaadin.flow.server.StaticFileServer;
import com.vaadin.flow.server.VaadinRequest;
import com.vaadin.flow.server.VaadinResponse;
import com.vaadin.flow.server.VaadinService;
import com.vaadin.flow.server.VaadinSession;
import com.vaadin.flow.server.frontend.FrontendTools;
import com.vaadin.flow.server.frontend.FrontendUtils;
Expand Down Expand Up @@ -614,12 +616,13 @@ public HttpURLConnection prepareConnection(String path, String method)
@Override
public boolean handleRequest(VaadinSession session, VaadinRequest request,
VaadinResponse response) throws IOException {
return handleRequestInternal(request, response, devServerStartFuture,
isDevServerFailedToStart);
return handleRequestInternal(session, request, response,
devServerStartFuture, isDevServerFailedToStart);
}

static boolean handleRequestInternal(VaadinRequest request,
VaadinResponse response, CompletableFuture<?> devServerStartFuture,
static boolean handleRequestInternal(VaadinSession session,
VaadinRequest request, VaadinResponse response,
CompletableFuture<?> devServerStartFuture,
AtomicBoolean isDevServerFailedToStart) throws IOException {
if (devServerStartFuture.isDone()) {
// The server has started, check for any exceptions in the startup
Expand All @@ -637,6 +640,15 @@ static boolean handleRequestInternal(VaadinRequest request,
response.setHeader("Cache-Control", "no-cache");
return true;
}
try {
session.lock();
tepi marked this conversation as resolved.
Show resolved Hide resolved
VaadinService service = session.getService();
RouteUtil.checkForClientRouteCollisions(service, service
.getRouter().getRegistry().getRegisteredRoutes());
} finally {
session.unlock();
}

return false;
} else {
if (request.getHeader("X-DevModePoll") == null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,8 @@ public int getPort() {
@Override
public boolean handleRequest(VaadinSession session, VaadinRequest request,
VaadinResponse response) throws IOException {
return AbstractDevServerRunner.handleRequestInternal(request, response,
buildCompletedFuture, new AtomicBoolean());
return AbstractDevServerRunner.handleRequestInternal(session, request,
response, buildCompletedFuture, new AtomicBoolean());
}

/**
Expand Down
Loading