Skip to content

Commit

Permalink
Merge pull request #336 from jfdenise/main
Browse files Browse the repository at this point in the history
Fix randomly failing test
  • Loading branch information
jfdenise authored Dec 8, 2023
2 parents 8609fe3 + 60817dd commit 2d7779d
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 11 deletions.
3 changes: 1 addition & 2 deletions api/src/main/java/org/jboss/galleon/api/GalleonBuilder.java
Original file line number Diff line number Diff line change
Expand Up @@ -276,15 +276,14 @@ static synchronized URLClassLoader getCallerClassLoader(String version, Universe
} else {
RepositoryArtifactResolver repoManager = (RepositoryArtifactResolver) universeResolver.getArtifactResolver(MavenRepoManager.REPOSITORY_ID);
usage = new ClassLoaderUsage();
classLoaders.put(version, usage);
String loc = GALLEON_CORE_GROUP_ID + ":" + GALLEON_CORE_ARTIFACT_ID + ":jar:" + version;
Path path;
try {
path = repoManager.resolve(loc);
} catch (MavenUniverseException ex) {
throw new ProvisioningException(ex);
}

classLoaders.put(version, usage);
URL[] cp = new URL[1];
try {
cp[0] = path.toFile().toURI().toURL();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,9 @@ public void test() throws Exception {
GalleonProvisioningConfig config2 = p.loadProvisioningConfig(prov1);
assertEquals(config, config2);

Provisioning p2 = builder.newProvisioningBuilder().setInstallationHome(installHome).build();
assertEquals(p2.getProvisioningConfig(), config);
try(Provisioning p2 = builder.newProvisioningBuilder().setInstallationHome(installHome).build()) {
assertEquals(p2.getProvisioningConfig(), config);
}
}

assertEquals(APIVersion.getVersion(), builder.getCoreVersion(prov1));
Expand Down
18 changes: 11 additions & 7 deletions api/src/test/java/org/jboss/galleon/api/test/PmTestBase.java
Original file line number Diff line number Diff line change
Expand Up @@ -132,14 +132,18 @@ public void main() throws Throwable {
assertErrors(t, errors);
}
if(pm != null) {
if(isRecordState()) {
assertProvisioningConfig(pm, initialProvisioningConfig);
assertProvisionedState(mgr, initialProvisionedState);
} else if(initialProvisioningConfig != null) {
try {
if (isRecordState()) {
assertProvisioningConfig(pm, initialProvisioningConfig);
assertProvisionedState(mgr, initialProvisionedState);
} else if (initialProvisioningConfig != null) {
pm.close();
pm = getPm();
assertProvisioningConfig(pm, initialProvisioningConfig);
assertProvisionedState(mgr, initialProvisionedState);
}
} finally {
pm.close();
pm = getPm();
assertProvisioningConfig(pm, initialProvisioningConfig);
assertProvisionedState(mgr, initialProvisionedState);
}
}
} finally {
Expand Down

0 comments on commit 2d7779d

Please sign in to comment.