From 35c3bdfc96a732aac1d2a5335461d786b4661f05 Mon Sep 17 00:00:00 2001 From: Zac Spitzer Date: Thu, 12 Mar 2026 17:06:01 +1100 Subject: [PATCH] LDEV-6145 - do not rename bundle JAR if Felix already has it registered at that path --- .../main/java/lucee/runtime/osgi/OSGiUtil.java | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/core/src/main/java/lucee/runtime/osgi/OSGiUtil.java b/core/src/main/java/lucee/runtime/osgi/OSGiUtil.java index 9daf5382cba..2ddddfc7a87 100644 --- a/core/src/main/java/lucee/runtime/osgi/OSGiUtil.java +++ b/core/src/main/java/lucee/runtime/osgi/OSGiUtil.java @@ -1194,6 +1194,22 @@ private static BundleFile improveFileName(File bundlDirectory, BundleFile bf) { String preferedName = bf.getSymbolicName() + "-" + bf.getVersionAsString() + ".jar"; if (!preferedName.equals(f.getName())) { + // LDEV-6145: do not rename if Felix already has this bundle registered at the current path. + // Renaming without updating Felix leaves the cache pointing at the old (now missing) path, + // causing "Bundle symbolic name and version are not unique" on the next restart. + try { + BundleContext bc = CFMLEngineFactory.getInstance().getBundleContext(); + if (bc != null) { + String location = f.getAbsolutePath(); + for (Bundle b: bc.getBundles()) { + if (location.equals(b.getLocation())) return bf; + } + } + } + catch (Exception e) { + // engine not yet started; safe to rename + } + try { File nf = new File(f.getParentFile(), preferedName); if (f.renameTo(nf)) {