diff --git a/src/main/java/org/springframework/hateoas/mvc/ControllerLinkBuilder.java b/src/main/java/org/springframework/hateoas/mvc/ControllerLinkBuilder.java index c02c3aca..f5269ea7 100755 --- a/src/main/java/org/springframework/hateoas/mvc/ControllerLinkBuilder.java +++ b/src/main/java/org/springframework/hateoas/mvc/ControllerLinkBuilder.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2017 the original author or authors. + * Copyright 2012-2018 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -15,7 +15,7 @@ */ package org.springframework.hateoas.mvc; -import static org.springframework.hateoas.mvc.ForwardedHeader.handleXForwardedSslHeader; +import static org.springframework.hateoas.mvc.ForwardedHeader.*; import lombok.RequiredArgsConstructor; import lombok.experimental.Delegate; @@ -330,7 +330,7 @@ public class ControllerLinkBuilder extends LinkBuilderSupport type, Method method) { String mapping = delegate.getMapping(type, method); - + return templates.computeIfAbsent(mapping, UriTemplate::new); } } diff --git a/src/main/java/org/springframework/hateoas/mvc/ForwardedHeader.java b/src/main/java/org/springframework/hateoas/mvc/ForwardedHeader.java index f1f3b957..3c1aa228 100644 --- a/src/main/java/org/springframework/hateoas/mvc/ForwardedHeader.java +++ b/src/main/java/org/springframework/hateoas/mvc/ForwardedHeader.java @@ -1,5 +1,5 @@ /* - * Copyright 2017 the original author or authors. + * Copyright 2017-2018 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -46,8 +46,8 @@ class ForwardedHeader { } /** - * Utility method to pull handling of {@literal X-Forwarded-Ssl} into a class that will be removed when - * rebaselined against Spring 5.1 + * Utility method to pull handling of {@literal X-Forwarded-Ssl} into a class that will be removed when rebaselined + * against Spring 5.1 * * @param request * @param builder @@ -55,7 +55,8 @@ class ForwardedHeader { * @deprecated No longer needed with Spring 5.1 */ @Deprecated - public static UriComponentsBuilder handleXForwardedSslHeader(HttpServletRequest request, UriComponentsBuilder builder) { + public static UriComponentsBuilder handleXForwardedSslHeader(HttpServletRequest request, + UriComponentsBuilder builder) { // special case handling for X-Forwarded-Ssl: // apply it, but only if X-Forwarded-Proto is unset. diff --git a/src/test/java/org/springframework/hateoas/TestUtils.java b/src/test/java/org/springframework/hateoas/TestUtils.java index c7a21c13..4008fa75 100644 --- a/src/test/java/org/springframework/hateoas/TestUtils.java +++ b/src/test/java/org/springframework/hateoas/TestUtils.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2013 the original author or authors. + * Copyright 2012-2018 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -34,6 +34,7 @@ import org.springframework.web.filter.ForwardedHeaderFilter; * Utility class to ease testing. * * @author Oliver Gierke + * @author Greg Turnquist */ public class TestUtils { @@ -52,13 +53,13 @@ public class TestUtils { } /** - * Provide a mechanism to simulate inserting a {@link ForwardedHeaderFilter} into the servlet - * filter chain, so {@literal Forwarded} headers are properly inserted into the test web request. + * Provide a mechanism to simulate inserting a {@link ForwardedHeaderFilter} into the servlet filter chain, so + * {@literal Forwarded} headers are properly inserted into the test web request. * * @see https://jira.spring.io/browse/SPR-16668 */ protected void adaptRequestFromForwardedHeaders() { - + MockFilterChain chain = new MockFilterChain(); try { new ForwardedHeaderFilter().doFilter(this.request, new MockHttpServletResponse(), chain); diff --git a/src/test/java/org/springframework/hateoas/mvc/ControllerLinkBuilderUnitTest.java b/src/test/java/org/springframework/hateoas/mvc/ControllerLinkBuilderUnitTest.java index fcf75f15..da287a11 100755 --- a/src/test/java/org/springframework/hateoas/mvc/ControllerLinkBuilderUnitTest.java +++ b/src/test/java/org/springframework/hateoas/mvc/ControllerLinkBuilderUnitTest.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2017 the original author or authors. + * Copyright 2012-2018 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -435,7 +435,7 @@ public class ControllerLinkBuilderUnitTest extends TestUtils { setUp(); request.addHeader("X-Forwarded-Proto", proto); - + adaptRequestFromForwardedHeaders(); Link link = linkTo(PersonControllerImpl.class).withSelfRel(); @@ -469,7 +469,7 @@ public class ControllerLinkBuilderUnitTest extends TestUtils { request.addHeader("X-Forwarded-Proto", "foo"); request.addHeader("Forwarded", "proto=bar"); - + adaptRequestFromForwardedHeaders(); Link link = linkTo(PersonControllerImpl.class).withSelfRel(); @@ -588,8 +588,7 @@ public class ControllerLinkBuilderUnitTest extends TestUtils { @Test public void considersEmptyOptionalMethodParameterOptional() { - Link link = linkTo(methodOn(ControllerWithMethods.class).methodWithJdk8Optional(Optional.empty())) - .withSelfRel(); + Link link = linkTo(methodOn(ControllerWithMethods.class).methodWithJdk8Optional(Optional.empty())).withSelfRel(); assertThat(link.isTemplated()).isTrue(); assertThat(link.getVariableNames(), contains("value"));