Skip to content
Snippets Groups Projects
Commit 469105fc authored by Nelson Tavares de Sousa's avatar Nelson Tavares de Sousa
Browse files

added a check, if any config instance is executed multiple times

parent 4e9b00b6
No related branches found
No related tags found
No related merge requests found
......@@ -31,6 +31,7 @@ public abstract class Configuration extends AbstractCompositeStage {
private final IExceptionListenerFactory<?> factory;
private final ConfigurationContext context;
private boolean initialized;
private boolean executed;
private Stage startStage;
......@@ -43,11 +44,19 @@ public abstract class Configuration extends AbstractCompositeStage {
this.context = new ConfigurationContext(this);
}
boolean isExecuted() {
boolean isInitialized() {
return initialized;
}
void setInitialized(final boolean executed) {
this.initialized = executed;
}
public boolean isExecuted() {
return executed;
}
void setExecuted(final boolean executed) {
public void setExecuted(final boolean executed) {
this.executed = executed;
}
......
......@@ -62,10 +62,10 @@ public final class Execution<T extends Configuration> {
public Execution(final T configuration, final boolean validationEnabled) {
this.configuration = configuration;
this.configurationContext = configuration.getContext();
if (configuration.isExecuted()) {
if (configuration.isInitialized()) {
throw new IllegalStateException("Configuration was already executed");
}
configuration.setExecuted(true);
configuration.setInitialized(true);
if (validationEnabled) {
validateStages();
}
......@@ -133,6 +133,10 @@ public final class Execution<T extends Configuration> {
* @since 2.0
*/
public void executeNonBlocking() {
if (configuration.isExecuted()) {
throw new IllegalStateException("Any configuration instance may only be executed once.");
}
configuration.setExecuted(true);
configurationContext.executeConfiguration();
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment