From fda670053c24a57c15f780bec89b05912849d6fc Mon Sep 17 00:00:00 2001 From: Konrad Windszus Date: Fri, 15 Mar 2024 12:44:35 +0100 Subject: [PATCH] Allow duplicate pids in designates if one is for regular the other for factory pid This closes #6042 Signed-off-by: Konrad Windszus --- .../src/aQute/bnd/metatype/MetatypeAnnotations.java | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/biz.aQute.bndlib/src/aQute/bnd/metatype/MetatypeAnnotations.java b/biz.aQute.bndlib/src/aQute/bnd/metatype/MetatypeAnnotations.java index 7aaa3614566..dce18aa448c 100644 --- a/biz.aQute.bndlib/src/aQute/bnd/metatype/MetatypeAnnotations.java +++ b/biz.aQute.bndlib/src/aQute/bnd/metatype/MetatypeAnnotations.java @@ -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; @@ -105,6 +104,7 @@ public boolean analyzeJar(Analyzer analyzer) throws Exception { Set ocdIds = new HashSet<>(); Set pids = new HashSet<>(); + Set factoryPids = new HashSet<>(); Instructions instructions = new Instructions(header); @@ -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 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")