Skip to content

Commit

Permalink
Fail when creating a Scope with a null-parent #1354.
Browse files Browse the repository at this point in the history
- Prevent subsequent lookup of values in the parent-scope, from failing.
- In case of failure: Preserve stack trace to uncover root cause.
  • Loading branch information
Max Hohenegger committed Sep 3, 2020
1 parent 99e76ca commit ed15ba7
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions liquibase-core/src/main/java/liquibase/Scope.java
Expand Up @@ -4,7 +4,6 @@
import liquibase.database.DatabaseConnection;
import liquibase.database.OfflineConnection;
import liquibase.database.jvm.JdbcConnection;
import liquibase.diff.output.changelog.DiffToChangeLog;
import liquibase.exception.UnexpectedLiquibaseException;
import liquibase.listener.LiquibaseListener;
import liquibase.logging.LogService;
Expand All @@ -23,6 +22,8 @@
import java.nio.charset.Charset;
import java.util.*;

import static java.util.Objects.requireNonNull;

/**
* This scope object is used to hold configuration and other parameters within a call without needing complex method signatures.
* It also allows new parameters to be added by extensions without affecting standard method signatures.
Expand Down Expand Up @@ -114,8 +115,12 @@ private Scope() {
values.put(Attr.ui.name(), new ConsoleUIService());
}

/**
* @param parent The new Scopes parent in the hierarchy of Scopes, not null.
* @param scopeValues The values for the new Scope.
*/
protected Scope(Scope parent, Map<String, Object> scopeValues) {
this.parent = parent;
this.parent = requireNonNull(parent, "A 'null' parent would detach this scope from the hierarchy.");
if (scopeValues != null) {
for (Map.Entry<String, Object> entry : scopeValues.entrySet()) {
values.put(entry.getKey(), entry.getValue());
Expand Down

0 comments on commit ed15ba7

Please sign in to comment.