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

Make thread safe #1786

Merged
merged 3 commits into from
Jan 18, 2024
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
2 changes: 1 addition & 1 deletion liberty-maven-plugin/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@
<dependency>
<groupId>io.openliberty.tools</groupId>
<artifactId>ci.common</artifactId>
<version>1.8.30</version>
<version>1.8.31-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.twdata.maven</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,10 @@ protected static void runProcess(String processCommand) throws IOException, Inte
writer = new BufferedWriter(new OutputStreamWriter(stdin));
// wait for process to finish max 20 seconds
process.waitFor(20, TimeUnit.SECONDS);
assertFalse(process.isAlive());
if (process.isAlive()) {
process.waitFor(20, TimeUnit.SECONDS);
}
assertFalse("The process for command "+command+" did not finish in 40 seconds.", process.isAlive());

// save and print process output
Path path = logFile.toPath();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* (C) Copyright IBM Corporation 2014, 2023.
* (C) Copyright IBM Corporation 2014, 2024.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -35,7 +35,6 @@
import io.openliberty.tools.maven.utils.SpringBootUtil;
import io.openliberty.tools.common.plugins.config.ApplicationXmlDocument;
import io.openliberty.tools.common.plugins.config.LooseConfigData;
import io.openliberty.tools.common.plugins.config.ServerConfigDocument;
import io.openliberty.tools.common.plugins.util.DevUtil;

