From 514eb4281c04134f371b7341da315e008e4e5caf Mon Sep 17 00:00:00 2001 From: Juergen Hoeller Date: Wed, 1 Apr 2015 17:23:45 +0200 Subject: [PATCH] Polishing --- .../core/io/support/EncodedResource.java | 16 ++++++++-------- .../http/client/Netty4ClientHttpRequest.java | 1 - .../AbstractHttpRequestFactoryTestCase.java | 15 +++++++++------ .../http/client/AbstractJettyServerTestCase.java | 13 ++++++++++--- 4 files changed, 27 insertions(+), 18 deletions(-) diff --git a/spring-core/src/main/java/org/springframework/core/io/support/EncodedResource.java b/spring-core/src/main/java/org/springframework/core/io/support/EncodedResource.java index edb10b0b9d5..638af8ebe5e 100644 --- a/spring-core/src/main/java/org/springframework/core/io/support/EncodedResource.java +++ b/spring-core/src/main/java/org/springframework/core/io/support/EncodedResource.java @@ -155,17 +155,17 @@ public class EncodedResource implements InputStreamSource { @Override - public boolean equals(Object obj) { - if (obj == this) { + public boolean equals(Object other) { + if (this == other) { return true; } - if (obj instanceof EncodedResource) { - EncodedResource that = (EncodedResource) obj; - return (this.resource.equals(that.resource) && - ObjectUtils.nullSafeEquals(this.charset, that.charset) && - ObjectUtils.nullSafeEquals(this.encoding, that.encoding)); + if (!(other instanceof EncodedResource)) { + return false; } - return false; + EncodedResource otherResource = (EncodedResource) other; + return (this.resource.equals(otherResource.resource) && + ObjectUtils.nullSafeEquals(this.charset, otherResource.charset) && + ObjectUtils.nullSafeEquals(this.encoding, otherResource.encoding)); } @Override diff --git a/spring-web/src/main/java/org/springframework/http/client/Netty4ClientHttpRequest.java b/spring-web/src/main/java/org/springframework/http/client/Netty4ClientHttpRequest.java index 7a4a47e2379..961255a4b72 100644 --- a/spring-web/src/main/java/org/springframework/http/client/Netty4ClientHttpRequest.java +++ b/spring-web/src/main/java/org/springframework/http/client/Netty4ClientHttpRequest.java @@ -41,7 +41,6 @@ import org.springframework.http.HttpMethod; import org.springframework.util.concurrent.ListenableFuture; import org.springframework.util.concurrent.SettableListenableFuture; - /** * {@link org.springframework.http.client.ClientHttpRequest} implementation that uses * Netty 4 to execute requests. diff --git a/spring-web/src/test/java/org/springframework/http/client/AbstractHttpRequestFactoryTestCase.java b/spring-web/src/test/java/org/springframework/http/client/AbstractHttpRequestFactoryTestCase.java index fd1887413cb..c51312dbf9a 100644 --- a/spring-web/src/test/java/org/springframework/http/client/AbstractHttpRequestFactoryTestCase.java +++ b/spring-web/src/test/java/org/springframework/http/client/AbstractHttpRequestFactoryTestCase.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2013 the original author or authors. + * Copyright 2002-2015 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. @@ -23,8 +23,6 @@ import java.util.Arrays; import java.util.Locale; import org.junit.After; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; import org.junit.Before; import org.junit.Test; @@ -36,12 +34,16 @@ import org.springframework.http.StreamingHttpOutputMessage; import org.springframework.util.FileCopyUtils; import org.springframework.util.StreamUtils; -/** @author Arjen Poutsma */ -public abstract class AbstractHttpRequestFactoryTestCase extends - AbstractJettyServerTestCase { +import static org.junit.Assert.*; + +/** + * @author Arjen Poutsma + */ +public abstract class AbstractHttpRequestFactoryTestCase extends AbstractJettyServerTestCase { protected ClientHttpRequestFactory factory; + @Before public final void createFactory() throws Exception { factory = createRequestFactory(); @@ -60,6 +62,7 @@ public abstract class AbstractHttpRequestFactoryTestCase extends protected abstract ClientHttpRequestFactory createRequestFactory(); + @Test public void status() throws Exception { URI uri = new URI(baseUrl + "/status/notfound"); diff --git a/spring-web/src/test/java/org/springframework/http/client/AbstractJettyServerTestCase.java b/spring-web/src/test/java/org/springframework/http/client/AbstractJettyServerTestCase.java index 64e5840405a..1991eb16a03 100644 --- a/spring-web/src/test/java/org/springframework/http/client/AbstractJettyServerTestCase.java +++ b/spring-web/src/test/java/org/springframework/http/client/AbstractJettyServerTestCase.java @@ -38,13 +38,16 @@ import org.junit.BeforeClass; import org.springframework.util.SocketUtils; import org.springframework.util.StreamUtils; -/** @author Arjen Poutsma */ +/** + * @author Arjen Poutsma + */ public abstract class AbstractJettyServerTestCase { protected static String baseUrl; private static Server jettyServer; + @BeforeClass public static void startJettyServer() throws Exception { int port = SocketUtils.findAvailableTcpPort(); @@ -77,6 +80,7 @@ public abstract class AbstractJettyServerTestCase { } } + /** * Servlet that sets a given status code. */ @@ -96,6 +100,7 @@ public abstract class AbstractJettyServerTestCase { } } + @SuppressWarnings("serial") private static class MethodServlet extends GenericServlet { @@ -114,6 +119,7 @@ public abstract class AbstractJettyServerTestCase { } } + @SuppressWarnings("serial") private static class PostServlet extends MethodServlet { @@ -138,6 +144,7 @@ public abstract class AbstractJettyServerTestCase { } } + @SuppressWarnings("serial") private static class EchoServlet extends HttpServlet { @@ -161,12 +168,12 @@ public abstract class AbstractJettyServerTestCase { } } + @SuppressWarnings("serial") private static class ParameterServlet extends HttpServlet { @Override - protected void service(HttpServletRequest req, HttpServletResponse resp) - throws ServletException, IOException { + protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { Map parameters = req.getParameterMap(); assertEquals(2, parameters.size());