This is an automated email from the ASF dual-hosted git repository.

jbonofre pushed a commit to branch 
dependabot/maven/main/org.eclipse.platform-org.eclipse.osgi-3.24.100
in repository https://gitbox.apache.org/repos/asf/karaf.git


The following commit(s) were added to 
refs/heads/dependabot/maven/main/org.eclipse.platform-org.eclipse.osgi-3.24.100 
by this push:
     new 009204941c Fix framework factory loading to skip comments in service 
loader files
009204941c is described below

commit 009204941ce0951042beae2f9d28070b67a5e1f8
Author: JB Onofré <[email protected]>
AuthorDate: Sun Mar 15 17:26:40 2026 +0100

    Fix framework factory loading to skip comments in service loader files
    
    The loadFrameworkFactory() method reads 
META-INF/services/org.osgi.framework.launch.FrameworkFactory
    to discover the framework factory class. It was reading only the first 
line, but the Java ServiceLoader
    specification allows comment lines starting with '#'. Equinox 3.24.100 now 
includes a '# Generated by bnd'
    comment, causing a ClassNotFoundException and preventing the framework from 
starting.
---
 main/src/main/java/org/apache/karaf/main/Main.java | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/main/src/main/java/org/apache/karaf/main/Main.java 
b/main/src/main/java/org/apache/karaf/main/Main.java
index 0793861883..2fe5717216 100644
--- a/main/src/main/java/org/apache/karaf/main/Main.java
+++ b/main/src/main/java/org/apache/karaf/main/Main.java
@@ -537,7 +537,14 @@ public class Main {
         if (factoryClass == null) {
             InputStream is = 
classLoader.getResourceAsStream("META-INF/services/" + 
FrameworkFactory.class.getName());
             BufferedReader br = new BufferedReader(new InputStreamReader(is, 
StandardCharsets.UTF_8));
-            factoryClass = br.readLine();
+            String line;
+            while ((line = br.readLine()) != null) {
+                line = line.trim();
+                if (!line.isEmpty() && !line.startsWith("#")) {
+                    factoryClass = line;
+                    break;
+                }
+            }
             br.close();
         }
         FrameworkFactory factory = (FrameworkFactory) 
classLoader.loadClass(factoryClass).newInstance();

Reply via email to