/**
Expand All @@ -45,7 +44,7 @@
* dependencies with scope compile + system + runtime.
* Provided scope transitive dependencies are not included by default (built-in maven behavior).
*/
@Mojo(name = "deploy", requiresDependencyResolution = ResolutionScope.COMPILE_PLUS_RUNTIME)
@Mojo(name = "deploy", requiresDependencyResolution = ResolutionScope.COMPILE_PLUS_RUNTIME, threadSafe = true)
public class DeployMojo extends DeployMojoSupport {

@Override
Expand Down Expand Up @@ -304,7 +303,7 @@ private static LooseConfigData createLooseConfigData() throws MojoExecutionExcep
private void cleanupPreviousExecution() {
if (ApplicationXmlDocument.getApplicationXmlFile(serverDirectory).exists()) {
ApplicationXmlDocument.getApplicationXmlFile(serverDirectory).delete();
ServerConfigDocument.markInstanceStale();
scd = null; // force reinitialization of ServerConfigDocument
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* (C) Copyright IBM Corporation 2016, 2023.
* (C) Copyright IBM Corporation 2016, 2024.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -44,12 +44,8 @@
import io.openliberty.tools.common.plugins.config.ApplicationXmlDocument;
import io.openliberty.tools.common.plugins.config.LooseApplication;
import io.openliberty.tools.common.plugins.config.LooseConfigData;
import io.openliberty.tools.common.plugins.config.ServerConfigDocument;
import io.openliberty.tools.common.plugins.util.DevUtil;
import io.openliberty.tools.common.plugins.util.InstallFeatureUtil;
import io.openliberty.tools.common.plugins.util.InstallFeatureUtil.ProductProperties;
import io.openliberty.tools.common.plugins.util.OSUtil;
import io.openliberty.tools.common.plugins.util.PluginExecutionException;

/**
* Support for installing and deploying applications to a Liberty server.
Expand Down Expand Up @@ -317,13 +313,13 @@ protected void verifyAppStarted(String appFile) throws MojoExecutionException {

try {
Map<String, File> libertyDirPropertyFiles = getLibertyDirectoryPropertyFiles();
CommonLogger logger = CommonLogger.getInstance(getLog());
CommonLogger logger = new CommonLogger(getLog());
setLog(logger.getLog());
ServerConfigDocument.getInstance(logger, serverXML, configDirectory,
getServerConfigDocument(logger, serverXML, configDirectory,
bootstrapPropertiesFile, combinedBootstrapProperties, serverEnvFile, false, libertyDirPropertyFiles);

//appName will be set to a name derived from appFile if no name can be found.
appName = ServerConfigDocument.findNameForLocation(appFile);
appName = scd.findNameForLocation(appFile);
} catch (Exception e) {
getLog().warn(e.getLocalizedMessage());
getLog().debug(e);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* (C) Copyright IBM Corporation 2017, 2023.
* (C) Copyright IBM Corporation 2017, 2024.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -27,7 +27,7 @@
/**
* Display an application URL in the default browser.
*/
@Mojo(name = "display-url")
@Mojo(name = "display-url", threadSafe = true)
public class DisplayUrlMojo extends AbstractMojo {

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* (C) Copyright IBM Corporation 2014, 2023.
* (C) Copyright IBM Corporation 2014, 2024.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -27,14 +27,13 @@
import org.apache.maven.project.MavenProject;

import io.openliberty.tools.ant.ServerTask;
import io.openliberty.tools.common.plugins.config.ServerConfigDocument;
import io.openliberty.tools.maven.utils.CommonLogger;

/**
* Undeploy application from liberty server. If no parameters have been defined
* the mojo will undeploy all applications from the server.
*/
@Mojo(name = "undeploy", requiresDependencyResolution = ResolutionScope.COMPILE_PLUS_RUNTIME)
@Mojo(name = "undeploy", requiresDependencyResolution = ResolutionScope.COMPILE_PLUS_RUNTIME, threadSafe = true)

public class UndeployAppMojo extends DeployMojoSupport {

Expand Down Expand Up @@ -135,13 +134,13 @@ protected void undeployApp(File file) throws MojoExecutionException {
File serverXML = new File(serverDirectory.getCanonicalPath(), "server.xml");

Map<String, File> libertyDirPropertyFiles = getLibertyDirectoryPropertyFiles();
CommonLogger logger = CommonLogger.getInstance(getLog());
CommonLogger logger = new CommonLogger(getLog());
setLog(logger.getLog());
ServerConfigDocument.getInstance(logger, serverXML, configDirectory,
getServerConfigDocument(logger, serverXML, configDirectory,
bootstrapPropertiesFile, combinedBootstrapProperties, serverEnvFile, false, libertyDirPropertyFiles);

//appName will be set to a name derived from file if no name can be found.
appName = ServerConfigDocument.findNameForLocation(appName);
appName = scd.findNameForLocation(appName);
} catch (Exception e) {
getLog().warn(e.getLocalizedMessage());
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* (C) Copyright IBM Corporation 2017, 2023.
* (C) Copyright IBM Corporation 2017, 2024.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -42,7 +42,7 @@
import io.openliberty.tools.common.arquillian.util.Constants;
import io.openliberty.tools.common.arquillian.util.HttpPortUtil;

@Mojo(name = "configure-arquillian", requiresDependencyResolution = ResolutionScope.TEST)
@Mojo(name = "configure-arquillian", requiresDependencyResolution = ResolutionScope.TEST, threadSafe = true)
public class ConfigureArquillianMojo extends BasicSupport {

@Parameter
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* (C) Copyright IBM Corporation 2017, 2023.
* (C) Copyright IBM Corporation 2017, 2024.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -37,7 +37,7 @@
/**
* Compile the JSPs in the src/main/webapp folder.
*/
@Mojo(name = "compile-jsp", defaultPhase = LifecyclePhase.COMPILE, requiresDependencyResolution = ResolutionScope.COMPILE)
@Mojo(name = "compile-jsp", defaultPhase = LifecyclePhase.COMPILE, requiresDependencyResolution = ResolutionScope.COMPILE, threadSafe = true)
public class CompileJspMojo extends InstallFeatureSupport {

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* (C) Copyright IBM Corporation 2014, 2023.
* (C) Copyright IBM Corporation 2014, 2024.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -26,7 +26,7 @@
/**
* Check a liberty server status
*/
@Mojo(name = "status")
@Mojo(name = "status", threadSafe = true)
public class CheckStatusMojo extends StartDebugMojoSupport {

@Override
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* (C) Copyright IBM Corporation 2016, 2023.
* (C) Copyright IBM Corporation 2016, 2024.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -24,7 +24,7 @@
/**
* Clean the logs, workarea, dropins and apps directories.
*/
@Mojo(name = "clean")
@Mojo(name = "clean", threadSafe = true)
public class CleanServerMojo extends StartDebugMojoSupport {

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* (C) Copyright IBM Corporation 2014, 2023.
* (C) Copyright IBM Corporation 2014, 2024.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -30,7 +30,7 @@
/**
* Create a liberty server
*/
@Mojo(name = "create", requiresDependencyResolution = ResolutionScope.COMPILE_PLUS_RUNTIME)
@Mojo(name = "create", requiresDependencyResolution = ResolutionScope.COMPILE_PLUS_RUNTIME, threadSafe = true)
public class CreateServerMojo extends PluginConfigSupport {

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* (C) Copyright IBM Corporation 2017, 2023.
* (C) Copyright IBM Corporation 2017, 2024.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -28,7 +28,7 @@
/**
* Start a liberty server in debug mode
*/
@Mojo(name = "debug", requiresDependencyResolution = ResolutionScope.COMPILE_PLUS_RUNTIME)
@Mojo(name = "debug", requiresDependencyResolution = ResolutionScope.COMPILE_PLUS_RUNTIME, threadSafe = true)

public class DebugServerMojo extends StartDebugMojoSupport {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* (C) Copyright IBM Corporation 2019, 2023.
* (C) Copyright IBM Corporation 2019, 2024.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -83,7 +83,7 @@
* Start a liberty server in dev mode import to set ResolutionScope for TEST as
* it helps build full transitive dependency classpath
*/
@Mojo(name = "dev", requiresDependencyCollection = ResolutionScope.TEST, requiresDependencyResolution = ResolutionScope.TEST)
@Mojo(name = "dev", requiresDependencyCollection = ResolutionScope.TEST, requiresDependencyResolution = ResolutionScope.TEST, threadSafe = true)
public class DevMojo extends LooseAppSupport {

private static final String TEST_RUN_ID_PROPERTY_NAME = "liberty.dev.test.run.id";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* (C) Copyright IBM Corporation 2020, 2023.
* (C) Copyright IBM Corporation 2020, 2024.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -22,7 +22,7 @@
/**
* Start dev mode for containers
*/
@Mojo(name = "devc", requiresDependencyCollection = ResolutionScope.TEST, requiresDependencyResolution = ResolutionScope.TEST)
@Mojo(name = "devc", requiresDependencyCollection = ResolutionScope.TEST, requiresDependencyResolution = ResolutionScope.TEST, threadSafe = true)
public class DevcMojo extends DevMojo {

@Override
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* (C) Copyright IBM Corporation 2014, 2023.
* (C) Copyright IBM Corporation 2014, 2024.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -29,7 +29,7 @@
/**
* Dump diagnostic information from the server into an archive.
*/
@Mojo(name = "dump", requiresDependencyResolution = ResolutionScope.COMPILE_PLUS_RUNTIME)
@Mojo(name = "dump", requiresDependencyResolution = ResolutionScope.COMPILE_PLUS_RUNTIME, threadSafe = true)
public class DumpServerMojo extends StartDebugMojoSupport {

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* (C) Copyright IBM Corporation 2021, 2023.
* (C) Copyright IBM Corporation 2021, 2024.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
Expand Down Expand Up @@ -53,7 +53,7 @@
* them in a new featureManager element in a new XML file in the source
* config/dropins directory.
*/
@Mojo(name = "generate-features")
@Mojo(name = "generate-features", threadSafe = true)
public class GenerateFeaturesMojo extends ServerFeatureSupport {

public static final String FEATURES_FILE_MESSAGE = "The Liberty Maven Plugin has generated Liberty features necessary for your application in "
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* (C) Copyright IBM Corporation 2015, 2023.
* (C) Copyright IBM Corporation 2015, 2024.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
Expand Down Expand Up @@ -39,7 +39,7 @@
* This mojo installs a feature packaged as a Subsystem Archive (esa) to the
* runtime.
*/
@Mojo(name = "install-feature")
@Mojo(name = "install-feature", threadSafe = true)
public class InstallFeatureMojo extends InstallFeatureSupport {

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* (C) Copyright IBM Corporation 2014, 2023.
* (C) Copyright IBM Corporation 2014, 2024.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -22,7 +22,7 @@
/**
* Install a liberty server
*/
@Mojo(name = "install-server", requiresDependencyResolution = ResolutionScope.COMPILE_PLUS_RUNTIME)
@Mojo(name = "install-server", requiresDependencyResolution = ResolutionScope.COMPILE_PLUS_RUNTIME, threadSafe = true)
public class InstallServerMojo extends PluginConfigSupport {

@Override
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* (C) Copyright IBM Corporation 2014, 2023.
* (C) Copyright IBM Corporation 2014, 2024.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -28,7 +28,7 @@
/**
* Dump diagnostic information from the server JVM.
*/
@Mojo(name = "java-dump", requiresDependencyResolution = ResolutionScope.COMPILE_PLUS_RUNTIME)
@Mojo(name = "java-dump", requiresDependencyResolution = ResolutionScope.COMPILE_PLUS_RUNTIME, threadSafe = true)
public class JavaDumpServerMojo extends StartDebugMojoSupport {

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* (C) Copyright IBM Corporation 2014, 2023.
* (C) Copyright IBM Corporation 2014, 2024.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -36,7 +36,7 @@
/**
* Package a liberty server
*/
@Mojo(name = "package", defaultPhase = LifecyclePhase.PACKAGE, requiresDependencyResolution = ResolutionScope.COMPILE_PLUS_RUNTIME)
@Mojo(name = "package", defaultPhase = LifecyclePhase.PACKAGE, requiresDependencyResolution = ResolutionScope.COMPILE_PLUS_RUNTIME, threadSafe = true)
public class PackageServerMojo extends StartDebugMojoSupport {

private enum PackageFileType {
Expand Down
Loading