diff --git a/spring-boot-tools/spring-boot-loader/src/main/java/org/springframework/boot/loader/archive/ExplodedArchive.java b/spring-boot-tools/spring-boot-loader/src/main/java/org/springframework/boot/loader/archive/ExplodedArchive.java index aca81420f7..7230f09de1 100644 --- a/spring-boot-tools/spring-boot-loader/src/main/java/org/springframework/boot/loader/archive/ExplodedArchive.java +++ b/spring-boot-tools/spring-boot-loader/src/main/java/org/springframework/boot/loader/archive/ExplodedArchive.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2013 the original author or authors. + * Copyright 2012-2014 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. @@ -58,10 +58,21 @@ public class ExplodedArchive extends Archive { private boolean recursive = true; + /** + * Create a new {@link ExplodedArchive} instance. + * @param root the root folder + */ public ExplodedArchive(File root) { this(root, true); } + /** + * Create a new {@link ExplodedArchive} instance. + * @param root the root folder + * @param recursive if recursive searching should be used to locate the manifest. + * Defaults to {@code true}, folders with a large tree might want to set this to {code + * false}. + */ public ExplodedArchive(File root, boolean recursive) { if (!root.exists() || !root.isDirectory()) { throw new IllegalArgumentException("Invalid source folder " + root); diff --git a/spring-boot-tools/spring-boot-loader/src/test/java/org/springframework/boot/loader/archive/ExplodedArchiveTests.java b/spring-boot-tools/spring-boot-loader/src/test/java/org/springframework/boot/loader/archive/ExplodedArchiveTests.java index 96ef50472b..f086f1878e 100644 --- a/spring-boot-tools/spring-boot-loader/src/test/java/org/springframework/boot/loader/archive/ExplodedArchiveTests.java +++ b/spring-boot-tools/spring-boot-loader/src/test/java/org/springframework/boot/loader/archive/ExplodedArchiveTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2013 the original author or authors. + * Copyright 2012-2014 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. @@ -38,13 +38,16 @@ import org.springframework.boot.loader.archive.Archive.Entry; import org.springframework.boot.loader.util.AsciiBytes; import static org.hamcrest.Matchers.equalTo; +import static org.hamcrest.Matchers.greaterThan; import static org.hamcrest.Matchers.nullValue; +import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertThat; /** * Tests for {@link ExplodedArchive}. * * @author Phillip Webb + * @author Dave Syer */ public class ExplodedArchiveTests { @@ -145,6 +148,30 @@ public class ExplodedArchiveTests { assertThat(classLoader.getResourceAsStream("2.dat"), nullValue()); } + @Test + public void getNonRecursiveEntriesForRoot() throws Exception { + ExplodedArchive archive = new ExplodedArchive(new File("/"), false); + Map entries = getEntriesMap(archive); + assertThat(entries.size(), greaterThan(1)); + } + + @Test + public void getNonRecursiveManifest() throws Exception { + ExplodedArchive archive = new ExplodedArchive(new File("src/test/resources/root")); + assertNotNull(archive.getManifest()); + Map entries = getEntriesMap(archive); + assertThat(entries.size(), equalTo(4)); + } + + @Test + public void getNonRecursiveManifestEvenIfNonRecursive() throws Exception { + ExplodedArchive archive = new ExplodedArchive( + new File("src/test/resources/root"), false); + assertNotNull(archive.getManifest()); + Map entries = getEntriesMap(archive); + assertThat(entries.size(), equalTo(3)); + } + private Map getEntriesMap(Archive archive) { Map entries = new HashMap(); for (Archive.Entry entry : archive.getEntries()) { diff --git a/spring-boot-tools/spring-boot-loader/src/test/java/org/springframework/boot/loader/archive/SpecialArchiveTests.java b/spring-boot-tools/spring-boot-loader/src/test/java/org/springframework/boot/loader/archive/SpecialArchiveTests.java deleted file mode 100644 index 60cb756201..0000000000 --- a/spring-boot-tools/spring-boot-loader/src/test/java/org/springframework/boot/loader/archive/SpecialArchiveTests.java +++ /dev/null @@ -1,66 +0,0 @@ -/* - * Copyright 2012-2013 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. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springframework.boot.loader.archive; - -import java.io.File; -import java.util.HashMap; -import java.util.Map; - -import org.junit.Test; - -import static org.hamcrest.Matchers.equalTo; -import static org.hamcrest.Matchers.greaterThan; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertThat; - -/** - * @author Dave Syer - */ -public class SpecialArchiveTests { - - @Test - public void getEntriesForRoot() throws Exception { - ExplodedArchive archive = new ExplodedArchive(new File("/"), false); - Map entries = getEntriesMap(archive); - assertThat(entries.size(), greaterThan(1)); - } - - @Test - public void getManifest() throws Exception { - ExplodedArchive archive = new ExplodedArchive(new File("src/test/resources/root")); - assertNotNull(archive.getManifest()); - Map entries = getEntriesMap(archive); - assertThat(entries.size(), equalTo(4)); - } - - @Test - public void getManifestEvenIfNonRecursive() throws Exception { - ExplodedArchive archive = new ExplodedArchive( - new File("src/test/resources/root"), false); - assertNotNull(archive.getManifest()); - Map entries = getEntriesMap(archive); - assertThat(entries.size(), equalTo(3)); - } - - private Map getEntriesMap(Archive archive) { - Map entries = new HashMap(); - for (Archive.Entry entry : archive.getEntries()) { - entries.put(entry.getName().toString(), entry); - } - return entries; - } -} diff --git a/spring-boot-tools/spring-boot-loader/src/test/resources/root/META-INF/spring/application.xml b/spring-boot-tools/spring-boot-loader/src/test/resources/root/META-INF/spring/application.xml index daac473bbf..704859f049 100644 --- a/spring-boot-tools/spring-boot-loader/src/test/resources/root/META-INF/spring/application.xml +++ b/spring-boot-tools/spring-boot-loader/src/test/resources/root/META-INF/spring/application.xml @@ -3,5 +3,4 @@ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd"> - diff --git a/spring-boot/src/main/java/org/springframework/boot/SpringApplication.java b/spring-boot/src/main/java/org/springframework/boot/SpringApplication.java index 415b199174..2e295c3388 100644 --- a/spring-boot/src/main/java/org/springframework/boot/SpringApplication.java +++ b/spring-boot/src/main/java/org/springframework/boot/SpringApplication.java @@ -285,7 +285,7 @@ public class SpringApplication { try { context.registerShutdownHook(); } - catch (AccessControlException e) { + catch (AccessControlException ex) { // Not allowed in some environments. } } diff --git a/spring-boot/src/main/java/org/springframework/boot/StartupInfoLogger.java b/spring-boot/src/main/java/org/springframework/boot/StartupInfoLogger.java index 68b8f011d1..3a1f0ed146 100644 --- a/spring-boot/src/main/java/org/springframework/boot/StartupInfoLogger.java +++ b/spring-boot/src/main/java/org/springframework/boot/StartupInfoLogger.java @@ -88,14 +88,13 @@ class StartupInfoLogger { message.append(getApplicationName()); message.append(" in "); message.append(stopWatch.getTotalTimeSeconds()); - message.append(" seconds (JVM running for "); try { - message.append(ManagementFactory.getRuntimeMXBean().getUptime() / 1000.0); + double uptime = ManagementFactory.getRuntimeMXBean().getUptime() / 1000.0; + message.append(" seconds (JVM running for " + uptime + ")"); } - catch (Throwable e) { - message.append("?"); + catch (Throwable ex) { + // No JVM time available } - message.append(")"); return message; } diff --git a/spring-boot/src/main/java/org/springframework/boot/logging/LoggingApplicationListener.java b/spring-boot/src/main/java/org/springframework/boot/logging/LoggingApplicationListener.java index 7859457064..2ad90a87ba 100644 --- a/spring-boot/src/main/java/org/springframework/boot/logging/LoggingApplicationListener.java +++ b/spring-boot/src/main/java/org/springframework/boot/logging/LoggingApplicationListener.java @@ -197,7 +197,8 @@ public class LoggingApplicationListener implements SmartApplicationListener { return name.split("@")[0]; } } - catch (Throwable e) { + catch (Throwable ex) { + // Ignore } return "????"; } diff --git a/spring-boot/src/main/java/org/springframework/boot/logging/logback/LogbackLoggingSystem.java b/spring-boot/src/main/java/org/springframework/boot/logging/logback/LogbackLoggingSystem.java index 7e2d29ba52..3808ab226e 100644 --- a/spring-boot/src/main/java/org/springframework/boot/logging/logback/LogbackLoggingSystem.java +++ b/spring-boot/src/main/java/org/springframework/boot/logging/logback/LogbackLoggingSystem.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2013 the original author or authors. + * Copyright 2012-2014 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. @@ -79,7 +79,7 @@ public class LogbackLoggingSystem extends AbstractLoggingSystem { SLF4JBridgeHandler.install(); } } - catch (Throwable e) { + catch (Throwable ex) { // Ignore. No java.util.logging bridge is installed. } }