Skip to content

Commit a84fac9

Browse files
author
Vincent Potucek
committed
Pull #2291: Modernize codebase with Java improvements - Unnecessary throws
1 parent 3002b40 commit a84fac9

File tree

79 files changed

+179
-229
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

79 files changed

+179
-229
lines changed

impl/maven-cli/src/main/java/org/apache/maven/cling/invoker/LookupInvoker.java

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,7 @@ protected void validate(C context) throws Exception {
222222
.warnAboutDeprecatedOptions(context.invokerRequest.parserRequest(), context.logger::warn);
223223
}
224224

225-
protected void pushCoreProperties(C context) throws Exception {
225+
protected void pushCoreProperties(C context) {
226226
System.setProperty(
227227
Constants.MAVEN_HOME,
228228
context.invokerRequest.installationDirectory().toString());
@@ -235,7 +235,7 @@ protected void pushCoreProperties(C context) throws Exception {
235235
* {@link PropertyContributor} SPI invocation, and "refreshes" already pushed user properties by re-writing them
236236
* as SPI may have modified them.
237237
*/
238-
protected void pushUserProperties(C context) throws Exception {
238+
protected void pushUserProperties(C context) {
239239
ProtoSession protoSession = context.protoSession;
240240
HashSet<String> sys = new HashSet<>(protoSession.getSystemProperties().keySet());
241241
if (context.pushedUserProperties == null) {
@@ -493,7 +493,7 @@ protected String describe(Terminal terminal) {
493493
return terminal.getClass().getSimpleName() + " (" + String.join(", ", subs) + ")";
494494
}
495495

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

523-
protected void postContainer(C context) throws Exception {
523+
protected void postContainer(C context) {
524524
ProtoSession protoSession = context.protoSession;
525525
for (PropertyContributor propertyContributor : context.lookup
526526
.lookup(PropertyContributorsHolder.class)
@@ -533,13 +533,13 @@ protected void postContainer(C context) throws Exception {
533533
context.protoSession = protoSession;
534534
}
535535

536-
protected void lookup(C context) throws Exception {
536+
protected void lookup(C context) {
537537
if (context.eventSpyDispatcher == null) {
538538
context.eventSpyDispatcher = context.lookup.lookup(EventSpyDispatcher.class);
539539
}
540540
}
541541

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

552-
protected void postCommands(C context) throws Exception {
552+
protected void postCommands(C context) {
553553
InvokerRequest invokerRequest = context.invokerRequest;
554554
Logger logger = context.logger;
555555
if (invokerRequest.options().showErrors().orElse(false)) {
@@ -716,10 +716,9 @@ protected Runnable settings(C context, boolean emitSettingsWarnings, SettingsBui
716716
};
717717
}
718718

719-
protected void customizeSettingsRequest(C context, SettingsBuilderRequest settingsBuilderRequest)
720-
throws Exception {}
719+
protected void customizeSettingsRequest(C context, SettingsBuilderRequest settingsBuilderRequest) {}
721720

722-
protected void customizeSettingsResult(C context, SettingsBuilderResult settingsBuilderResult) throws Exception {}
721+
protected void customizeSettingsResult(C context, SettingsBuilderResult settingsBuilderResult) {}
723722

724723
protected boolean mayDisableInteractiveMode(C context, boolean proposedInteractive) {
725724
if (!context.invokerRequest.options().forceInteractive().orElse(false)) {

impl/maven-cli/src/main/java/org/apache/maven/cling/invoker/PlexusContainerCapsuleFactory.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -200,11 +200,11 @@ protected LoggerManager createLoggerManager() {
200200
return new Slf4jLoggerManager();
201201
}
202202

203-
protected void customizeContainerConfiguration(C context, ContainerConfiguration configuration) throws Exception {}
203+
protected void customizeContainerConfiguration(C context, ContainerConfiguration configuration) {}
204204

205-
protected void customizeContainer(C context, PlexusContainer container) throws Exception {}
205+
protected void customizeContainer(C context, PlexusContainer container) {}
206206

207-
protected List<Path> parseExtClasspath(C context) throws Exception {
207+
protected List<Path> parseExtClasspath(C context) {
208208
ProtoSession protoSession = context.protoSession;
209209
String extClassPath = protoSession.getUserProperties().get(Constants.MAVEN_EXT_CLASS_PATH);
210210
if (extClassPath == null) {

impl/maven-cli/src/main/java/org/apache/maven/cling/invoker/mvn/MavenInvoker.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ protected int execute(MavenContext context) throws Exception {
100100
return doExecute(context, request);
101101
}
102102

103-
protected MavenExecutionRequest prepareMavenExecutionRequest() throws Exception {
103+
protected MavenExecutionRequest prepareMavenExecutionRequest() {
104104
// explicitly fill in "defaults"?
105105
DefaultMavenExecutionRequest mavenExecutionRequest = new DefaultMavenExecutionRequest();
106106
mavenExecutionRequest.setRepositoryCache(new DefaultRepositoryCache());
@@ -453,7 +453,7 @@ protected void performProfileActivation(MavenContext context, ProfileActivation
453453
}
454454
}
455455

456-
protected int doExecute(MavenContext context, MavenExecutionRequest request) throws Exception {
456+
protected int doExecute(MavenContext context, MavenExecutionRequest request) {
457457
context.eventSpyDispatcher.onEvent(request);
458458

459459
MavenExecutionResult result;

impl/maven-cli/src/main/java/org/apache/maven/cling/invoker/mvnenc/goals/Init.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,7 @@ protected PromptBuilder dispatcherPrompt(PromptBuilder promptBuilder) {
235235
}
236236

237237
private PromptBuilder configureDispatcher(
238-
EncryptContext context, DispatcherMeta dispatcherMeta, PromptBuilder promptBuilder) throws Exception {
238+
EncryptContext context, DispatcherMeta dispatcherMeta, PromptBuilder promptBuilder) {
239239
context.addInHeader(
240240
context.style.italic().bold().foreground(Colors.rgbColor("yellow")),
241241
"Configure " + dispatcherMeta.displayName());

impl/maven-cli/src/main/java/org/apache/maven/cling/transfer/SimplexTransferListener.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,7 @@ public void process(Consumer<TransferEvent> consumer) {
215215
consumer.accept(event);
216216
}
217217

218-
public void waitForProcessed() throws InterruptedException {
218+
public void waitForProcessed() {
219219
// nothing, is async
220220
}
221221
}

impl/maven-core/src/main/java/org/apache/maven/configuration/internal/DefaultBeanConfigurator.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ public boolean canConvert(Class<?> type) {
178178
}
179179

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

impl/maven-core/src/main/java/org/apache/maven/lifecycle/internal/builder/BuilderCommon.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@
3535
import org.apache.maven.execution.MavenSession;
3636
import org.apache.maven.internal.MultilineMessageHelper;
3737
import org.apache.maven.internal.impl.DefaultLifecycleRegistry;
38-
import org.apache.maven.lifecycle.LifecycleExecutionException;
3938
import org.apache.maven.lifecycle.LifecycleNotFoundException;
4039
import org.apache.maven.lifecycle.LifecyclePhaseNotFoundException;
4140
import org.apache.maven.lifecycle.MavenExecutionPlan;
@@ -103,8 +102,7 @@ public MavenExecutionPlan resolveBuildPlan(
103102
MavenSession session, MavenProject project, TaskSegment taskSegment, Set<Artifact> projectArtifacts)
104103
throws PluginNotFoundException, PluginResolutionException, LifecyclePhaseNotFoundException,
105104
PluginDescriptorParsingException, MojoNotFoundException, InvalidPluginDescriptorException,
106-
NoPluginFoundForPrefixException, LifecycleNotFoundException, PluginVersionResolutionException,
107-
LifecycleExecutionException {
105+
NoPluginFoundForPrefixException, LifecycleNotFoundException, PluginVersionResolutionException {
108106
MavenExecutionPlan executionPlan =
109107
lifeCycleExecutionPlanCalculator.calculateExecutionPlan(session, project, taskSegment.getTasks());
110108

impl/maven-core/src/main/java/org/apache/maven/lifecycle/internal/concurrent/BuildPlanExecutor.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@
3434
import java.util.Optional;
3535
import java.util.Set;
3636
import java.util.concurrent.ConcurrentHashMap;
37-
import java.util.concurrent.ExecutionException;
3837
import java.util.concurrent.Executors;
3938
import java.util.concurrent.locks.ReadWriteLock;
4039
import java.util.concurrent.locks.ReentrantReadWriteLock;
@@ -186,8 +185,7 @@ public BuildPlanExecutor(
186185
this.lifecycles = lifecycles;
187186
}
188187

189-
public void execute(MavenSession session, ReactorContext reactorContext, List<TaskSegment> taskSegments)
190-
throws ExecutionException, InterruptedException {
188+
public void execute(MavenSession session, ReactorContext reactorContext, List<TaskSegment> taskSegments) {
191189
try (BuildContext ctx = new BuildContext(session, reactorContext, taskSegments)) {
192190
ctx.execute();
193191
}

impl/maven-core/src/test/java/org/apache/maven/DefaultMavenTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ private static final class WsrClassCatcher extends AbstractMavenLifecyclePartici
4848
private final AtomicReference<Class<?>> wsrClassRef = new AtomicReference<>(null);
4949

5050
@Override
51-
public void afterProjectsRead(MavenSession session) throws MavenExecutionException {
51+
public void afterProjectsRead(MavenSession session) {
5252
wsrClassRef.set(session.getRepositorySession().getWorkspaceReader().getClass());
5353
}
5454
}

impl/maven-core/src/test/java/org/apache/maven/configuration/DefaultBeanConfiguratorPathTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,12 +41,12 @@ class DefaultBeanConfiguratorPathTest {
4141
private BeanConfigurator configurator;
4242

4343
@BeforeEach
44-
void setUp() throws Exception {
44+
void setUp() {
4545
configurator = new DefaultBeanConfigurator();
4646
}
4747

4848
@AfterEach
49-
void tearDown() throws Exception {
49+
void tearDown() {
5050
configurator = null;
5151
}
5252

0 commit comments

Comments
 (0)