Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

application install may deadlock in cluster #7925 #7928

Merged
merged 1 commit into from
Mar 9, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import java.util.concurrent.ConcurrentMap;
import java.util.concurrent.CopyOnWriteArrayList;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;

import org.osgi.framework.Bundle;
import org.osgi.framework.BundleContext;
Expand Down Expand Up @@ -308,13 +309,24 @@ public Configuration getConfig()
LOG.debug( "Waiting for app {}", application.getKey() );
}
}
latch.await();
final boolean releasedNormally = latch.await( 10, TimeUnit.SECONDS );
latch.countDown(); //release all waiting threads even if released by timeout

if ( !releasedNormally )
{
LOG.warn( "App {} was not configured properly", application.getKey() );
}

if ( awaitWillLock && LOG.isDebugEnabled() )
{
LOG.debug( Thread.currentThread().getName() + " Finished waiting for app {}", application.getKey() );
}
return application.getConfig();
final Configuration config = application.getConfig();
if ( config == null )
{
throw new RuntimeException( "App was not fully configured" );
}
return config;
}
catch ( InterruptedException e )
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
import java.util.Dictionary;

import org.osgi.service.cm.ManagedService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.enonic.xp.app.ApplicationKey;
import com.enonic.xp.config.ConfigBuilder;
Expand All @@ -12,6 +14,8 @@
final class ApplicationConfigReloader
implements ManagedService
{
private final static Logger LOG = LoggerFactory.getLogger( ApplicationConfigReloader.class );

private static final Configuration EMPTY_CONFIG = ConfigBuilder.create().build();

private final ApplicationKey key;
Expand All @@ -27,6 +31,8 @@ final class ApplicationConfigReloader
@Override
public void updated( final Dictionary<String, ?> properties )
{
LOG.info( "Configuring application {}", this.key );

this.applicationConfigService.setConfiguration( this.key, properties == null ? EMPTY_CONFIG : ConfigBuilder.create().
addAll( properties ).build() );
}
Expand Down