Skip to content

Commit ebf13df

Browse files
authored
Merge pull request wildfly#6281 from bstansberry/WFCORE-7094
[WFCORE-7094] Fix remaining incorrect calls to ModuleIdentifier.getNa…
2 parents 50f4ef5 + a3991b3 commit ebf13df

File tree

4 files changed

+22
-21
lines changed

4 files changed

+22
-21
lines changed

server/src/main/java/org/jboss/as/server/deployment/module/ModuleSpecProcessor.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -282,8 +282,9 @@ private void installAliases(final ModuleSpecification moduleSpecification, final
282282
ModuleLoader moduleLoader = deploymentUnit.getAttachment(Attachments.SERVICE_MODULE_LOADER);
283283
for (final String aliasName : moduleSpecification.getModuleAliases()) {
284284
final ModuleIdentifier alias = ModuleIdentifier.fromString(aliasName);
285+
285286
final ServiceName moduleSpecServiceName = ServiceModuleLoader.moduleSpecServiceName(alias.toString());
286-
final ModuleSpec spec = ModuleSpec.buildAlias(aliasName, moduleIdentifier.getName()).create();
287+
final ModuleSpec spec = ModuleSpec.buildAlias(aliasName, moduleIdentifier.toString()).create();
287288

288289
HashSet<ModuleDependency> dependencies = new HashSet<>(moduleSpecification.getAllDependencies());
289290
//we need to add the module we are aliasing as a dependency, to make sure that it will be resolved

server/src/main/java/org/jboss/as/server/deployment/module/ModuleSpecification.java

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -129,12 +129,12 @@ public class ModuleSpecification extends SimpleAttachable {
129129
private final List<PermissionFactory> permissionFactories = new ArrayList<>();
130130

131131
public void addSystemDependency(final ModuleDependency dependency) {
132-
if (!exclusions.contains(dependency.getIdentifier().getName())) {
132+
if (!exclusions.contains(dependency.getIdentifier().toString())) {
133133
if (systemDependenciesSet.add(dependency)) {
134134
resetDependencyLists();
135135
}
136136
} else {
137-
excludedDependencies.add(dependency.getIdentifier().getName());
137+
excludedDependencies.add(dependency.getIdentifier().toString());
138138
}
139139
}
140140

@@ -173,12 +173,12 @@ public void removeUserDependencies(final Predicate<ModuleDependency> predicate)
173173
}
174174

175175
public void addLocalDependency(final ModuleDependency dependency) {
176-
if (!exclusions.contains(dependency.getIdentifier().getName())) {
176+
if (!exclusions.contains(dependency.getIdentifier().toString())) {
177177
if (this.localDependenciesSet.add(dependency)) {
178178
resetDependencyLists();
179179
}
180180
} else {
181-
excludedDependencies.add(dependency.getIdentifier().getName());
181+
excludedDependencies.add(dependency.getIdentifier().toString());
182182
}
183183
}
184184

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

211211
/**
@@ -227,15 +227,15 @@ public void addModuleExclusion(final String exclusion) {
227227
Iterator<ModuleDependency> it = systemDependenciesSet.iterator();
228228
while (it.hasNext()) {
229229
final ModuleDependency dep = it.next();
230-
if (dep.getIdentifier().getName().equals(exclusion)) {
230+
if (dep.getIdentifier().toString().equals(exclusion)) {
231231
it.remove();
232232
resetDependencyLists();
233233
}
234234
}
235235
it = localDependenciesSet.iterator();
236236
while (it.hasNext()) {
237237
final ModuleDependency dep = it.next();
238-
if (dep.getIdentifier().getName().equals(exclusion)) {
238+
if (dep.getIdentifier().toString().equals(exclusion)) {
239239
it.remove();
240240
resetDependencyLists();
241241
}
@@ -370,7 +370,7 @@ public void setLocalLast(final boolean localLast) {
370370
@Deprecated(forRemoval = true)
371371
@SuppressWarnings("unused")
372372
public void addAlias(final ModuleIdentifier moduleIdentifier) {
373-
addModuleAlias(moduleIdentifier.getName());
373+
addModuleAlias(moduleIdentifier.toString());
374374
}
375375

376376
/**
@@ -390,7 +390,7 @@ public void addModuleAlias(final String moduleIdentifier) {
390390
@Deprecated(forRemoval = true)
391391
public void addAliases(final Collection<ModuleIdentifier> moduleIdentifiers) {
392392
for (ModuleIdentifier id : moduleIdentifiers) {
393-
addModuleAlias(id.getName());
393+
addModuleAlias(id.toString());
394394
}
395395
}
396396

server/src/main/java/org/jboss/as/server/deployment/module/descriptor/DeploymentStructureDescriptorParser.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,7 @@ private void handleDeployment(final DeploymentPhaseContext phaseContext, final D
244244
}
245245
// No more nested loop
246246
for (ModuleDependency dependency : moduleDependencies) {
247-
String identifier = dependency.getIdentifier().getName();
247+
String identifier = dependency.getIdentifier().toString();
248248
if (index.containsKey(identifier)) {
249249
aliasDependencies.add(new ModuleDependency(dependency.getModuleLoader(), index.get(identifier).getModuleIdentifier(), dependency.isOptional(), dependency.isExport(), dependency.isImportServices(), dependency.isUserSpecified()));
250250
}
@@ -253,7 +253,7 @@ private void handleDeployment(final DeploymentPhaseContext phaseContext, final D
253253
ModuleAliasChecker.checkModuleAliasesForDependencies(moduleDependencies, MessageContext.JBOSS_DEPLOYMENT_STRUCTURE_CONTEXT, deploymentUnit.getName());
254254
moduleSpec.addUserDependencies(moduleDependencies);
255255
ModuleAliasChecker.checkModuleAliasesForExclusions(rootDeploymentSpecification.getExclusions(), MessageContext.JBOSS_DEPLOYMENT_STRUCTURE_CONTEXT, deploymentUnit.getName());
256-
rootDeploymentSpecification.getExclusions().stream().map(ModuleIdentifier::getName).forEach(moduleSpec::addModuleExclusion);
256+
rootDeploymentSpecification.getExclusions().stream().map(ModuleIdentifier::toString).forEach(moduleSpec::addModuleExclusion);
257257
moduleSpec.addAliases(rootDeploymentSpecification.getAliases());
258258
moduleSpec.addModuleSystemDependencies(rootDeploymentSpecification.getSystemDependencies());
259259
for (final ResourceRoot additionalResourceRoot : rootDeploymentSpecification.getResourceRoots()) {
@@ -279,7 +279,7 @@ private void handleDeployment(final DeploymentPhaseContext phaseContext, final D
279279
for (final ModuleIdentifier dependency : rootDeploymentSpecification.getAnnotationModules()) {
280280
ModuleIdentifier identifier = dependency;
281281
for (AdditionalModuleSpecification module : additionalModules.values()) {
282-
if (module.getModuleAliases().contains(dependency.getName())) {
282+
if (module.getModuleAliases().contains(dependency.toString())) {
283283
identifier = module.getModuleIdentifier();
284284
break;
285285
}

server/src/test/java/org/jboss/as/server/deployment/module/ModuleSpecificationTestCase.java

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ public class ModuleSpecificationTestCase {
3636

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

39-
private static final ModuleDependency DEP_D = createModuleDependency("d");
39+
private static final ModuleDependency DEP_D = createModuleDependency("d:aslot");
4040
private static final ModuleDependency DEP_E = createModuleDependency("e");
4141

4242
private static ModuleDependency createModuleDependency(String identifier) {
@@ -61,11 +61,11 @@ public void testUserDependencyConsistency() {
6161
);
6262

6363
// Removal consistency
64-
ms.removeUserDependencies(md -> md.getIdentifier().getName().equals("a"));
64+
ms.removeUserDependencies(md -> md.getIdentifier().toString().equals("a"));
6565
Set<ModuleDependency> userDepSet = ms.getUserDependenciesSet();
6666
assertEquals(INITIAL_DEPS.size() /* the initials, minus 'a', plus 'd'*/, userDepSet.size());
6767
for (ModuleDependency md : ALL_DEPS) {
68-
boolean shouldFind = !md.getIdentifier().getName().equals("a");
68+
boolean shouldFind = !md.getIdentifier().toString().equals("a");
6969
assertEquals(shouldFind, userDepSet.contains(md));
7070
}
7171
assertTrue(userDepSet.contains(DEP_D));
@@ -95,12 +95,12 @@ public void testLocalDependencyConsistency() {
9595
public void testModuleAliases() {
9696
ModuleSpecification ms = new ModuleSpecification();
9797
for (ModuleDependency dependency : ALL_DEPS) {
98-
ms.addModuleAlias(dependency.getIdentifier().getName());
98+
ms.addModuleAlias(dependency.getIdentifier().toString());
9999
}
100100
Set<String> aliases = ms.getModuleAliases();
101101
assertEquals(ALL_DEPS.size() - 1, aliases.size());
102102
for (ModuleDependency dep : INITIAL_DEPS) {
103-
assertTrue(dep + " missing", aliases.contains(dep.getIdentifier().getName()));
103+
assertTrue(dep + " missing", aliases.contains(dep.getIdentifier().toString()));
104104
}
105105
}
106106

@@ -174,7 +174,7 @@ private ModuleSpecification dependencySetConsistencyTest(BiConsumer<ModuleSpecif
174174
}
175175

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

186186
// Check fictitious exclusion tracking
187-
ms.addModuleExclusion(DEP_E.getIdentifier().getName());
187+
ms.addModuleExclusion(DEP_E.getIdentifier().toString());
188188
Set<String> fictitious = ms.getFictitiousExcludedDependencies();
189-
Set<String> expected = exclusionsSupported ? Set.of(DEP_E.getIdentifier().getName()) : Set.of(DEP_D.getIdentifier().getName(), DEP_E.getIdentifier().getName());
189+
Set<String> expected = exclusionsSupported ? Set.of(DEP_E.getIdentifier().toString()) : Set.of(DEP_D.getIdentifier().toString(), DEP_E.getIdentifier().toString());
190190
assertEquals(expected, fictitious);
191191

192192
return ms;

0 commit comments

Comments
 (0)