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: use the latest Spring version #7028

Merged
merged 4 commits into from
Nov 26, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions flow-server/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
<properties>
<validation.api.version>2.0.1.Final</validation.api.version>
<jackson.version>2.9.7</jackson.version>
<spring.version>5.1.2.RELEASE</spring.version>
<spring.autoconfigure.version>2.1.0.RELEASE</spring.autoconfigure.version>
<spring.version>5.2.0.RELEASE</spring.version>
<spring.autoconfigure.version>2.2.0.RELEASE</spring.autoconfigure.version>
<javax.annotation.api.version>1.3.2</javax.annotation.api.version>
<javaparser.version>3.15.1</javaparser.version>
<commons.configuration.version>2.6</commons.configuration.version>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@
package com.vaadin.flow.server.connect;

import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.List;

import org.springframework.boot.autoconfigure.web.servlet.WebMvcRegistrations;
import org.springframework.context.annotation.Bean;
Expand Down Expand Up @@ -63,36 +61,18 @@ public WebMvcRegistrations webMvcRegistrationsHandlerMapping() {
public RequestMappingHandlerMapping getRequestMappingHandlerMapping() {
return new RequestMappingHandlerMapping() {

private List<Method> registered = new ArrayList<>();

@Override
protected void registerHandlerMethod(Object handler,
Method method, RequestMappingInfo mapping) {

// Avoid registering twice, it rarely happens, but
// removing this check causes infinite loops in
// vaadin-spring tests.
if (registered.contains(method)) {
return;
}
registered.add(method);
// If Spring context initialization fails here with a
// stack overflow in a project that also has the
// `vaadin-spring` dependency, make sure that the Spring
// version in `flow-server` and in `vaadin-spring` is
// the same.

if (VaadinConnectController.class
.equals(method.getDeclaringClass())) {
PatternsRequestCondition connectServicePattern = new PatternsRequestCondition(
vaadinConnectProperties
.getVaadinConnectEndpoint())
.combine(mapping
.getPatternsCondition());

mapping = new RequestMappingInfo(mapping.getName(),
connectServicePattern,
mapping.getMethodsCondition(),
mapping.getParamsCondition(),
mapping.getHeadersCondition(),
mapping.getConsumesCondition(),
mapping.getProducesCondition(),
mapping.getCustomCondition());
mapping = prependConnectEndpointUrl(mapping);
}

super.registerHandlerMethod(handler, method, mapping);
Expand All @@ -102,6 +82,27 @@ protected void registerHandlerMethod(Object handler,
};
}

/**
* Prepends the Connect endpoint URL from the Vaadin Connect properties to
* the {@code pattern} of a {@link RequestMappingInfo} object, and returns
* the updated mapping as a new object (not modifying the given
* {@param mapping} parameter).
*
* @return a new mapping with the Connect endpoint URL prepended to the
* mapping pattern
*/
private RequestMappingInfo prependConnectEndpointUrl(
RequestMappingInfo mapping) {
PatternsRequestCondition connectServicePattern = new PatternsRequestCondition(
vaadinConnectProperties.getVaadinConnectEndpoint())
.combine(mapping.getPatternsCondition());

return new RequestMappingInfo(mapping.getName(), connectServicePattern,
mapping.getMethodsCondition(), mapping.getParamsCondition(),
mapping.getHeadersCondition(), mapping.getConsumesCondition(),
mapping.getProducesCondition(), mapping.getCustomCondition());
}

/**
* Registers a service name checker responsible for validating the service
* names.
Expand Down
3 changes: 2 additions & 1 deletion flow-tests/test-ccdm-connect/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@
<packaging>jar</packaging>

<properties>
<spring.version>2.1.6.RELEASE</spring.version>
<!-- this version has to match the Spring version used by `flow-server` -->
<spring.version>2.2.0.RELEASE</spring.version>
<vaadin.spring.version>15.0-SNAPSHOT</vaadin.spring.version>
<server.port>8888</server.port>
<vaadin.clientSideMode>true</vaadin.clientSideMode>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ protected void configure(HttpSecurity http) throws Exception {
* Allows access to static resources, bypassing Spring security.
*/
@Override
public void configure(WebSecurity web) throws Exception {
public void configure(WebSecurity web) {
web.ignoring().antMatchers(
// Vaadin Flow static resources
"/VAADIN/**");
Expand Down