Skip to content

Commit

Permalink
Allow duplicate pids in designates if one is for regular the other for
Browse files Browse the repository at this point in the history
factory pid

This closes bndtools#6042

Signed-off-by: Konrad Windszus <kwin@apache.org>
  • Loading branch information
kwin committed Mar 15, 2024
1 parent c951830 commit fda6700
Showing 1 changed file with 5 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
import java.util.Map;
import java.util.Set;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import aQute.bnd.component.TagResource;
Expand Down Expand Up @@ -105,6 +104,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 +142,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

0 comments on commit fda6700

Please sign in to comment.