karaf-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jean-Baptiste Onofré (Jira) <j...@apache.org>
Subject [jira] [Updated] (KARAF-6386) Race condition in initialization of Activators (Port already in use: 1099)
Date Mon, 26 Aug 2019 05:24:00 GMT

     [ https://issues.apache.org/jira/browse/KARAF-6386?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]

Jean-Baptiste Onofré updated KARAF-6386:
----------------------------------------
    Component/s: karaf

> Race condition in initialization of Activators (Port already in use: 1099)
> --------------------------------------------------------------------------
>
>                 Key: KARAF-6386
>                 URL: https://issues.apache.org/jira/browse/KARAF-6386
>             Project: Karaf
>          Issue Type: Bug
>          Components: karaf
>            Reporter: Xtra Coder
>            Assignee: Jean-Baptiste Onofré
>            Priority: Major
>
> Recently I came across the problem mentioned in KARAF-5054 (at startup - Port already
in use: 1099 - whereas another port is specified in configuration)
>  After digging through debugger - I see this is indeed a "race condition" issue - Activator's
doStart() in one thread happens before "CM Configuration Updater" thread reaches to the same
activator and provides appropriate properties. And it may affect other activators.
> The bug as i see it - SomeActivator.doStart() do not ensure startup configuration is
loaded before start, however all need environment is already available. I've fixed this for
myself in the following way. Please apply to sources if it seems appropriate:
> 1. Add this method into org/apache/karaf/util/tracker/BaseActivator.java
> {code:java}
>     protected boolean ensureStartupConfiguration(String configId) throws IOException
{
>         if (this.configuration != null) {
>             return true;
>         }
>         ConfigurationAdmin configurationAdmin = getTrackedService(ConfigurationAdmin.class);
>         if (configurationAdmin != null) {
>             Configuration configuration = configurationAdmin.getConfiguration(configId);
>             Dictionary<String, Object> properties = (configuration == null) ? null
: configuration.getProperties();
>             if (properties != null) {
>                 this.configuration = properties;
>                 return true;
>             }
>         }
>         // Since logging may not get initialized - let's spam directly to console
>         System.out.println("No startup configuration for: " + configId);
>         return false;
>     }
> {code}
> 2. Add following initialization line ... 
> {code:java}
>     protected void doStart() throws Exception {
>         // Verify dependencies
>         ConfigurationAdmin configurationAdmin = ...
>         if (!ensureStartupConfiguration("org.apache.karaf.management")) {
>             return;
>         }
> {code}
> ... into affected activators. Here is the list I've got in my environment:
> {code:java}
> org.apache.karaf.jaas.modules.impl.Activator - CM Configuration Updater (ManagedService
Update: pid=[org.apache.karaf.jaas]):
>   file:/.../etc/org.apache.karaf.jaas.cfg
> org.apache.karaf.kar.internal.osgi.Activator - CM Configuration Updater (ManagedService
Update: pid=[org.apache.karaf.kar]):
>   file:/.../etc/org.apache.karaf.kar.cfg
> org.apache.karaf.log.core.internal.osgi.Activator - CM Configuration Updater (ManagedService
Update: pid=[org.apache.karaf.log]):
>   file:/.../etc/org.apache.karaf.log.cfg
> org.apache.karaf.management.internal.Activator - CM Configuration Updater (ManagedService
Update: pid=[org.apache.karaf.management]):
>   file:/.../etc/org.apache.karaf.management.cfg
> org.apache.karaf.shell.ssh.Activator - CM Configuration Updater (ManagedService Update:
pid=[org.apache.karaf.shell]):
>   file:/.../etc/org.apache.karaf.shell.cfg
> {code}



--
This message was sent by Atlassian Jira
(v8.3.2#803003)

Mime
View raw message