This commit is contained in:
Phillip Webb
2015-09-05 10:38:30 -07:00
parent 67402405db
commit 6e29ee4557
125 changed files with 638 additions and 506 deletions

View File

@@ -32,7 +32,7 @@ import org.json.JSONException;
* @author Stephane Nicoll
* @since 1.3.0
*/
public class ConfigurationMetadataRepositoryJsonBuilder {
public final class ConfigurationMetadataRepositoryJsonBuilder {
public static final Charset UTF_8 = Charset.forName("UTF-8");

View File

@@ -27,7 +27,7 @@ import javax.lang.model.element.Element;
* @author Phillip Webb
* @since 1.2.0
*/
class Trees extends ReflectionWrapper {
final class Trees extends ReflectionWrapper {
private Trees(Object instance) {
super(instance);

View File

@@ -68,7 +68,6 @@ import static org.junit.Assert.assertTrue;
import static org.springframework.boot.configurationprocessor.ConfigurationMetadataMatchers.containsGroup;
import static org.springframework.boot.configurationprocessor.ConfigurationMetadataMatchers.containsHint;
import static org.springframework.boot.configurationprocessor.ConfigurationMetadataMatchers.containsProperty;
import static org.springframework.boot.configurationprocessor.MetadataStore.METADATA_PATH;
/**
* Tests for {@link ConfigurationMetadataAnnotationProcessor}.
@@ -491,10 +490,10 @@ public class ConfigurationMetadataAnnotationProcessorTests {
public void incrementalBuild() throws Exception {
TestProject project = new TestProject(this.temporaryFolder, FooProperties.class,
BarProperties.class);
assertFalse(project.getOutputFile(METADATA_PATH).exists());
assertFalse(project.getOutputFile(MetadataStore.METADATA_PATH).exists());
ConfigurationMetadata metadata = project.fullBuild();
assertTrue(project.getOutputFile(METADATA_PATH).exists());
assertTrue(project.getOutputFile(MetadataStore.METADATA_PATH).exists());
assertThat(metadata,
containsProperty("foo.counter").fromSource(FooProperties.class));

View File

@@ -37,7 +37,10 @@ import org.springframework.boot.configurationprocessor.metadata.ItemMetadata.Ite
* @author Phillip Webb
* @author Stephane Nicoll
*/
public class ConfigurationMetadataMatchers {
public final class ConfigurationMetadataMatchers {
private ConfigurationMetadataMatchers() {
}
public static ContainsItemMatcher containsGroup(String name) {
return new ContainsItemMatcher(ItemType.GROUP, name);

View File

@@ -19,7 +19,7 @@ package org.springframework.boot.configurationprocessor.metadata;
import org.junit.Test;
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.junit.Assert.assertThat;
/**
* Tests for {@link ConfigurationMetadata}.

View File

@@ -24,7 +24,6 @@ import org.springframework.boot.gradle.dependencymanagement.DependencyManagement
import org.springframework.boot.gradle.repackage.RepackagePluginFeatures
import org.springframework.boot.gradle.run.RunPluginFeatures
/**
* Gradle 'Spring Boot' {@link Plugin}.
*

View File

@@ -18,10 +18,10 @@ package org.springframework.boot.gradle
import java.io.File;
import java.util.Map;
import java.util.Set;
import org.springframework.boot.loader.tools.Layout
import org.springframework.boot.loader.tools.Layouts
import org.springframework.boot.loader.tools.Layout;
import org.springframework.boot.loader.tools.Layouts;
/**
* Gradle DSL Extension for 'Spring Boot'. Most of the time Spring Boot can guess the

View File

@@ -16,12 +16,12 @@
package org.springframework.boot.gradle.dependencymanagement;
import org.gradle.api.Project;
import org.springframework.boot.gradle.PluginFeatures;
import io.spring.gradle.dependencymanagement.DependencyManagementExtension
import io.spring.gradle.dependencymanagement.DependencyManagementPlugin
import org.gradle.api.Project
import org.springframework.boot.gradle.PluginFeatures
/**
* {@link PluginFeatures} to configure dependency management
*

View File

@@ -28,7 +28,10 @@ import org.gradle.api.tasks.SourceSet;
* @author Dave Syer
* @author Phillip Webb
*/
class SourceSets {
final class SourceSets {
private SourceSets() {
}
public static SourceSet findMainSourceSet(Project project) {
for (SourceSet sourceSet : getJavaSourceSets(project)) {

View File

@@ -31,7 +31,10 @@ import java.util.Set;
* @author Dave Syer
* @author Andy Wilkinson
*/
public class Layouts {
public final class Layouts {
private Layouts() {
}
/**
* Return the a layout for the given source file.

View File

@@ -25,6 +25,9 @@ package org.springframework.boot.loader.tools;
*/
public interface LibraryScope {
@Override
String toString();
/**
* The library is used at compile time and runtime.
*/

View File

@@ -147,6 +147,7 @@ public class RunProcess {
reader.close();
}
catch (Exception ex) {
// Ignore
}
}

View File

@@ -26,10 +26,13 @@ import sun.misc.SignalHandler;
* @since 1.1.0
*/
@SuppressWarnings("restriction")
public class SignalUtils {
public final class SignalUtils {
private static final Signal SIG_INT = new Signal("INT");
private SignalUtils() {
}
/**
* Handle {@literal INT} signals by calling the specified {@link Runnable}
* @param runnable the runnable to call on SIGINT.

View File

@@ -23,7 +23,12 @@ package org.springframework.boot.loader.tools.sample;
*/
public class ClassWithMainMethod {
public void run() {
System.out.println("Hello World");
}
public static void main(String[] args) {
new ClassWithMainMethod().run();
}
}

View File

@@ -138,6 +138,7 @@ public class LaunchedURLClassLoader extends URLClassLoader {
}
}
catch (Exception ex) {
// Ignore and continue
}
// 2) Try to find locally
@@ -147,6 +148,7 @@ public class LaunchedURLClassLoader extends URLClassLoader {
return cls;
}
catch (Exception ex) {
// Ignore and continue
}
// 3) Use standard loading

View File

@@ -27,10 +27,13 @@ import org.springframework.boot.loader.data.RandomAccessData.ResourceAccess;
*
* @author Phillip Webb
*/
class Bytes {
final class Bytes {
private static final byte[] EMPTY_BYTES = new byte[] {};
private Bytes() {
}
public static byte[] get(RandomAccessData data) throws IOException {
InputStream inputStream = data.getInputStream(ResourceAccess.ONCE);
try {

View File

@@ -55,6 +55,7 @@ public class Handler extends URLStreamHandler {
.getDeclaredMethod("openConnection", URL.class);
}
catch (Exception ex) {
// Swallow and ignore
}
OPEN_CONNECTION_METHOD = method;
}

View File

@@ -34,16 +34,16 @@ public class ByteArrayStartsWith extends TypeSafeMatcher<byte[]> {
@Override
public void describeTo(Description description) {
description.appendText("a byte array starting with ").appendValue(bytes);
description.appendText("a byte array starting with ").appendValue(this.bytes);
}
@Override
protected boolean matchesSafely(byte[] item) {
if (item.length < bytes.length) {
if (item.length < this.bytes.length) {
return false;
}
for (int i = 0; i < bytes.length; i++) {
if (item[i] != bytes[i]) {
for (int i = 0; i < this.bytes.length; i++) {
if (item[i] != this.bytes[i]) {
return false;
}
}

View File

@@ -90,6 +90,17 @@ public class ExecutableArchiveLauncherTests {
assertArrayEquals(urls, ((URLClassLoader) classLoader).getURLs());
}
private void doWithTccl(ClassLoader classLoader, Callable<?> action) throws Exception {
ClassLoader old = Thread.currentThread().getContextClassLoader();
try {
Thread.currentThread().setContextClassLoader(classLoader);
action.call();
}
finally {
Thread.currentThread().setContextClassLoader(old);
}
}
private static final class UnitTestExecutableArchiveLauncher extends
ExecutableArchiveLauncher {
@@ -103,15 +114,4 @@ public class ExecutableArchiveLauncherTests {
}
}
private void doWithTccl(ClassLoader classLoader, Callable<?> action) throws Exception {
ClassLoader old = Thread.currentThread().getContextClassLoader();
try {
Thread.currentThread().setContextClassLoader(classLoader);
action.call();
}
finally {
Thread.currentThread().setContextClassLoader(old);
}
}
}

View File

@@ -57,8 +57,8 @@ public class JarFileArchiveTests {
private void setup(boolean unpackNested) throws Exception {
this.rootJarFile = this.temporaryFolder.newFile();
this.rootJarFileUrl = rootJarFile.toURI().toString();
System.out.println(rootJarFileUrl);
this.rootJarFileUrl = this.rootJarFile.toURI().toString();
System.out.println(this.rootJarFileUrl);
TestJarCreator.createTestJar(this.rootJarFile, unpackNested);
this.archive = new JarFileArchive(this.rootJarFile);
}

View File

@@ -72,7 +72,7 @@ public class DependencyFilterMojoTests {
return a;
}
private static class TestableDependencyFilterMojo extends
private static final class TestableDependencyFilterMojo extends
AbstractDependencyFilterMojo {
private TestableDependencyFilterMojo(List<Exclude> excludes,

View File

@@ -40,10 +40,13 @@ import static org.junit.Assert.assertTrue;
* @author Phillip Webb
* @author Andy Wilkinson
*/
public class Verify {
public final class Verify {
public static final String SAMPLE_APP = "org.test.SampleApplication";
private Verify() {
}
public static void verifyJar(File file) throws Exception {
new JarArchiveVerification(file, SAMPLE_APP).verify();
}

View File

@@ -23,7 +23,12 @@ package org.springframework.boot.maven.sample;
*/
public class ClassWithMainMethod {
public void run() {
System.out.println("Hello World");
}
public static void main(String[] args) {
new ClassWithMainMethod().run();
}
}