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

support concurrent build in maven plugin #4461

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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ protected AbstractIntegrationTest(String changelogDir, Database dbms) throws Exc
this.pathChangeLog = "changelogs/common/pathChangeLog.xml";
logger = Scope.getCurrentScope().getLog(getClass());

Scope.setScopeManager(new TestScopeManager());
Scope.setScopeManager(new TestScopeManager(Scope.getCurrentScope()));
}

private void openConnection() throws Exception {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,11 @@
@SuppressWarnings("java:S2583")
public abstract class AbstractLiquibaseMojo extends AbstractMojo {

static {
// If maven is called with -T and a value larger than 1, it can get confused under heavy thread load
Scope.setScopeManager( new ThreadLocalScopeManager(null));
}

/**
* Suffix for fields that are representing a default value for a another field.
*/
Expand Down Expand Up @@ -709,8 +714,6 @@ public void execute() throws MojoExecutionException, MojoFailureException {
getLog().warn("Liquibase NOT skipped because file " + skipOnFileExists + " does NOT exists");
}

// If maven is called with -T and a value larger than 1, it can get confused under heavy thread load
Scope.setScopeManager(new ThreadLocalScopeManager());
try {
Scope.child(setUpLogging(), () -> {

Expand Down
14 changes: 0 additions & 14 deletions liquibase-standard/src/main/java/liquibase/Scope.java
Original file line number Diff line number Diff line change
Expand Up @@ -113,21 +113,7 @@ public static Scope getCurrentScope() {
}

public static void setScopeManager(ScopeManager scopeManager) {
Scope currentScope = getCurrentScope();
filipelautert marked this conversation as resolved.
Show resolved Hide resolved
if (currentScope == null) {
currentScope = new Scope();
}

try {
currentScope = scopeManager.init(currentScope);
} catch (Exception e) {
Scope.getCurrentScope().getLog(Scope.class).warning(e.getMessage(), e);
}
scopeManager.setCurrentScope(currentScope);

Scope.scopeManager = scopeManager;


}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,11 @@ public class ThreadLocalScopeManager extends ScopeManager {
private final ThreadLocal<Scope> threadLocalScopes = new ThreadLocal<>();

public ThreadLocalScopeManager() {
this.rootScope = Scope.getCurrentScope();
this(Scope.getCurrentScope());
}

public ThreadLocalScopeManager(Scope rootScope) {
this.rootScope = rootScope;
}

@Override
Expand All @@ -39,4 +43,4 @@ protected Scope init(Scope scope) throws Exception {
}


}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

public abstract class AbstractOutputWriterCommandStep extends AbstractHelperCommandStep implements CleanUpCommandStep {

private static OutputStreamWriter outputStreamWriter;
private OutputStreamWriter outputStreamWriter;
filipelautert marked this conversation as resolved.
Show resolved Hide resolved

@Override
public List<Class<?>> providedDependencies() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,11 @@ public ZipResourceAccessor(Path file) throws FileNotFoundException {
try {
this.fileSystem = FileSystems.getFileSystem(finalUri);
} catch (FileSystemNotFoundException e) {
this.fileSystem = FileSystems.newFileSystem(finalUri, Collections.emptyMap(), Scope.getCurrentScope().getClassLoader());
try {
this.fileSystem = FileSystems.newFileSystem(finalUri, Collections.emptyMap(), Scope.getCurrentScope().getClassLoader());
} catch (FileSystemAlreadyExistsException ex) {
this.fileSystem = FileSystems.getFileSystem(finalUri);
}
}
} catch (Throwable e) {
throw new IllegalArgumentException(e.getMessage(), e);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public abstract class StandardChangeTest extends Specification {
@Shared resourceSupplier = new ResourceSupplier()

def setup() {
Scope.setScopeManager(new TestScopeManager());
Scope.setScopeManager(new TestScopeManager(Scope.getCurrentScope()));
}

def cleanup() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@

public class TestScopeManager extends SingletonScopeManager {

public TestScopeManager() {

public TestScopeManager(Scope scope) throws Exception {
setCurrentScope(init(scope));
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
public abstract class AbstractAntTaskTest {

@BeforeClass
public static void setup() {
Scope.setScopeManager(new TestScopeManager());
public static void setup() throws Exception {
Scope.setScopeManager(new TestScopeManager(Scope.getCurrentScope()));
}

protected static void setProperties() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ public class VerifyChangeClassesTest extends AbstractVerifyTest {


@BeforeClass
public static void setUpClass() {
Scope.setScopeManager(new TestScopeManager());
public static void setUpClass() throws Exception {
Scope.setScopeManager(new TestScopeManager(Scope.getCurrentScope()));
}

@Test
Expand Down