Skip to content

Commit

Permalink
Information and doclink on routes not found error about known Spring …
Browse files Browse the repository at this point in the history
…Boot Devtools issue (#655)

Spring Boot Devtools issue (spring-projects/spring-boot#19543)
  • Loading branch information
Johannes Eriksson authored Aug 26, 2020
1 parent 64b8d83 commit 7b684a4
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@
import com.vaadin.flow.server.startup.WebComponentExporterAwareValidator;
import com.vaadin.flow.server.webcomponent.WebComponentConfigurationRegistry;
import com.vaadin.flow.spring.VaadinScanPackagesRegistrar.VaadinScanPackages;
import com.vaadin.flow.spring.router.SpringRouteNotFoundError;
import com.vaadin.flow.theme.Theme;

/**
Expand Down Expand Up @@ -630,11 +631,10 @@ private Collection<String> getWebComponentPackages() {
}

private Collection<String> getErrorParameterPackages() {
return Stream
.concat(Stream
.of(HasErrorParameter.class.getPackage().getName()),
getDefaultPackages().stream())
.collect(Collectors.toSet());
return Stream.concat(
Stream.of(HasErrorParameter.class.getPackage().getName(),
SpringRouteNotFoundError.class.getPackage().getName()),
getDefaultPackages().stream()).collect(Collectors.toSet());
}

private List<String> getDefaultPackages() {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package com.vaadin.flow.spring.router;

import com.vaadin.flow.component.Html;
import com.vaadin.flow.router.BeforeEnterEvent;
import com.vaadin.flow.router.ErrorParameter;
import com.vaadin.flow.router.NotFoundException;
import com.vaadin.flow.router.RouteNotFoundError;

public class SpringRouteNotFoundError extends RouteNotFoundError {
@Override
public int setErrorParameter(BeforeEnterEvent event,
ErrorParameter<NotFoundException> parameter) {
int retval = super.setErrorParameter(event, parameter);

// Alert user about potential issue with Spring Boot Devtools losing
// routes https://github.com/spring-projects/spring-boot/issues/19543
String customMessage = "<span>When using Spring Boot Devtools with "
+ "automatic reload, please note that routes can sometimes be "
+ "lost due to a <a href ='https://github.com/spring-projects/spring-boot/issues/19543'>"
+ "compilation race condition</a>. See "
+ "<a href='https://vaadin.com/docs/flow/workflow/setup-live-reload-springboot.html'>"
+ "the documentation</a> for further workarounds and other "
+ "live reload alternatives.";
getElement().appendChild(new Html(customMessage).getElement());

return retval;
}
}

0 comments on commit 7b684a4

Please sign in to comment.