Skip to content

Commit

Permalink
Merge pull request wildfly#6281 from bstansberry/WFCORE-7094
Browse files Browse the repository at this point in the history
[WFCORE-7094] Fix remaining incorrect calls to ModuleIdentifier.getNa…
  • Loading branch information
yersan authored Dec 17, 2024
2 parents 50f4ef5 + a3991b3 commit ebf13df
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -282,8 +282,9 @@ private void installAliases(final ModuleSpecification moduleSpecification, final
ModuleLoader moduleLoader = deploymentUnit.getAttachment(Attachments.SERVICE_MODULE_LOADER);
for (final String aliasName : moduleSpecification.getModuleAliases()) {
final ModuleIdentifier alias = ModuleIdentifier.fromString(aliasName);

final ServiceName moduleSpecServiceName = ServiceModuleLoader.moduleSpecServiceName(alias.toString());
final ModuleSpec spec = ModuleSpec.buildAlias(aliasName, moduleIdentifier.getName()).create();
final ModuleSpec spec = ModuleSpec.buildAlias(aliasName, moduleIdentifier.toString()).create();

HashSet<ModuleDependency> dependencies = new HashSet<>(moduleSpecification.getAllDependencies());
//we need to add the module we are aliasing as a dependency, to make sure that it will be resolved
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,12 +129,12 @@ public class ModuleSpecification extends SimpleAttachable {
private final List<PermissionFactory> permissionFactories = new ArrayList<>();

public void addSystemDependency(final ModuleDependency dependency) {
if (!exclusions.contains(dependency.getIdentifier().getName())) {
if (!exclusions.contains(dependency.getIdentifier().toString())) {
if (systemDependenciesSet.add(dependency)) {
resetDependencyLists();
}
} else {
excludedDependencies.add(dependency.getIdentifier().getName());
excludedDependencies.add(dependency.getIdentifier().toString());
}
}

Expand Down Expand Up @@ -173,12 +173,12 @@ public void removeUserDependencies(final Predicate<ModuleDependency> predicate)
}

public void addLocalDependency(final ModuleDependency dependency) {
if (!exclusions.contains(dependency.getIdentifier().getName())) {
if (!exclusions.contains(dependency.getIdentifier().toString())) {
if (this.localDependenciesSet.add(dependency)) {
resetDependencyLists();
}
} else {
excludedDependencies.add(dependency.getIdentifier().getName());
excludedDependencies.add(dependency.getIdentifier().toString());
}
}

Expand All @@ -205,7 +205,7 @@ public Set<ModuleDependency> getSystemDependenciesSet() {
*/
@Deprecated(forRemoval = true)
public void addExclusion(final ModuleIdentifier exclusion) {
addModuleExclusion(exclusion.getName());
addModuleExclusion(exclusion.toString());
}

/**
Expand All @@ -227,15 +227,15 @@ public void addModuleExclusion(final String exclusion) {
Iterator<ModuleDependency> it = systemDependenciesSet.iterator();
while (it.hasNext()) {
final ModuleDependency dep = it.next();
if (dep.getIdentifier().getName().equals(exclusion)) {
if (dep.getIdentifier().toString().equals(exclusion)) {
it.remove();
resetDependencyLists();
}
}
it = localDependenciesSet.iterator();
while (it.hasNext()) {
final ModuleDependency dep = it.next();
if (dep.getIdentifier().getName().equals(exclusion)) {
if (dep.getIdentifier().toString().equals(exclusion)) {
it.remove();
resetDependencyLists();
}
Expand Down Expand Up @@ -370,7 +370,7 @@ public void setLocalLast(final boolean localLast) {
@Deprecated(forRemoval = true)
@SuppressWarnings("unused")
public void addAlias(final ModuleIdentifier moduleIdentifier) {
addModuleAlias(moduleIdentifier.getName());
addModuleAlias(moduleIdentifier.toString());
}

/**
Expand All @@ -390,7 +390,7 @@ public void addModuleAlias(final String moduleIdentifier) {
@Deprecated(forRemoval = true)
public void addAliases(final Collection<ModuleIdentifier> moduleIdentifiers) {
for (ModuleIdentifier id : moduleIdentifiers) {
addModuleAlias(id.getName());
addModuleAlias(id.toString());
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ private void handleDeployment(final DeploymentPhaseContext phaseContext, final D
}
// No more nested loop
for (ModuleDependency dependency : moduleDependencies) {
String identifier = dependency.getIdentifier().getName();
String identifier = dependency.getIdentifier().toString();
if (index.containsKey(identifier)) {
aliasDependencies.add(new ModuleDependency(dependency.getModuleLoader(), index.get(identifier).getModuleIdentifier(), dependency.isOptional(), dependency.isExport(), dependency.isImportServices(), dependency.isUserSpecified()));
}
Expand All @@ -253,7 +253,7 @@ private void handleDeployment(final DeploymentPhaseContext phaseContext, final D
ModuleAliasChecker.checkModuleAliasesForDependencies(moduleDependencies, MessageContext.JBOSS_DEPLOYMENT_STRUCTURE_CONTEXT, deploymentUnit.getName());
moduleSpec.addUserDependencies(moduleDependencies);
ModuleAliasChecker.checkModuleAliasesForExclusions(rootDeploymentSpecification.getExclusions(), MessageContext.JBOSS_DEPLOYMENT_STRUCTURE_CONTEXT, deploymentUnit.getName());
rootDeploymentSpecification.getExclusions().stream().map(ModuleIdentifier::getName).forEach(moduleSpec::addModuleExclusion);
rootDeploymentSpecification.getExclusions().stream().map(ModuleIdentifier::toString).forEach(moduleSpec::addModuleExclusion);
moduleSpec.addAliases(rootDeploymentSpecification.getAliases());
moduleSpec.addModuleSystemDependencies(rootDeploymentSpecification.getSystemDependencies());
for (final ResourceRoot additionalResourceRoot : rootDeploymentSpecification.getResourceRoots()) {
Expand All @@ -279,7 +279,7 @@ private void handleDeployment(final DeploymentPhaseContext phaseContext, final D
for (final ModuleIdentifier dependency : rootDeploymentSpecification.getAnnotationModules()) {
ModuleIdentifier identifier = dependency;
for (AdditionalModuleSpecification module : additionalModules.values()) {
if (module.getModuleAliases().contains(dependency.getName())) {
if (module.getModuleAliases().contains(dependency.toString())) {
identifier = module.getModuleIdentifier();
break;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public class ModuleSpecificationTestCase {

private static final Set<ModuleDependency> ALL_DEPS = Set.of(DEP_A, DEP_B, DEP_C, DEP_A_FILTERED);

private static final ModuleDependency DEP_D = createModuleDependency("d");
private static final ModuleDependency DEP_D = createModuleDependency("d:aslot");
private static final ModuleDependency DEP_E = createModuleDependency("e");

private static ModuleDependency createModuleDependency(String identifier) {
Expand All @@ -61,11 +61,11 @@ public void testUserDependencyConsistency() {
);

// Removal consistency
ms.removeUserDependencies(md -> md.getIdentifier().getName().equals("a"));
ms.removeUserDependencies(md -> md.getIdentifier().toString().equals("a"));
Set<ModuleDependency> userDepSet = ms.getUserDependenciesSet();
assertEquals(INITIAL_DEPS.size() /* the initials, minus 'a', plus 'd'*/, userDepSet.size());
for (ModuleDependency md : ALL_DEPS) {
boolean shouldFind = !md.getIdentifier().getName().equals("a");
boolean shouldFind = !md.getIdentifier().toString().equals("a");
assertEquals(shouldFind, userDepSet.contains(md));
}
assertTrue(userDepSet.contains(DEP_D));
Expand Down Expand Up @@ -95,12 +95,12 @@ public void testLocalDependencyConsistency() {
public void testModuleAliases() {
ModuleSpecification ms = new ModuleSpecification();
for (ModuleDependency dependency : ALL_DEPS) {
ms.addModuleAlias(dependency.getIdentifier().getName());
ms.addModuleAlias(dependency.getIdentifier().toString());
}
Set<String> aliases = ms.getModuleAliases();
assertEquals(ALL_DEPS.size() - 1, aliases.size());
for (ModuleDependency dep : INITIAL_DEPS) {
assertTrue(dep + " missing", aliases.contains(dep.getIdentifier().getName()));
assertTrue(dep + " missing", aliases.contains(dep.getIdentifier().toString()));
}
}

Expand Down Expand Up @@ -174,7 +174,7 @@ private ModuleSpecification dependencySetConsistencyTest(BiConsumer<ModuleSpecif
}

// Test exclusions are treated as expected
ms.addModuleExclusion(DEP_D.getIdentifier().getName());
ms.addModuleExclusion(DEP_D.getIdentifier().toString());
addConsumer.accept(ms, DEP_D);
depSet = readFunction.apply(ms);
assertEquals(ALL_DEPS.size() + (exclusionsSupported ? 0 : 1), depSet.size());
Expand All @@ -184,9 +184,9 @@ private ModuleSpecification dependencySetConsistencyTest(BiConsumer<ModuleSpecif
}

// Check fictitious exclusion tracking
ms.addModuleExclusion(DEP_E.getIdentifier().getName());
ms.addModuleExclusion(DEP_E.getIdentifier().toString());
Set<String> fictitious = ms.getFictitiousExcludedDependencies();
Set<String> expected = exclusionsSupported ? Set.of(DEP_E.getIdentifier().getName()) : Set.of(DEP_D.getIdentifier().getName(), DEP_E.getIdentifier().getName());
Set<String> expected = exclusionsSupported ? Set.of(DEP_E.getIdentifier().toString()) : Set.of(DEP_D.getIdentifier().toString(), DEP_E.getIdentifier().toString());
assertEquals(expected, fictitious);

return ms;
Expand Down

0 comments on commit ebf13df

Please sign in to comment.