Skip to content

Commit

Permalink
[JENKINS-39169] fixed circular dependency warning on startup
Browse files Browse the repository at this point in the history
  • Loading branch information
cpoenisch committed Oct 21, 2016
1 parent a976cf4 commit 5313443
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 5 deletions.
15 changes: 15 additions & 0 deletions src/main/java/de/tracetronic/jenkins/plugins/ecutest/ETPlugin.java
Expand Up @@ -38,6 +38,8 @@

import org.apache.commons.lang.builder.HashCodeBuilder;

import de.tracetronic.jenkins.plugins.ecutest.report.atx.ATXPublisher.DescriptorImpl;

/**
* Main entry point to this plugin for the {@link Jenkins} instance.
*
Expand Down Expand Up @@ -188,4 +190,17 @@ public static ToolVersion parse(final String version) throws IllegalArgumentExce
return new ToolVersion(major, minor, micro, qualifier);
}
}

@Override
public void postInitialize() throws Exception {
super.postInitialize();
final Jenkins instance = Jenkins.getInstance();
if (instance != null) {
// Synchronize current ATX configuration with the default one.
final DescriptorImpl descriptor = instance.getDescriptorByType(DescriptorImpl.class);
if (descriptor != null) {
descriptor.syncWithDefaultConfig();
}
}
}
}
Expand Up @@ -237,7 +237,7 @@ public void performReport(final Run<?, ?> run, final FilePath workspace, final L
*/
private boolean publishReports(final ATXInstallation installation, final Run<?, ?> run,
final Launcher launcher, final TaskListener listener)
throws IOException, InterruptedException {
throws IOException, InterruptedException {
final TTConsoleLogger logger = new TTConsoleLogger(listener);
final boolean isUploadEnabled = isUploadEnabled(installation);
final boolean isServerReachable = isServerReachable(installation, launcher, run.getEnvironment(listener));
Expand Down Expand Up @@ -373,15 +373,13 @@ public static class DescriptorImpl extends AbstractReportDescriptor {
private final transient ATXValidator atxValidator;

/**
* Instantiates a new {@link DescriptorImpl} and synchronizes
* the current ATX configuration with the default one.
* Instantiates a new {@link DescriptorImpl}.
*/
public DescriptorImpl() {
super();
load();
atxValidator = new ATXValidator();
defaultConfig = new ATXConfig();
syncWithDefaultConfig();
}

/**
Expand Down Expand Up @@ -461,9 +459,12 @@ public boolean configure(final StaplerRequest req, final JSONObject json) {
/**
* Synchronizes current ATX configuration with default configuration
* by overriding their current values and saving them as new ATX installation.
*
* This method will be automatically called by {@link ETPlugin#postInitialize()} to
* avoid circular dependencies while loading other plugins.
*/
@SuppressWarnings("unchecked")
private void syncWithDefaultConfig() {
public void syncWithDefaultConfig() {
final List<ATXInstallation> list = new ArrayList<ATXInstallation>();
for (final ATXInstallation installation : installations.clone()) {
final ATXConfig currentConfig = installation.getConfig();
Expand Down

0 comments on commit 5313443

Please sign in to comment.