Skip to content

Commit eff893f

Browse files
committed
#758 - Polishing.
Original pull request: #717.
1 parent bb4a4a6 commit eff893f

File tree

4 files changed

+18
-17
lines changed

4 files changed

+18
-17
lines changed

src/main/java/org/springframework/hateoas/mvc/ControllerLinkBuilder.java

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2017 the original author or authors.
2+
* Copyright 2012-2018 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -15,7 +15,7 @@
1515
*/
1616
package org.springframework.hateoas.mvc;
1717

18-
import static org.springframework.hateoas.mvc.ForwardedHeader.handleXForwardedSslHeader;
18+
import static org.springframework.hateoas.mvc.ForwardedHeader.*;
1919

2020
import lombok.RequiredArgsConstructor;
2121
import lombok.experimental.Delegate;
@@ -330,7 +330,7 @@ public static UriComponentsBuilder getBuilder() {
330330
* @return
331331
*/
332332
private static boolean isSpringAtLeast5_1() {
333-
333+
334334
String versionOfSpringFramework = ApplicationContext.class.getPackage().getImplementationVersion();
335335

336336
String[] parts = versionOfSpringFramework.split("\\.");
@@ -377,7 +377,7 @@ private static class CachingAnnotationMappingDiscoverer implements MappingDiscov
377377
public UriTemplate getMappingAsUriTemplate(Class<?> type, Method method) {
378378

379379
String mapping = delegate.getMapping(type, method);
380-
380+
381381
return templates.computeIfAbsent(mapping, UriTemplate::new);
382382
}
383383
}

src/main/java/org/springframework/hateoas/mvc/ForwardedHeader.java

+5-4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2017 the original author or authors.
2+
* Copyright 2017-2018 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -46,16 +46,17 @@ private ForwardedHeader(Map<String, String> elements) {
4646
}
4747

4848
/**
49-
* Utility method to pull handling of {@literal X-Forwarded-Ssl} into a class that will be removed when
50-
* rebaselined against Spring 5.1
49+
* Utility method to pull handling of {@literal X-Forwarded-Ssl} into a class that will be removed when rebaselined
50+
* against Spring 5.1
5151
*
5252
* @param request
5353
* @param builder
5454
* @return
5555
* @deprecated No longer needed with Spring 5.1
5656
*/
5757
@Deprecated
58-
public static UriComponentsBuilder handleXForwardedSslHeader(HttpServletRequest request, UriComponentsBuilder builder) {
58+
public static UriComponentsBuilder handleXForwardedSslHeader(HttpServletRequest request,
59+
UriComponentsBuilder builder) {
5960

6061
// special case handling for X-Forwarded-Ssl:
6162
// apply it, but only if X-Forwarded-Proto is unset.

src/test/java/org/springframework/hateoas/TestUtils.java

+5-4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2013 the original author or authors.
2+
* Copyright 2012-2018 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -34,6 +34,7 @@
3434
* Utility class to ease testing.
3535
*
3636
* @author Oliver Gierke
37+
* @author Greg Turnquist
3738
*/
3839
public class TestUtils {
3940

@@ -52,13 +53,13 @@ protected void assertPointsToMockServer(Link link) {
5253
}
5354

5455
/**
55-
* Provide a mechanism to simulate inserting a {@link ForwardedHeaderFilter} into the servlet
56-
* filter chain, so {@literal Forwarded} headers are properly inserted into the test web request.
56+
* Provide a mechanism to simulate inserting a {@link ForwardedHeaderFilter} into the servlet filter chain, so
57+
* {@literal Forwarded} headers are properly inserted into the test web request.
5758
*
5859
* @see https://jira.spring.io/browse/SPR-16668
5960
*/
6061
protected void adaptRequestFromForwardedHeaders() {
61-
62+
6263
MockFilterChain chain = new MockFilterChain();
6364
try {
6465
new ForwardedHeaderFilter().doFilter(this.request, new MockHttpServletResponse(), chain);

src/test/java/org/springframework/hateoas/mvc/ControllerLinkBuilderUnitTest.java

+4-5
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2017 the original author or authors.
2+
* Copyright 2012-2018 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -435,7 +435,7 @@ public void usesXForwardedProtoHeaderAsLinkSchema() throws ServletException, IOE
435435

436436
setUp();
437437
request.addHeader("X-Forwarded-Proto", proto);
438-
438+
439439
adaptRequestFromForwardedHeaders();
440440

441441
Link link = linkTo(PersonControllerImpl.class).withSelfRel();
@@ -469,7 +469,7 @@ public void favorsStandardForwardHeaderOverXForwardedProto() {
469469

470470
request.addHeader("X-Forwarded-Proto", "foo");
471471
request.addHeader("Forwarded", "proto=bar");
472-
472+
473473
adaptRequestFromForwardedHeaders();
474474

475475
Link link = linkTo(PersonControllerImpl.class).withSelfRel();
@@ -588,8 +588,7 @@ public void createsLinkRelativeToContextRoot() {
588588
@Test
589589
public void considersEmptyOptionalMethodParameterOptional() {
590590

591-
Link link = linkTo(methodOn(ControllerWithMethods.class).methodWithJdk8Optional(Optional.empty()))
592-
.withSelfRel();
591+
Link link = linkTo(methodOn(ControllerWithMethods.class).methodWithJdk8Optional(Optional.empty())).withSelfRel();
593592

594593
assertThat(link.isTemplated()).isTrue();
595594
assertThat(link.getVariableNames(), contains("value"));

0 commit comments

Comments
 (0)