Remove redundant throws declarations from internal APIs

Closes gh-31176
This commit is contained in:
Andy Wilkinson
2022-05-26 14:24:55 +01:00
parent cbf42dea14
commit ee45fd2fc8
69 changed files with 157 additions and 193 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2021 the original author or authors.
* Copyright 2012-2022 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.
@@ -49,7 +49,7 @@ class BuildpackCoordinatesTests extends AbstractJsonTests {
}
@Test
void fromTomlWhenMissingDescriptorThrowsException() throws Exception {
void fromTomlWhenMissingDescriptorThrowsException() {
ByteArrayInputStream coordinates = new ByteArrayInputStream("".getBytes());
assertThatIllegalArgumentException().isThrownBy(() -> BuildpackCoordinates.fromToml(coordinates, this.archive))
.withMessageContaining("Buildpack descriptor 'buildpack.toml' is required")
@@ -57,7 +57,7 @@ class BuildpackCoordinatesTests extends AbstractJsonTests {
}
@Test
void fromTomlWhenMissingIDThrowsException() throws Exception {
void fromTomlWhenMissingIDThrowsException() {
InputStream coordinates = createTomlStream(null, null, true, false);
assertThatIllegalArgumentException().isThrownBy(() -> BuildpackCoordinates.fromToml(coordinates, this.archive))
.withMessageContaining("Buildpack descriptor must contain ID")
@@ -65,7 +65,7 @@ class BuildpackCoordinatesTests extends AbstractJsonTests {
}
@Test
void fromTomlWhenMissingVersionThrowsException() throws Exception {
void fromTomlWhenMissingVersionThrowsException() {
InputStream coordinates = createTomlStream("example/buildpack1", null, true, false);
assertThatIllegalArgumentException().isThrownBy(() -> BuildpackCoordinates.fromToml(coordinates, this.archive))
.withMessageContaining("Buildpack descriptor must contain version")
@@ -73,7 +73,7 @@ class BuildpackCoordinatesTests extends AbstractJsonTests {
}
@Test
void fromTomlWhenMissingStacksAndOrderThrowsException() throws Exception {
void fromTomlWhenMissingStacksAndOrderThrowsException() {
InputStream coordinates = createTomlStream("example/buildpack1", "0.0.1", false, false);
assertThatIllegalArgumentException().isThrownBy(() -> BuildpackCoordinates.fromToml(coordinates, this.archive))
.withMessageContaining("Buildpack descriptor must contain either 'stacks' or 'order'")
@@ -81,7 +81,7 @@ class BuildpackCoordinatesTests extends AbstractJsonTests {
}
@Test
void fromTomlWhenContainsBothStacksAndOrderThrowsException() throws Exception {
void fromTomlWhenContainsBothStacksAndOrderThrowsException() {
InputStream coordinates = createTomlStream("example/buildpack1", "0.0.1", true, true);
assertThatIllegalArgumentException().isThrownBy(() -> BuildpackCoordinates.fromToml(coordinates, this.archive))
.withMessageContaining("Buildpack descriptor must not contain both 'stacks' and 'order'")

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2021 the original author or authors.
* Copyright 2012-2022 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,7 +58,7 @@ class FilePermissionsTests {
@Test
@DisabledOnOs(OS.WINDOWS)
void umaskForPathWithNonExistentFile() throws IOException {
void umaskForPathWithNonExistentFile() {
assertThatIOException()
.isThrownBy(() -> FilePermissions.umaskForPath(Paths.get(this.tempDir.toString(), "does-not-exist")));
}
@@ -72,7 +72,7 @@ class FilePermissionsTests {
}
@Test
void umaskForPathWithNullPath() throws IOException {
void umaskForPathWithNullPath() {
assertThatIllegalArgumentException().isThrownBy(() -> FilePermissions.umaskForPath(null));
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2019 the original author or authors.
* Copyright 2012-2022 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.
@@ -91,7 +91,7 @@ public final class ConfigurationMetadataRepositoryJsonBuilder {
return result;
}
private SimpleConfigurationMetadataRepository add(InputStream in, Charset charset) throws IOException {
private SimpleConfigurationMetadataRepository add(InputStream in, Charset charset) {
try {
RawConfigurationMetadata metadata = this.reader.read(in, charset);
return create(metadata);

View File

@@ -112,16 +112,11 @@ abstract class AbstractBootArchiveTests<T extends Jar & BootArchive> {
@BeforeEach
void createTask() {
try {
File projectDir = new File(this.temp, "project");
projectDir.mkdirs();
this.project = GradleProjectBuilder.builder().withProjectDir(projectDir).build();
this.project.setDescription("Test project for " + this.taskClass.getSimpleName());
this.task = configure(this.project.getTasks().create("testArchive", this.taskClass));
}
catch (IOException ex) {
throw new RuntimeException(ex);
}
File projectDir = new File(this.temp, "project");
projectDir.mkdirs();
this.project = GradleProjectBuilder.builder().withProjectDir(projectDir).build();
this.project.setDescription("Test project for " + this.taskClass.getSimpleName());
this.task = configure(this.project.getTasks().create("testArchive", this.taskClass));
}
@Test
@@ -586,7 +581,7 @@ abstract class AbstractBootArchiveTests<T extends Jar & BootArchive> {
return file;
}
private T configure(T task) throws IOException {
private T configure(T task) {
AbstractArchiveTask archiveTask = task;
archiveTask.getArchiveBaseName().set("test");
File destination = new File(this.temp, "destination");

View File

@@ -92,7 +92,7 @@ abstract class AbstractPackagerTests<P extends Packager> {
protected TestJarFile testJarFile;
@BeforeEach
void setup() throws IOException {
void setup() {
this.testJarFile = new TestJarFile(this.tempDir);
}
@@ -628,7 +628,7 @@ abstract class AbstractPackagerTests<P extends Packager> {
return new Library(null, file, scope, null, unpackRequired, false, included);
}
protected final P createPackager() throws IOException {
protected final P createPackager() {
return createPackager(this.testJarFile.getFile());
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2020 the original author or authors.
* Copyright 2012-2022 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.
@@ -17,7 +17,6 @@
package org.springframework.boot.loader.tools;
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.jar.JarFile;
@@ -45,7 +44,7 @@ class MainClassFinderTests {
private TestJarFile testJarFile;
@BeforeEach
void setup(@TempDir File tempDir) throws IOException {
void setup(@TempDir File tempDir) {
this.testJarFile = new TestJarFile(tempDir);
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2020 the original author or authors.
* Copyright 2012-2022 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.
@@ -46,7 +46,7 @@ public class TestJarFile {
private final List<ZipEntrySource> entries = new ArrayList<>();
public TestJarFile(File temporaryDirectory) throws IOException {
public TestJarFile(File temporaryDirectory) {
this.temporaryDirectory = temporaryDirectory;
this.jarSource = new File(temporaryDirectory, "jar-source");
}
@@ -115,11 +115,11 @@ public class TestJarFile {
return this.jarSource;
}
public File getFile() throws IOException {
public File getFile() {
return getFile("jar");
}
public File getFile(String extension) throws IOException {
public File getFile(String extension) {
File file = new File(this.temporaryDirectory, UUID.randomUUID() + "." + extension);
ZipUtil.pack(this.entries.toArray(new ZipEntrySource[0]), file);
return file;

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2021 the original author or authors.
* Copyright 2012-2022 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.
@@ -221,7 +221,7 @@ class CentralDirectoryEndRecord {
private final long offset;
private Zip64Locator(long offset, byte[] block) throws IOException {
private Zip64Locator(long offset, byte[] block) {
this.offset = offset;
this.zip64EndOffset = Bytes.littleEndianValue(block, ZIP64_LOCOFF, 8);
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2021 the original author or authors.
* Copyright 2012-2022 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.
@@ -407,8 +407,7 @@ class JarIntegrationTests extends AbstractArchiveIntegrationTests {
}
@TestTemplate
void whenJarIsRepackagedWithOutputTimestampConfiguredThenLibrariesAreSorted(MavenBuild mavenBuild)
throws InterruptedException {
void whenJarIsRepackagedWithOutputTimestampConfiguredThenLibrariesAreSorted(MavenBuild mavenBuild) {
mavenBuild.project("jar-output-timestamp").execute((project) -> {
File repackaged = new File(project, "target/jar-output-timestamp-0.0.1.BUILD-SNAPSHOT.jar");
List<String> sortedLibs = Arrays.asList("BOOT-INF/lib/jakarta.servlet-api", "BOOT-INF/lib/spring-aop",

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2021 the original author or authors.
* Copyright 2012-2022 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.
@@ -113,8 +113,7 @@ class WarIntegrationTests extends AbstractArchiveIntegrationTests {
}
@TestTemplate
void whenWarIsRepackagedWithOutputTimestampConfiguredThenLibrariesAreSorted(MavenBuild mavenBuild)
throws InterruptedException {
void whenWarIsRepackagedWithOutputTimestampConfiguredThenLibrariesAreSorted(MavenBuild mavenBuild) {
mavenBuild.project("war-output-timestamp").execute((project) -> {
File repackaged = new File(project, "target/war-output-timestamp-0.0.1.BUILD-SNAPSHOT.war");
List<String> sortedLibs = Arrays.asList(

View File

@@ -188,7 +188,7 @@ public class StartMojo extends AbstractRunMojo {
}
}
private void waitForForkedSpringApplication() throws IOException, MojoFailureException, MojoExecutionException {
private void waitForForkedSpringApplication() throws IOException, MojoExecutionException {
try {
getLog().debug("Connecting to local MBeanServer at port " + this.jmxPort);
try (JMXConnector connector = execute(this.wait, this.maxAttempts, new CreateJmxConnector(this.jmxPort))) {
@@ -210,7 +210,7 @@ public class StartMojo extends AbstractRunMojo {
}
private void doWaitForSpringApplication(MBeanServerConnection connection)
throws IOException, MojoExecutionException, MojoFailureException {
throws MojoExecutionException, MojoFailureException {
final SpringApplicationAdminClient client = new SpringApplicationAdminClient(connection, this.jmxName);
try {
execute(this.wait, this.maxAttempts, () -> (client.isReady() ? true : null));

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2021 the original author or authors.
* Copyright 2012-2022 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.
@@ -111,14 +111,14 @@ public class StopMojo extends AbstractMojo {
return true;
}
private void stopForkedProcess() throws IOException, MojoFailureException, MojoExecutionException {
private void stopForkedProcess() throws IOException, MojoExecutionException {
try (JMXConnector connector = SpringApplicationAdminClient.connect(this.jmxPort)) {
MBeanServerConnection connection = connector.getMBeanServerConnection();
doStop(connection);
}
}
private void stop() throws IOException, MojoFailureException, MojoExecutionException {
private void stop() throws IOException, MojoExecutionException {
doStop(ManagementFactory.getPlatformMBeanServer());
}