Remove `throws IOException` from DefaultGenerationContext.writeGeneratedContent()
The `throws` declaration is unnecessary since writeGeneratedContent() will never throw an IOException.
This commit is contained in:
parent
a466179bc8
commit
0944c9a99c
|
@ -16,7 +16,6 @@
|
|||
|
||||
package org.springframework.aot.generate;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
@ -27,9 +26,9 @@ import org.springframework.util.Assert;
|
|||
/**
|
||||
* Default {@link GenerationContext} implementation.
|
||||
*
|
||||
* <p>Generated classes are flushed out using {@link #writeGeneratedContent()}
|
||||
* and should be called once the generation process using this instance has
|
||||
* completed.
|
||||
* <p>Generated classes can be flushed out using {@link #writeGeneratedContent()}
|
||||
* which should be called only once after the generation process using this instance
|
||||
* has completed.
|
||||
*
|
||||
* @author Phillip Webb
|
||||
* @author Stephane Nicoll
|
||||
|
@ -108,7 +107,7 @@ public class DefaultGenerationContext implements GenerationContext {
|
|||
/**
|
||||
* Write any generated content out to the generated files.
|
||||
*/
|
||||
public void writeGeneratedContent() throws IOException {
|
||||
public void writeGeneratedContent() {
|
||||
this.generatedClasses.writeTo(this.generatedFiles);
|
||||
}
|
||||
|
||||
|
|
|
@ -30,8 +30,10 @@ import org.springframework.lang.Nullable;
|
|||
import org.springframework.util.Assert;
|
||||
|
||||
/**
|
||||
* A managed collection of generated classes. This class is stateful so the
|
||||
* same instance should be used for all class generation.
|
||||
* A managed collection of generated classes.
|
||||
*
|
||||
* <p>This class is stateful, so the same instance should be used for all class
|
||||
* generation.
|
||||
*
|
||||
* @author Phillip Webb
|
||||
* @author Stephane Nicoll
|
||||
|
@ -157,7 +159,7 @@ public class GeneratedClasses {
|
|||
* @param generatedFiles where to write the generated classes
|
||||
* @throws IOException on IO error
|
||||
*/
|
||||
void writeTo(GeneratedFiles generatedFiles) throws IOException {
|
||||
void writeTo(GeneratedFiles generatedFiles) {
|
||||
Assert.notNull(generatedFiles, "'generatedFiles' must not be null");
|
||||
List<GeneratedClass> generatedClasses = new ArrayList<>(this.classes);
|
||||
generatedClasses.sort(Comparator.comparing(GeneratedClass::getName));
|
||||
|
@ -172,7 +174,6 @@ public class GeneratedClasses {
|
|||
}
|
||||
|
||||
private record Owner(String featureNamePrefix, String featureName, @Nullable Class<?> target) {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -16,9 +16,6 @@
|
|||
|
||||
package org.springframework.core.testfixture.aot.generate;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.UncheckedIOException;
|
||||
|
||||
import org.springframework.aot.generate.ClassNameGenerator;
|
||||
import org.springframework.aot.generate.DefaultGenerationContext;
|
||||
import org.springframework.aot.generate.GenerationContext;
|
||||
|
@ -26,9 +23,7 @@ import org.springframework.aot.generate.InMemoryGeneratedFiles;
|
|||
|
||||
/**
|
||||
* {@link GenerationContext} test implementation that uses
|
||||
* {@link InMemoryGeneratedFiles} by default, with a convenient override of
|
||||
* {@link #writeGeneratedContent()} that throws {@link UncheckedIOException}
|
||||
* instead of {@link IOException}.
|
||||
* {@link InMemoryGeneratedFiles} by default.
|
||||
*
|
||||
* @author Stephane Nicoll
|
||||
* @author Sam Brannen
|
||||
|
@ -75,14 +70,4 @@ public class TestGenerationContext extends DefaultGenerationContext {
|
|||
return (InMemoryGeneratedFiles) super.getGeneratedFiles();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeGeneratedContent() {
|
||||
try {
|
||||
super.writeGeneratedContent();
|
||||
}
|
||||
catch (IOException ex) {
|
||||
throw new UncheckedIOException(ex);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -16,9 +16,6 @@
|
|||
|
||||
package org.springframework.test.aot.generate;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.UncheckedIOException;
|
||||
|
||||
import org.springframework.aot.generate.ClassNameGenerator;
|
||||
import org.springframework.aot.generate.DefaultGenerationContext;
|
||||
import org.springframework.aot.generate.GenerationContext;
|
||||
|
@ -26,9 +23,7 @@ import org.springframework.aot.generate.InMemoryGeneratedFiles;
|
|||
|
||||
/**
|
||||
* {@link GenerationContext} test implementation that uses
|
||||
* {@link InMemoryGeneratedFiles} by default, with a convenient override of
|
||||
* {@link #writeGeneratedContent()} that throws {@link UncheckedIOException}
|
||||
* instead of {@link IOException}.
|
||||
* {@link InMemoryGeneratedFiles} by default.
|
||||
*
|
||||
* @author Stephane Nicoll
|
||||
* @author Sam Brannen
|
||||
|
@ -68,14 +63,4 @@ public class TestGenerationContext extends DefaultGenerationContext {
|
|||
return (InMemoryGeneratedFiles) super.getGeneratedFiles();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeGeneratedContent() {
|
||||
try {
|
||||
super.writeGeneratedContent();
|
||||
}
|
||||
catch (IOException ex) {
|
||||
throw new UncheckedIOException(ex);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue