From bd573f668c5c06dc3a09adad18973f9dbce749f8 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 | 7 +++++-- 1 file changed, 5 insertions(+), 2 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..3224ba1bc63 100644 --- a/biz.aQute.bndlib/src/aQute/bnd/metatype/MetatypeAnnotations.java +++ b/biz.aQute.bndlib/src/aQute/bnd/metatype/MetatypeAnnotations.java @@ -105,6 +105,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 +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 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")