1
0
mirror of synced 2026-08-05 17:57:15 +00:00

Use Integer.valueOf() in preference to new Integer()

This commit is contained in:
Luke Taylor
2010-08-11 18:17:23 +01:00
parent db6da77a5f
commit 2222a7be07
18 changed files with 49 additions and 43 deletions
@@ -40,8 +40,8 @@ public class PortMapperImpl implements PortMapper {
public PortMapperImpl() {
httpsPortMappings = new HashMap<Integer, Integer>();
httpsPortMappings.put(new Integer(80), new Integer(443));
httpsPortMappings.put(new Integer(8080), new Integer(8443));
httpsPortMappings.put(Integer.valueOf(80), Integer.valueOf(443));
httpsPortMappings.put(Integer.valueOf(8080), Integer.valueOf(8443));
}
//~ Methods ========================================================================================================
@@ -92,8 +92,8 @@ public class PortMapperImpl implements PortMapper {
httpsPortMappings.clear();
for (Map.Entry<String,String> entry : newMappings.entrySet()) {
Integer httpPort = new Integer(entry.getKey());
Integer httpsPort = new Integer(entry.getValue());
Integer httpPort = Integer.valueOf(entry.getKey());
Integer httpsPort = Integer.valueOf(entry.getValue());
if ((httpPort.intValue() < 1) || (httpPort.intValue() > 65535) || (httpsPort.intValue() < 1)
|| (httpsPort.intValue() > 65535)) {
@@ -50,10 +50,10 @@ public class PortResolverImpl implements PortResolver {
String scheme = request.getScheme().toLowerCase();
if ("http".equals(scheme)) {
portLookup = portMapper.lookupHttpPort(new Integer(serverPort));
portLookup = portMapper.lookupHttpPort(Integer.valueOf(serverPort));
} else if ("https".equals(scheme)) {
portLookup = portMapper.lookupHttpsPort(new Integer(serverPort));
portLookup = portMapper.lookupHttpsPort(Integer.valueOf(serverPort));
}
if (portLookup != null) {
@@ -167,7 +167,7 @@ public class LoginUrlAuthenticationEntryPoint implements AuthenticationEntryPoin
urlBuilder.setPathInfo(loginForm);
if (forceHttps && "http".equals(scheme)) {
Integer httpsPort = portMapper.lookupHttpsPort(new Integer(serverPort));
Integer httpsPort = portMapper.lookupHttpsPort(Integer.valueOf(serverPort));
if (httpsPort != null) {
// Overwrite scheme and port in the redirect URL
@@ -189,7 +189,7 @@ public class LoginUrlAuthenticationEntryPoint implements AuthenticationEntryPoin
throws IOException, ServletException {
int serverPort = portResolver.getServerPort(request);
Integer httpsPort = portMapper.lookupHttpsPort(new Integer(serverPort));
Integer httpsPort = portMapper.lookupHttpsPort(Integer.valueOf(serverPort));
if (httpsPort != null) {
RedirectUrlBuilder urlBuilder = new RedirectUrlBuilder();
@@ -124,7 +124,7 @@ public class ConcurrentSessionControlStrategy extends SessionFixationProtectionS
SessionRegistry registry) throws SessionAuthenticationException {
if (exceptionIfMaximumExceeded || (sessions == null)) {
throw new SessionAuthenticationException(messages.getMessage("ConcurrentSessionControllerImpl.exceededAllowed",
new Object[] {new Integer(allowableSessions)},
new Object[] {Integer.valueOf(allowableSessions)},
"Maximum sessions of {0} for this principal exceeded"));
}
@@ -36,13 +36,17 @@ import org.springframework.util.Assert;
/**
* Represents central information from a <code>HttpServletRequest</code>.<p>This class is used by {@link
* org.springframework.security.web.authentication.AbstractAuthenticationProcessingFilter} and {@link org.springframework.security.web.savedrequest.SavedRequestAwareWrapper} to
* Represents central information from a <code>HttpServletRequest</code>.
* <p>
* This class is used by {@link org.springframework.security.web.authentication.AbstractAuthenticationProcessingFilter}
* and {@link org.springframework.security.web.savedrequest.SavedRequestAwareWrapper} to
* reproduce the request after successful authentication. An instance of this class is stored at the time of an
* authentication exception by {@link org.springframework.security.web.access.ExceptionTranslationFilter}.</p>
* <p><em>IMPLEMENTATION NOTE</em>: It is assumed that this object is accessed only from the context of a single
* thread, so no synchronization around internal collection classes is performed.</p>
* <p>This class is based on code in Apache Tomcat.</p>
* authentication exception by {@link org.springframework.security.web.access.ExceptionTranslationFilter}.
* <p>
* <em>IMPLEMENTATION NOTE</em>: It is assumed that this object is accessed only from the context of a single
* thread, so no synchronization around internal collection classes is performed.
* <p>
* This class is based on code in Apache Tomcat.
*
* @author Craig McClanahan
* @author Andrey Grebnev
@@ -168,7 +172,10 @@ public class DefaultSavedRequest implements SavedRequest {
* Determines if the current request matches the <code>DefaultSavedRequest</code>.
* <p>
* All URL arguments are considered but not cookies, locales, headers or parameters.
* <p>
*
* @param request the actual request to be matched against this one
* @param portResolver used to obtain the server port of the request
* @return true if the request is deemed to match this one.
*
*/
public boolean doesRequestMatch(HttpServletRequest request, PortResolver portResolver) {
@@ -190,8 +197,7 @@ public class DefaultSavedRequest implements SavedRequest {
return false;
}
if (!propertyEquals("serverPort", new Integer(this.serverPort), new Integer(portResolver.getServerPort(request))))
{
if (!propertyEquals("serverPort", Integer.valueOf(this.serverPort), Integer.valueOf(portResolver.getServerPort(request)))) {
return false;
}
@@ -269,7 +275,7 @@ public class DefaultSavedRequest implements SavedRequest {
}
public String[] getParameterValues(String name) {
return ((String[]) parameters.get(name));
return parameters.get(name);
}
public String getPathInfo() {
@@ -33,10 +33,10 @@ public class PortMapperImplTests extends TestCase {
public void testDefaultMappingsAreKnown() throws Exception {
PortMapperImpl portMapper = new PortMapperImpl();
assertEquals(new Integer(80), portMapper.lookupHttpPort(new Integer(443)));
assertEquals(new Integer(8080), portMapper.lookupHttpPort(new Integer(8443)));
assertEquals(new Integer(443), portMapper.lookupHttpsPort(new Integer(80)));
assertEquals(new Integer(8443), portMapper.lookupHttpsPort(new Integer(8080)));
assertEquals(Integer.valueOf(80), portMapper.lookupHttpPort(Integer.valueOf(443)));
assertEquals(Integer.valueOf(8080), portMapper.lookupHttpPort(Integer.valueOf(8443)));
assertEquals(Integer.valueOf(443), portMapper.lookupHttpsPort(Integer.valueOf(80)));
assertEquals(Integer.valueOf(8443), portMapper.lookupHttpsPort(Integer.valueOf(8080)));
}
public void testDetectsEmptyMap() throws Exception {
@@ -81,7 +81,7 @@ public class PortMapperImplTests extends TestCase {
public void testReturnsNullIfHttpPortCannotBeFound() {
PortMapperImpl portMapper = new PortMapperImpl();
assertTrue(portMapper.lookupHttpPort(new Integer("34343")) == null);
assertTrue(portMapper.lookupHttpPort(Integer.valueOf("34343")) == null);
}
public void testSupportsCustomMappings() {
@@ -91,7 +91,7 @@ public class PortMapperImplTests extends TestCase {
portMapper.setPortMappings(map);
assertEquals(new Integer(79), portMapper.lookupHttpPort(new Integer(442)));
assertEquals(new Integer(442), portMapper.lookupHttpsPort(new Integer(79)));
assertEquals(Integer.valueOf(79), portMapper.lookupHttpPort(Integer.valueOf(442)));
assertEquals(Integer.valueOf(442), portMapper.lookupHttpsPort(Integer.valueOf(79)));
}
}