From c71aa32fbb1b11317049bf01fa63d4e9c23db1dd Mon Sep 17 00:00:00 2001 From: Phillip Webb Date: Thu, 21 Jan 2016 10:53:25 -0800 Subject: [PATCH] Polish --- .../flyway/FlywayAutoConfiguration.java | 2 +- .../autoconfigure/flyway/FlywayProperties.java | 2 +- .../websocket/WebSocketAutoConfiguration.java | 2 +- .../flyway/FlywayAutoConfigurationTests.java | 2 +- .../boot/loader/PropertiesLauncher.java | 14 ++++---------- .../TomcatEmbeddedServletContainerFactory.java | 18 +++++++++--------- 6 files changed, 17 insertions(+), 23 deletions(-) diff --git a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/flyway/FlywayAutoConfiguration.java b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/flyway/FlywayAutoConfiguration.java index 6c78c3d8412..59b204e1715 100644 --- a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/flyway/FlywayAutoConfiguration.java +++ b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/flyway/FlywayAutoConfiguration.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2014 the original author or authors. + * Copyright 2012-2016 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. diff --git a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/flyway/FlywayProperties.java b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/flyway/FlywayProperties.java index b80d4327b73..537ce836a80 100644 --- a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/flyway/FlywayProperties.java +++ b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/flyway/FlywayProperties.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2014 the original author or authors. + * Copyright 2012-2016 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. diff --git a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/websocket/WebSocketAutoConfiguration.java b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/websocket/WebSocketAutoConfiguration.java index d4f5f84968b..64ec20c3763 100644 --- a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/websocket/WebSocketAutoConfiguration.java +++ b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/websocket/WebSocketAutoConfiguration.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2015 the original author or authors. + * Copyright 2012-2016 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. diff --git a/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/flyway/FlywayAutoConfigurationTests.java b/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/flyway/FlywayAutoConfigurationTests.java index 0a5f137a6cb..eadea538e39 100644 --- a/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/flyway/FlywayAutoConfigurationTests.java +++ b/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/flyway/FlywayAutoConfigurationTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2014 the original author or authors. + * Copyright 2012-2016 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. diff --git a/spring-boot-tools/spring-boot-loader/src/main/java/org/springframework/boot/loader/PropertiesLauncher.java b/spring-boot-tools/spring-boot-loader/src/main/java/org/springframework/boot/loader/PropertiesLauncher.java index 248a058000d..78ed02785f8 100644 --- a/spring-boot-tools/spring-boot-loader/src/main/java/org/springframework/boot/loader/PropertiesLauncher.java +++ b/spring-boot-tools/spring-boot-loader/src/main/java/org/springframework/boot/loader/PropertiesLauncher.java @@ -549,19 +549,13 @@ public class PropertiesLauncher extends Launcher { if (url.toString().endsWith(".jar") || url.toString().endsWith(".zip")) { return new JarFileArchive(new File(url.toURI())); } - else if (url.toString().endsWith("/*")) { + if (url.toString().endsWith("/*")) { String name = url.getFile(); File dir = new File(name.substring(0, name.length() - 1)); - if (dir.exists()) { - return new ExplodedArchive(new File(name.substring(0, name.length() - 1)), - false); - } + return (dir.exists() ? new ExplodedArchive(dir, false) : null); } - else { - String filename = URLDecoder.decode(url.getFile(), "UTF-8"); - return new ExplodedArchive(new File(filename)); - } - return null; + String filename = URLDecoder.decode(url.getFile(), "UTF-8"); + return new ExplodedArchive(new File(filename)); } private void addNestedArchivesFromParent(List urls) { diff --git a/spring-boot/src/main/java/org/springframework/boot/context/embedded/tomcat/TomcatEmbeddedServletContainerFactory.java b/spring-boot/src/main/java/org/springframework/boot/context/embedded/tomcat/TomcatEmbeddedServletContainerFactory.java index c9e1f13e6d6..2a7fef04b73 100644 --- a/spring-boot/src/main/java/org/springframework/boot/context/embedded/tomcat/TomcatEmbeddedServletContainerFactory.java +++ b/spring-boot/src/main/java/org/springframework/boot/context/embedded/tomcat/TomcatEmbeddedServletContainerFactory.java @@ -600,9 +600,9 @@ public class TomcatEmbeddedServletContainerFactory private static class TomcatErrorPage { - private static final String ERROR_PAGE_TOMCAT7 = "org.apache.catalina.deploy.ErrorPage"; + private static final String ERROR_PAGE_CLASS = "org.apache.tomcat.util.descriptor.web.ErrorPage"; - private static final String ERROR_PAGE_TOMCAT = "org.apache.tomcat.util.descriptor.web.ErrorPage"; + private static final String LEGACY_ERROR_PAGE_CLASS = "org.apache.catalina.deploy.ErrorPage"; private final String location; @@ -622,13 +622,13 @@ public class TomcatEmbeddedServletContainerFactory private Object createNativePage(ErrorPage errorPage) { Object nativePage = null; try { - if (ClassUtils.isPresent(ERROR_PAGE_TOMCAT, null)) { - nativePage = BeanUtils.instantiate(ClassUtils - .forName(ERROR_PAGE_TOMCAT, null)); + if (ClassUtils.isPresent(ERROR_PAGE_CLASS, null)) { + nativePage = BeanUtils + .instantiate(ClassUtils.forName(ERROR_PAGE_CLASS, null)); } - else if (ClassUtils.isPresent(ERROR_PAGE_TOMCAT7, null)) { - nativePage = BeanUtils.instantiate(ClassUtils - .forName(ERROR_PAGE_TOMCAT7, null)); + else if (ClassUtils.isPresent(LEGACY_ERROR_PAGE_CLASS, null)) { + nativePage = BeanUtils.instantiate( + ClassUtils.forName(LEGACY_ERROR_PAGE_CLASS, null)); } } catch (ClassNotFoundException ex) { @@ -643,7 +643,7 @@ public class TomcatEmbeddedServletContainerFactory public void addToContext(Context context) { Assert.state(this.nativePage != null, "Neither Tomcat 7 nor 8 detected so no native error page exists"); - if (ClassUtils.isPresent(ERROR_PAGE_TOMCAT, null)) { + if (ClassUtils.isPresent(ERROR_PAGE_CLASS, null)) { org.apache.tomcat.util.descriptor.web.ErrorPage errorPage = (org.apache.tomcat.util.descriptor.web.ErrorPage) this.nativePage; errorPage.setLocation(this.location); errorPage.setErrorCode(this.errorCode);