Skip to content

Pull #2291: Modernize codebase with Java improvements - Unnecessary throws #2291

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ protected void validate(C context) throws Exception {
.warnAboutDeprecatedOptions(context.invokerRequest.parserRequest(), context.logger::warn);
}

protected void pushCoreProperties(C context) throws Exception {
protected void pushCoreProperties(C context) {
System.setProperty(
Constants.MAVEN_HOME,
context.invokerRequest.installationDirectory().toString());
Expand All @@ -235,7 +235,7 @@ protected void pushCoreProperties(C context) throws Exception {
* {@link PropertyContributor} SPI invocation, and "refreshes" already pushed user properties by re-writing them
* as SPI may have modified them.
*/
protected void pushUserProperties(C context) throws Exception {
protected void pushUserProperties(C context) {
ProtoSession protoSession = context.protoSession;
HashSet<String> sys = new HashSet<>(protoSession.getSystemProperties().keySet());
if (context.pushedUserProperties == null) {
Expand Down Expand Up @@ -493,7 +493,7 @@ protected String describe(Terminal terminal) {
return terminal.getClass().getSimpleName() + " (" + String.join(", ", subs) + ")";
}

protected void preCommands(C context) throws Exception {
protected void preCommands(C context) {
boolean verbose = context.invokerRequest.effectiveVerbose();
boolean version = context.invokerRequest.options().showVersion().orElse(false);
if (verbose || version) {
Expand All @@ -520,7 +520,7 @@ protected ContainerCapsuleFactory<C> createContainerCapsuleFactory() {
return new PlexusContainerCapsuleFactory<>();
}

protected void postContainer(C context) throws Exception {
protected void postContainer(C context) {
ProtoSession protoSession = context.protoSession;
for (PropertyContributor propertyContributor : context.lookup
.lookup(PropertyContributorsHolder.class)
Expand All @@ -533,13 +533,13 @@ protected void postContainer(C context) throws Exception {
context.protoSession = protoSession;
}

protected void lookup(C context) throws Exception {
protected void lookup(C context) {
if (context.eventSpyDispatcher == null) {
context.eventSpyDispatcher = context.lookup.lookup(EventSpyDispatcher.class);
}
}

protected void init(C context) throws Exception {
protected void init(C context) {
Map<String, Object> data = new HashMap<>();
data.put("plexus", context.lookup.lookup(PlexusContainer.class));
data.put("workingDirectory", context.cwd.get().toString());
Expand All @@ -549,7 +549,7 @@ protected void init(C context) throws Exception {
context.eventSpyDispatcher.init(() -> data);
}

protected void postCommands(C context) throws Exception {
protected void postCommands(C context) {
InvokerRequest invokerRequest = context.invokerRequest;
Logger logger = context.logger;
if (invokerRequest.options().showErrors().orElse(false)) {
Expand Down Expand Up @@ -716,10 +716,9 @@ protected Runnable settings(C context, boolean emitSettingsWarnings, SettingsBui
};
}

protected void customizeSettingsRequest(C context, SettingsBuilderRequest settingsBuilderRequest)
throws Exception {}
protected void customizeSettingsRequest(C context, SettingsBuilderRequest settingsBuilderRequest) {}

protected void customizeSettingsResult(C context, SettingsBuilderResult settingsBuilderResult) throws Exception {}
protected void customizeSettingsResult(C context, SettingsBuilderResult settingsBuilderResult) {}

protected boolean mayDisableInteractiveMode(C context, boolean proposedInteractive) {
if (!context.invokerRequest.options().forceInteractive().orElse(false)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -200,11 +200,11 @@ protected LoggerManager createLoggerManager() {
return new Slf4jLoggerManager();
}

protected void customizeContainerConfiguration(C context, ContainerConfiguration configuration) throws Exception {}
protected void customizeContainerConfiguration(C context, ContainerConfiguration configuration) {}

protected void customizeContainer(C context, PlexusContainer container) throws Exception {}
protected void customizeContainer(C context, PlexusContainer container) {}

protected List<Path> parseExtClasspath(C context) throws Exception {
protected List<Path> parseExtClasspath(C context) {
ProtoSession protoSession = context.protoSession;
String extClassPath = protoSession.getUserProperties().get(Constants.MAVEN_EXT_CLASS_PATH);
if (extClassPath == null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ protected int execute(MavenContext context) throws Exception {
return doExecute(context, request);
}

protected MavenExecutionRequest prepareMavenExecutionRequest() throws Exception {
protected MavenExecutionRequest prepareMavenExecutionRequest() {
// explicitly fill in "defaults"?
DefaultMavenExecutionRequest mavenExecutionRequest = new DefaultMavenExecutionRequest();
mavenExecutionRequest.setRepositoryCache(new DefaultRepositoryCache());
Expand Down Expand Up @@ -453,7 +453,7 @@ protected void performProfileActivation(MavenContext context, ProfileActivation
}
}

protected int doExecute(MavenContext context, MavenExecutionRequest request) throws Exception {
protected int doExecute(MavenContext context, MavenExecutionRequest request) {
context.eventSpyDispatcher.onEvent(request);

MavenExecutionResult result;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ protected PromptBuilder dispatcherPrompt(PromptBuilder promptBuilder) {
}

private PromptBuilder configureDispatcher(
EncryptContext context, DispatcherMeta dispatcherMeta, PromptBuilder promptBuilder) throws Exception {
EncryptContext context, DispatcherMeta dispatcherMeta, PromptBuilder promptBuilder) {
context.addInHeader(
context.style.italic().bold().foreground(Colors.rgbColor("yellow")),
"Configure " + dispatcherMeta.displayName());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ public void process(Consumer<TransferEvent> consumer) {
consumer.accept(event);
}

public void waitForProcessed() throws InterruptedException {
public void waitForProcessed() {
// nothing, is async
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ public boolean canConvert(Class<?> type) {
}

@Override
protected Object fromString(String value) throws ComponentConfigurationException {
protected Object fromString(String value) {
return Paths.get(value.replace('/' == File.separatorChar ? '\\' : '/', File.separatorChar));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@
import org.apache.maven.execution.MavenSession;
import org.apache.maven.internal.MultilineMessageHelper;
import org.apache.maven.internal.impl.DefaultLifecycleRegistry;
import org.apache.maven.lifecycle.LifecycleExecutionException;
import org.apache.maven.lifecycle.LifecycleNotFoundException;
import org.apache.maven.lifecycle.LifecyclePhaseNotFoundException;
import org.apache.maven.lifecycle.MavenExecutionPlan;
Expand Down Expand Up @@ -103,8 +102,7 @@ public MavenExecutionPlan resolveBuildPlan(
MavenSession session, MavenProject project, TaskSegment taskSegment, Set<Artifact> projectArtifacts)
throws PluginNotFoundException, PluginResolutionException, LifecyclePhaseNotFoundException,
PluginDescriptorParsingException, MojoNotFoundException, InvalidPluginDescriptorException,
NoPluginFoundForPrefixException, LifecycleNotFoundException, PluginVersionResolutionException,
LifecycleExecutionException {
NoPluginFoundForPrefixException, LifecycleNotFoundException, PluginVersionResolutionException {
MavenExecutionPlan executionPlan =
lifeCycleExecutionPlanCalculator.calculateExecutionPlan(session, project, taskSegment.getTasks());

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@
import java.util.Optional;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.Executors;
import java.util.concurrent.locks.ReadWriteLock;
import java.util.concurrent.locks.ReentrantReadWriteLock;
Expand Down Expand Up @@ -186,8 +185,7 @@ public BuildPlanExecutor(
this.lifecycles = lifecycles;
}

public void execute(MavenSession session, ReactorContext reactorContext, List<TaskSegment> taskSegments)
throws ExecutionException, InterruptedException {
public void execute(MavenSession session, ReactorContext reactorContext, List<TaskSegment> taskSegments) {
try (BuildContext ctx = new BuildContext(session, reactorContext, taskSegments)) {
ctx.execute();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ private static final class WsrClassCatcher extends AbstractMavenLifecyclePartici
private final AtomicReference<Class<?>> wsrClassRef = new AtomicReference<>(null);

@Override
public void afterProjectsRead(MavenSession session) throws MavenExecutionException {
public void afterProjectsRead(MavenSession session) {
wsrClassRef.set(session.getRepositorySession().getWorkspaceReader().getClass());
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,12 @@ class DefaultBeanConfiguratorPathTest {
private BeanConfigurator configurator;

@BeforeEach
void setUp() throws Exception {
void setUp() {
configurator = new DefaultBeanConfigurator();
}

@AfterEach
void tearDown() throws Exception {
void tearDown() {
configurator = null;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,12 @@ class DefaultBeanConfiguratorTest {
private BeanConfigurator configurator;

@BeforeEach
void setUp() throws Exception {
void setUp() {
configurator = new DefaultBeanConfigurator();
}

@AfterEach
void tearDown() throws Exception {
void tearDown() {
configurator = null;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@

class MojoExecutionScopeTest {
@Test
void testNestedEnter() throws Exception {
void testNestedEnter() {
MojoExecutionScope scope = new MojoExecutionScope();

scope.enter();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ void emptySha1Calculator() {
}

@Test
void calculateByte() throws IOException {
void calculateByte() {
Map<ChecksumAlgorithmService.ChecksumAlgorithm, String> checksums = service.calculate(
"test".getBytes(StandardCharsets.UTF_8), service.select(Arrays.asList("SHA-1", "MD5")));
assertNotNull(checksums);
Expand All @@ -78,7 +78,7 @@ void calculateByte() throws IOException {
}

@Test
void calculateByteBuffer() throws IOException {
void calculateByteBuffer() {
Map<ChecksumAlgorithmService.ChecksumAlgorithm, String> checksums = service.calculate(
ByteBuffer.wrap("test".getBytes(StandardCharsets.UTF_8)),
service.select(Arrays.asList("SHA-1", "MD5")));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ public abstract class AbstractRepositoryTestCase {
protected RepositorySystemSession session;

@BeforeEach
public void setUp() throws Exception {
public void setUp() {
session = newMavenRepositorySystemSession(system);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ void testSimpleConsumer() throws Exception {
}

@Test
void testScmInheritance() throws Exception {
void testScmInheritance() {
Model model = Model.newBuilder()
.scm(Scm.newBuilder()
.connection("scm:git:https://github.com/apache/maven-project.git")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ protected String getProjectsDirectory() {
}

@Test
void testCreation() throws Exception {
void testCreation() {
assertNotNull(defaultLifeCycles);
assertNotNull(mojoExecutor);
assertNotNull(lifeCycleBuilder);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,7 @@ void testLifecycleQueryingUsingADefaultLifecyclePhase() throws Exception {
}

@Test
void testLifecyclePluginsRetrievalForDefaultLifecycle() throws Exception {
void testLifecyclePluginsRetrievalForDefaultLifecycle() {
List<Plugin> plugins = new ArrayList<>(lifecycleExecutor.getPluginsBoundByDefaultToAllLifecycles("jar"));

assertThat(plugins.toString(), plugins, hasSize(8));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,13 +79,13 @@ void testDefaultBindingPluginsWarning() throws Exception {
}

@Test
void testHandleBuildError() throws Exception {}
void testHandleBuildError() {}

@Test
void testAttachToThread() throws Exception {}
void testAttachToThread() {}

@Test
void testGetKey() throws Exception {}
void testGetKey() {}

public BuilderCommon getBuilderCommon(Logger logger) {
final LifecycleDebugLogger debugLogger = new LifecycleDebugLogger();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -190,10 +190,7 @@ public static MavenExecutionPlan getProjectBExecutionPlan()
return createExecutionPlan(ProjectDependencyGraphStub.B.getExecutionProject(), me);
}

private static MavenExecutionPlan createExecutionPlan(MavenProject project, List<MojoExecution> mojoExecutions)
throws InvalidPluginDescriptorException, PluginVersionResolutionException, PluginDescriptorParsingException,
NoPluginFoundForPrefixException, MojoNotFoundException, PluginNotFoundException,
PluginResolutionException, LifecyclePhaseNotFoundException, LifecycleNotFoundException {
private static MavenExecutionPlan createExecutionPlan(MavenProject project, List<MojoExecution> mojoExecutions) {
final List<ExecutionPlanItem> planItemList =
ExecutionPlanItem.createExecutionPlanItems(project, mojoExecutions);
return new MavenExecutionPlan(planItemList, getDefaultLifecycles());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,10 +107,7 @@ public static List<ProjectSegment> getProjectBuilds(MavenSession session)
}

private static ProjectSegment createProjectBuild(
MavenProject project, MavenSession session, TaskSegment taskSegment)
throws InvalidPluginDescriptorException, PluginVersionResolutionException, PluginDescriptorParsingException,
NoPluginFoundForPrefixException, MojoNotFoundException, PluginNotFoundException,
PluginResolutionException, LifecyclePhaseNotFoundException, LifecycleNotFoundException {
MavenProject project, MavenSession session, TaskSegment taskSegment) {
final MavenSession session1 = session.clone();
return new ProjectSegment(project, taskSegment, session1);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,6 @@
import org.apache.maven.model.root.RootLocator;
import org.apache.maven.plugin.descriptor.MojoDescriptor;
import org.apache.maven.plugin.descriptor.PluginDescriptor;
import org.apache.maven.project.CycleDetectedException;
import org.apache.maven.project.DuplicateProjectException;
import org.apache.maven.project.MavenProject;
import org.codehaus.plexus.MutablePlexusContainer;
import org.codehaus.plexus.PlexusContainer;
Expand Down Expand Up @@ -337,8 +335,7 @@ void testValueExtractionFromSystemPropertiesWithMissingProjectWithDotNotation()
}

@SuppressWarnings("deprecation")
private static MavenSession createSession(PlexusContainer container, ArtifactRepository repo, Properties properties)
throws CycleDetectedException, DuplicateProjectException {
private static MavenSession createSession(PlexusContainer container, ArtifactRepository repo, Properties properties) {
MavenExecutionRequest request = new DefaultMavenExecutionRequest()
.setSystemProperties(properties)
.setGoals(Collections.emptyList())
Expand Down Expand Up @@ -498,7 +495,7 @@ private ExpressionEvaluator createExpressionEvaluator(
return new PluginParameterExpressionEvaluator(session, mojoExecution);
}

protected Artifact createArtifact(String groupId, String artifactId, String version) throws Exception {
protected Artifact createArtifact(String groupId, String artifactId, String version) {
Dependency dependency = new Dependency();
dependency.setGroupId(groupId);
dependency.setArtifactId(artifactId);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,6 @@
import org.apache.maven.model.root.RootLocator;
import org.apache.maven.plugin.descriptor.MojoDescriptor;
import org.apache.maven.plugin.descriptor.PluginDescriptor;
import org.apache.maven.project.CycleDetectedException;
import org.apache.maven.project.DuplicateProjectException;
import org.apache.maven.project.MavenProject;
import org.codehaus.plexus.MutablePlexusContainer;
import org.codehaus.plexus.PlexusContainer;
Expand Down Expand Up @@ -293,7 +291,7 @@ public void testValueExtractionFromSystemPropertiesWithMissingProjectWithDotNota

@SuppressWarnings("deprecation")
private static MavenSession createSession(PlexusContainer container, ArtifactRepository repo, Properties properties)
throws CycleDetectedException, DuplicateProjectException, NoLocalRepositoryManagerException {
throws NoLocalRepositoryManagerException {
MavenExecutionRequest request = new DefaultMavenExecutionRequest()
.setSystemProperties(properties)
.setGoals(Collections.emptyList())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,12 @@ class ExtensionDescriptorBuilderTest {
private ExtensionDescriptorBuilder builder;

@BeforeEach
void setUp() throws Exception {
void setUp() {
builder = new ExtensionDescriptorBuilder();
}

@AfterEach
void tearDown() throws Exception {
void tearDown() {
builder = null;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ class PomConstructionTest {
private File testDirectory;

@BeforeEach
void setUp() throws Exception {
void setUp() {
testDirectory = new File(getBasedir(), BASE_POM_DIR);
new File(getBasedir(), BASE_MIXIN_DIR);
EmptyLifecycleBindingsInjector.useEmpty();
Expand Down Expand Up @@ -1226,7 +1226,7 @@ void testCompleteModelWithParent() throws Exception {
}

@SuppressWarnings("checkstyle:MethodLength")
private void testCompleteModel(PomTestWrapper pom) throws Exception {
private void testCompleteModel(PomTestWrapper pom) {
assertEquals("4.0.0", pom.getValue("modelVersion"));

assertEquals("org.apache.maven.its.mng", pom.getValue("groupId"));
Expand Down
Loading
Loading