diff --git a/integration-tests/src/test/java/org/wildfly/prospero/it/cli/ApplyUpdateTest.java b/integration-tests/src/test/java/org/wildfly/prospero/it/cli/ApplyUpdateTest.java
index 5df8805e1..ec860d6dd 100644
--- a/integration-tests/src/test/java/org/wildfly/prospero/it/cli/ApplyUpdateTest.java
+++ b/integration-tests/src/test/java/org/wildfly/prospero/it/cli/ApplyUpdateTest.java
@@ -37,6 +37,7 @@
import static org.junit.Assert.assertEquals;
import static org.wildfly.prospero.test.MetadataTestUtils.upgradeStreamInManifest;
+@SuppressWarnings("OptionalGetWithoutIsPresent")
public class ApplyUpdateTest extends CliTestBase {
@Rule
diff --git a/integration-tests/src/test/java/org/wildfly/prospero/it/cli/UpdateWithAdditionalRepositoryTest.java b/integration-tests/src/test/java/org/wildfly/prospero/it/cli/UpdateWithAdditionalRepositoryTest.java
index 55f3d98df..22572944e 100644
--- a/integration-tests/src/test/java/org/wildfly/prospero/it/cli/UpdateWithAdditionalRepositoryTest.java
+++ b/integration-tests/src/test/java/org/wildfly/prospero/it/cli/UpdateWithAdditionalRepositoryTest.java
@@ -40,6 +40,7 @@
import static org.junit.Assert.assertEquals;
import static org.wildfly.prospero.test.MetadataTestUtils.upgradeStreamInManifest;
+@SuppressWarnings("OptionalGetWithoutIsPresent")
public class UpdateWithAdditionalRepositoryTest extends CliTestBase {
private File targetDir;
diff --git a/integration-tests/src/test/java/org/wildfly/prospero/it/commonapi/InstallationHistoryActionTest.java b/integration-tests/src/test/java/org/wildfly/prospero/it/commonapi/InstallationHistoryActionTest.java
index 708aeba77..6981b4ee2 100644
--- a/integration-tests/src/test/java/org/wildfly/prospero/it/commonapi/InstallationHistoryActionTest.java
+++ b/integration-tests/src/test/java/org/wildfly/prospero/it/commonapi/InstallationHistoryActionTest.java
@@ -58,6 +58,7 @@
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
+@SuppressWarnings("OptionalGetWithoutIsPresent")
public class InstallationHistoryActionTest extends WfCoreTestBase {
private Path channelsFile;
diff --git a/integration-tests/src/test/java/org/wildfly/prospero/it/commonapi/InstallationRestoreActionTest.java b/integration-tests/src/test/java/org/wildfly/prospero/it/commonapi/InstallationRestoreActionTest.java
index 4a252ace9..b6a7a6d95 100644
--- a/integration-tests/src/test/java/org/wildfly/prospero/it/commonapi/InstallationRestoreActionTest.java
+++ b/integration-tests/src/test/java/org/wildfly/prospero/it/commonapi/InstallationRestoreActionTest.java
@@ -48,6 +48,7 @@
import static org.junit.Assert.assertEquals;
+@SuppressWarnings("OptionalGetWithoutIsPresent")
public class InstallationRestoreActionTest extends WfCoreTestBase {
private Path restoredServerDir;
diff --git a/integration-tests/src/test/java/org/wildfly/prospero/it/commonapi/SimpleProvisionTest.java b/integration-tests/src/test/java/org/wildfly/prospero/it/commonapi/SimpleProvisionTest.java
index 604f95a4c..c1a18bf6b 100644
--- a/integration-tests/src/test/java/org/wildfly/prospero/it/commonapi/SimpleProvisionTest.java
+++ b/integration-tests/src/test/java/org/wildfly/prospero/it/commonapi/SimpleProvisionTest.java
@@ -55,6 +55,7 @@
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
+@SuppressWarnings("OptionalGetWithoutIsPresent")
public class SimpleProvisionTest extends WfCoreTestBase {
@Test
diff --git a/integration-tests/src/test/java/org/wildfly/prospero/it/commonapi/WfCoreTestBase.java b/integration-tests/src/test/java/org/wildfly/prospero/it/commonapi/WfCoreTestBase.java
index 00a4af95b..7ad776213 100644
--- a/integration-tests/src/test/java/org/wildfly/prospero/it/commonapi/WfCoreTestBase.java
+++ b/integration-tests/src/test/java/org/wildfly/prospero/it/commonapi/WfCoreTestBase.java
@@ -65,6 +65,7 @@
import java.util.zip.ZipEntry;
import java.util.zip.ZipInputStream;
+@SuppressWarnings("OptionalGetWithoutIsPresent")
public class WfCoreTestBase {
public static final String BASE_VERSION = "20.0.0.Beta5";
diff --git a/pom.xml b/pom.xml
index f2ac44b88..0d1e1eb41 100644
--- a/pom.xml
+++ b/pom.xml
@@ -42,7 +42,7 @@
4.4.16
1.8
3.0.2
- 3.16.0
+ 3.21.0
3.1.2
1.9.10
3.6.3
diff --git a/prospero-cli/src/main/java/org/wildfly/prospero/cli/CliConsole.java b/prospero-cli/src/main/java/org/wildfly/prospero/cli/CliConsole.java
index 829a509be..00f924130 100644
--- a/prospero-cli/src/main/java/org/wildfly/prospero/cli/CliConsole.java
+++ b/prospero-cli/src/main/java/org/wildfly/prospero/cli/CliConsole.java
@@ -236,7 +236,7 @@ public InputStream getInput() {
}
public void error(String message, String... args) {
- getErrOut().println(String.format(message, args));
+ getErrOut().println(String.format(message, (Object[]) args));
}
@Override
diff --git a/prospero-cli/src/main/java/org/wildfly/prospero/cli/commands/PrintLicensesCommand.java b/prospero-cli/src/main/java/org/wildfly/prospero/cli/commands/PrintLicensesCommand.java
index 630102f57..28946814b 100644
--- a/prospero-cli/src/main/java/org/wildfly/prospero/cli/commands/PrintLicensesCommand.java
+++ b/prospero-cli/src/main/java/org/wildfly/prospero/cli/commands/PrintLicensesCommand.java
@@ -17,6 +17,7 @@
package org.wildfly.prospero.cli.commands;
+import org.apache.commons.io.FileUtils;
import org.jboss.galleon.config.ProvisioningConfig;
import org.wildfly.channel.Channel;
import org.wildfly.prospero.actions.ProvisioningAction;
@@ -69,7 +70,7 @@ public Integer call() throws Exception {
}
return ReturnCodes.SUCCESS;
} finally {
- tempDirectory.toFile().delete();
+ FileUtils.deleteQuietly(tempDirectory.toFile());
}
}
}
diff --git a/prospero-cli/src/main/java/org/wildfly/prospero/cli/commands/channel/ChannelPromoteCommand.java b/prospero-cli/src/main/java/org/wildfly/prospero/cli/commands/channel/ChannelPromoteCommand.java
index 867c28fc0..e7b1062b8 100644
--- a/prospero-cli/src/main/java/org/wildfly/prospero/cli/commands/channel/ChannelPromoteCommand.java
+++ b/prospero-cli/src/main/java/org/wildfly/prospero/cli/commands/channel/ChannelPromoteCommand.java
@@ -165,7 +165,7 @@ private Optional readSetting(ThrowableFunction {
diff --git a/prospero-cli/src/test/java/org/wildfly/prospero/cli/commands/ApplyUpdateCommandTest.java b/prospero-cli/src/test/java/org/wildfly/prospero/cli/commands/ApplyUpdateCommandTest.java
index 0797188b9..3affb53db 100644
--- a/prospero-cli/src/test/java/org/wildfly/prospero/cli/commands/ApplyUpdateCommandTest.java
+++ b/prospero-cli/src/test/java/org/wildfly/prospero/cli/commands/ApplyUpdateCommandTest.java
@@ -187,7 +187,7 @@ public void testAskForConfirmationIfConflictsPresent() throws Exception {
private Path mockInstallation(String target) throws IOException, MetadataException, XMLStreamException {
final Path targetPath = temp.newFolder(target).toPath();
- MetadataTestUtils.createInstallationMetadata(targetPath);
+ MetadataTestUtils.createInstallationMetadata(targetPath).close();
MetadataTestUtils.createGalleonProvisionedState(targetPath, UpdateCommand.PROSPERO_FP_GA);
new MarkerFile("abcd1234", ApplyCandidateAction.Type.UPDATE).write(targetPath);
diff --git a/prospero-cli/src/test/java/org/wildfly/prospero/cli/commands/InstallCommandTest.java b/prospero-cli/src/test/java/org/wildfly/prospero/cli/commands/InstallCommandTest.java
index dd03ee899..bccdeabb2 100644
--- a/prospero-cli/src/test/java/org/wildfly/prospero/cli/commands/InstallCommandTest.java
+++ b/prospero-cli/src/test/java/org/wildfly/prospero/cli/commands/InstallCommandTest.java
@@ -97,7 +97,7 @@ public void setUp() throws Exception {
public void errorIfTargetPathIsNotPresent() {
int exitCode = commandLine.execute(CliConstants.Commands.INSTALL);
Assert.assertEquals(ReturnCodes.INVALID_ARGUMENTS, exitCode);
- assertTrue(getErrorOutput().contains(String.format("Missing required option: '--dir='",
+ assertTrue(getErrorOutput().contains(String.format("Missing required option: '%s='",
CliConstants.DIR)));
}
@@ -219,19 +219,6 @@ public void fplAndDefinitionAreNotAllowedTogether() throws Exception {
assertEquals(ReturnCodes.INVALID_ARGUMENTS, exitCode);
}
-// @Test
-// public void passChannelReposToProvisionDef() throws Exception {
-// int exitCode = commandLine.execute(CliConstants.Commands.INSTALL, CliConstants.DIR, "test",
-// CliConstants.FPL, KNOWN_FPL, CliConstants.REMOTE_REPOSITORIES, "http://test.repo1,http://test.repo2");
-//
-// assertEquals(ReturnCodes.SUCCESS, exitCode);
-// Mockito.verify(provisionAction).provision(serverDefiniton.capture());
-// assertThat(serverDefiniton.getValue().getRepositories().stream().map(RemoteRepository::getUrl)).contains(
-// "http://test.repo1",
-// "http://test.repo2"
-// );
-// }
-
@Test
public void provisionConfigAndChannelSet() throws IOException {
final File channelsFile = temporaryFolder.newFile();
@@ -263,6 +250,7 @@ public void provisionConfigAndRemoteRepoSet() throws Exception {
.containsOnly("file:/test");
}
+ @SuppressWarnings("unchecked")
@Test
public void passShadowRepositories() throws Exception {
Path channelsFile = temporaryFolder.newFile().toPath();
diff --git a/prospero-cli/src/test/java/org/wildfly/prospero/cli/commands/channel/ChannelInitializeCommandTest.java b/prospero-cli/src/test/java/org/wildfly/prospero/cli/commands/channel/ChannelInitializeCommandTest.java
index e37f13976..4a71e5d35 100644
--- a/prospero-cli/src/test/java/org/wildfly/prospero/cli/commands/channel/ChannelInitializeCommandTest.java
+++ b/prospero-cli/src/test/java/org/wildfly/prospero/cli/commands/channel/ChannelInitializeCommandTest.java
@@ -168,7 +168,7 @@ public void localCustomRepoDirIsWriteProtected() throws Exception {
final Path base = tempFolder.newFolder().toPath();
try {
- base.toFile().setWritable(false);
+ assertTrue("Unable to mark the file as un-writable, failing test", base.toFile().setWritable(false));
final Path repositoryPath = base.resolve("test-dir").resolve("repository");
final String customRepoUrl = repositoryPath.toUri().toURL().toString();
diff --git a/prospero-common/src/main/java/org/wildfly/prospero/ProsperoLogger.java b/prospero-common/src/main/java/org/wildfly/prospero/ProsperoLogger.java
index cb84a3768..a7d685312 100644
--- a/prospero-common/src/main/java/org/wildfly/prospero/ProsperoLogger.java
+++ b/prospero-common/src/main/java/org/wildfly/prospero/ProsperoLogger.java
@@ -217,7 +217,8 @@ public interface ProsperoLogger extends BasicLogger {
MetadataException unableToSaveConfiguration(Path path, @Cause Exception e);
@Message(id = 218, value = "Unable to close the update store.")
- MetadataException unableToCloseStore(@Cause Exception e);
+ @LogMessage(level = Logger.Level.WARN)
+ void unableToCloseStore(@Cause Exception e);
@Message(id = 219, value = "Unable to create history store at [%s]")
MetadataException unableToCreateHistoryStorage(Path path, @Cause Exception e);
diff --git a/prospero-common/src/main/java/org/wildfly/prospero/actions/ApplyCandidateAction.java b/prospero-common/src/main/java/org/wildfly/prospero/actions/ApplyCandidateAction.java
index 1e1b2f0b0..720345347 100644
--- a/prospero-common/src/main/java/org/wildfly/prospero/actions/ApplyCandidateAction.java
+++ b/prospero-common/src/main/java/org/wildfly/prospero/actions/ApplyCandidateAction.java
@@ -201,11 +201,13 @@ public ValidationResult verifyCandidate(Type operation) throws InvalidUpdateCand
final MarkerFile marker = MarkerFile.read(updateDir);
final String hash = marker.getState();
- if (!InstallationMetadata.loadInstallation(installationDir).getRevisions().get(0).getName().equals(hash)) {
- if (ProsperoLogger.ROOT_LOGGER.isDebugEnabled()) {
- ProsperoLogger.ROOT_LOGGER.debugf("The installation state has changed from the candidate [%s].", updateDir);
+ try(InstallationMetadata metadata = InstallationMetadata.loadInstallation(installationDir)) {
+ if (!metadata.getRevisions().get(0).getName().equals(hash)) {
+ if (ProsperoLogger.ROOT_LOGGER.isDebugEnabled()) {
+ ProsperoLogger.ROOT_LOGGER.debugf("The installation state has changed from the candidate [%s].", updateDir);
+ }
+ return ValidationResult.STALE;
}
- return ValidationResult.STALE;
}
if (marker.getOperation() != operation) {
diff --git a/prospero-common/src/main/java/org/wildfly/prospero/actions/InstallationHistoryAction.java b/prospero-common/src/main/java/org/wildfly/prospero/actions/InstallationHistoryAction.java
index 16ced54b4..dd8f03174 100644
--- a/prospero-common/src/main/java/org/wildfly/prospero/actions/InstallationHistoryAction.java
+++ b/prospero-common/src/main/java/org/wildfly/prospero/actions/InstallationHistoryAction.java
@@ -62,8 +62,9 @@ public InstallationChanges compare(SavedState savedState) throws MetadataExcepti
public List getRevisions() throws MetadataException {
ProsperoLogger.ROOT_LOGGER.listHistory(installation);
- final InstallationMetadata installationMetadata = InstallationMetadata.loadInstallation(installation);
- return installationMetadata.getRevisions();
+ try(InstallationMetadata installationMetadata = InstallationMetadata.loadInstallation(installation)) {
+ return installationMetadata.getRevisions();
+ }
}
public void rollback(SavedState savedState, MavenOptions mavenOptions, List overrideRepositories) throws OperationException, ProvisioningException {
@@ -137,7 +138,7 @@ private static void revertCurrentVersions(Path targetDir, InstallationMetadata r
}
private static void verifyStateExists(SavedState savedState, InstallationMetadata metadata) throws MetadataException {
- if (!metadata.getRevisions().stream().filter(s->s.getName().equals(savedState.getName())).findFirst().isPresent()) {
+ if (metadata.getRevisions().stream().noneMatch(s->s.getName().equals(savedState.getName()))) {
throw ProsperoLogger.ROOT_LOGGER.savedStateNotFound(savedState.getName());
}
}
diff --git a/prospero-common/src/main/java/org/wildfly/prospero/actions/MetadataAction.java b/prospero-common/src/main/java/org/wildfly/prospero/actions/MetadataAction.java
index da39bc8a8..2dffe07b8 100644
--- a/prospero-common/src/main/java/org/wildfly/prospero/actions/MetadataAction.java
+++ b/prospero-common/src/main/java/org/wildfly/prospero/actions/MetadataAction.java
@@ -47,7 +47,7 @@ public void addChannel(Channel channel) throws MetadataException {
final ProsperoConfig prosperoConfig = installationMetadata.getProsperoConfig();
final List channels = prosperoConfig.getChannels();
- if (channels.stream().filter(c->c.getName().equals(channel.getName())).findAny().isPresent()) {
+ if (channels.stream().anyMatch(c->c.getName().equals(channel.getName()))) {
ProsperoLogger.ROOT_LOGGER.existingChannel(channel.getName());
throw ProsperoLogger.ROOT_LOGGER.channelExists(channel.getName());
}
@@ -78,7 +78,6 @@ public void changeChannel(String channelName, Channel newChannel) throws Metadat
final List channels = prosperoConfig.getChannels();
final Optional modifiedChannel = channels.stream().filter(c -> c.getName().equals(channelName)).findAny();
if (modifiedChannel.isEmpty()) {
- ProsperoLogger.ROOT_LOGGER.channelNotFound(channelName);
throw ProsperoLogger.ROOT_LOGGER.channelNotFound(channelName);
}
channels.set(channels.indexOf(modifiedChannel.get()), newChannel);
diff --git a/prospero-common/src/main/java/org/wildfly/prospero/api/ArtifactUtils.java b/prospero-common/src/main/java/org/wildfly/prospero/api/ArtifactUtils.java
index c9b5853c2..0dc9d89a3 100644
--- a/prospero-common/src/main/java/org/wildfly/prospero/api/ArtifactUtils.java
+++ b/prospero-common/src/main/java/org/wildfly/prospero/api/ArtifactUtils.java
@@ -83,11 +83,8 @@ public static boolean isValidCoordinate(String gav) {
return false;
}
}
- if (parts.length != 2 && parts.length != 3) { // GA or GAV
- return false;
- }
-
- return true;
+ // GA or GAV
+ return parts.length == 2 || parts.length == 3;
}
public static String printStream(ArtifactCoordinate coord) {
diff --git a/prospero-common/src/main/java/org/wildfly/prospero/api/InstallationMetadata.java b/prospero-common/src/main/java/org/wildfly/prospero/api/InstallationMetadata.java
index 8fbe10bd5..dba9df274 100644
--- a/prospero-common/src/main/java/org/wildfly/prospero/api/InstallationMetadata.java
+++ b/prospero-common/src/main/java/org/wildfly/prospero/api/InstallationMetadata.java
@@ -81,7 +81,7 @@ public static InstallationMetadata loadInstallation(Path base) throws MetadataEx
ChannelManifest manifest;
ProsperoConfig prosperoConfig;
- Optional currentVersion = Optional.empty();
+ Optional currentVersion;
try {
manifest = ManifestYamlSupport.parse(manifestFile.toFile());
@@ -193,7 +193,7 @@ protected InstallationMetadata(Path base, ChannelManifest manifest, ProsperoConf
this.prosperoConfig = new ProsperoConfig(new ArrayList<>(prosperoConfig.getChannels()), prosperoConfig.getMavenOptions());
final List channels = prosperoConfig.getChannels();
- if (channels != null && channels.stream().filter(c-> StringUtils.isEmpty(c.getName())).findAny().isPresent()) {
+ if (channels != null && channels.stream().anyMatch(c-> StringUtils.isEmpty(c.getName()))) {
throw ProsperoLogger.ROOT_LOGGER.emptyChannelName();
}
diff --git a/prospero-common/src/main/java/org/wildfly/prospero/galleon/ChannelMavenArtifactRepositoryManager.java b/prospero-common/src/main/java/org/wildfly/prospero/galleon/ChannelMavenArtifactRepositoryManager.java
index 9a9cb17cb..72ddebfcb 100644
--- a/prospero-common/src/main/java/org/wildfly/prospero/galleon/ChannelMavenArtifactRepositoryManager.java
+++ b/prospero-common/src/main/java/org/wildfly/prospero/galleon/ChannelMavenArtifactRepositoryManager.java
@@ -157,11 +157,7 @@ private org.wildfly.channel.MavenArtifact resolveFromPreparedManifest(MavenArtif
private boolean requiresChannel(MavenArtifact artifact) {
boolean requireChannel = Boolean.parseBoolean(artifact.getMetadata().get(REQUIRE_CHANNEL_FOR_ALL_ARTIFACT));
try {
- if (!requireChannel && ! fpRequireChannel(artifact)) {
- return false;
- } else {
- return true;
- }
+ return requireChannel || fpRequireChannel(artifact);
} catch (Exception e) {
throw new RuntimeException(e);
}
diff --git a/prospero-common/src/main/java/org/wildfly/prospero/galleon/GalleonCallbackAdapter.java b/prospero-common/src/main/java/org/wildfly/prospero/galleon/GalleonCallbackAdapter.java
index 13744e212..137f91355 100644
--- a/prospero-common/src/main/java/org/wildfly/prospero/galleon/GalleonCallbackAdapter.java
+++ b/prospero-common/src/main/java/org/wildfly/prospero/galleon/GalleonCallbackAdapter.java
@@ -21,7 +21,6 @@
import org.jboss.galleon.progresstracking.ProgressTracker;
import org.jboss.galleon.state.ProvisionedConfig;
import org.jboss.galleon.universe.FeaturePackLocation;
-import org.jboss.galleon.universe.maven.MavenArtifact;
import org.wildfly.prospero.ProsperoLogger;
import org.wildfly.prospero.api.Console;
import org.wildfly.prospero.api.ProvisioningProgressEvent;
@@ -127,7 +126,7 @@ public void processing(ProgressTracker