Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow duplicate pids in designates if one is for regular the other for #6052

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -321,6 +321,7 @@ public interface DupPid4 {

}

// this is allowed (no duplicate)
@ObjectClassDefinition(pid = {
"3"
}, factoryPid = {
Expand All @@ -330,13 +331,15 @@ public interface DupPid5 {

}

// this is allowed (no duplicate)
@ObjectClassDefinition(pid = {
"4"
})
public interface DupPid6 {

}

// this is allowed (no duplicate)
@ObjectClassDefinition(factoryPid = {
"4"
})
Expand All @@ -354,7 +357,7 @@ public void testPidCollision() throws Exception {
b.setProperty(Constants.METATYPE_ANNOTATIONS, name.substring(0, name.length() - "1".length()) + "*");
b.build();
System.err.println(b.getErrors());
assertEquals(4, b.getErrors()
assertEquals(2, b.getErrors()
.size());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ public boolean analyzeJar(Analyzer analyzer) throws Exception {

Set<String> ocdIds = new HashSet<>();
Set<String> pids = new HashSet<>();
Set<String> factoryPids = new HashSet<>();

Instructions instructions = new Instructions(header);

Expand Down Expand Up @@ -142,8 +143,10 @@ public boolean analyzeJar(Analyzer analyzer) throws Exception {
analyzer.error("Duplicate OCD id %s from class %s; known ids %s", definition.id, c.getFQN(), ocdIds);
}
for (DesignateDef dDef : definition.designates) {
if (dDef.pid != null && !pids.add(dDef.pid)) {
analyzer.error("Duplicate pid %s from class %s", dDef.pid, c.getFQN());
Set<String> relevantPids = dDef.factory ? factoryPids : pids;
if (dDef.pid != null && !relevantPids.add(dDef.pid)) {
analyzer.error("Duplicate %s from class %s", dDef.factory ? "factoryPid" : "pid", dDef.pid,
c.getFQN());
}
}
String name = "OSGI-INF/metatype/" + analyzer.validResourcePath(definition.id, "Invalid resource name")
Expand Down
Loading