Skip to content

Commit

Permalink
Merge pull request #876 from cherylking/makeThreadSafe
Browse files Browse the repository at this point in the history
Changes needed because of ci.common changes
  • Loading branch information
cherylking authored Jan 18, 2024
2 parents 00c852d + bdc273b commit 96ba5b2
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 28 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/gradle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
matrix:
# test against latest update of each major Java version, as well as specific updates of LTS versions:
RUNTIME: [ol, wlp]
RUNTIME_VERSION: [23.0.0.11]
RUNTIME_VERSION: [23.0.0.12]
java: [21, 17, 11, 8]
exclude:
- java: 8
Expand Down Expand Up @@ -100,7 +100,7 @@ jobs:
matrix:
# test against latest update of each major Java version, as well as specific updates of LTS versions:
RUNTIME: [ol, wlp]
RUNTIME_VERSION: [23.0.0.11]
RUNTIME_VERSION: [23.0.0.12]
java: [21, 17, 11, 8]
exclude:
- java: 8
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 @@ -77,6 +77,7 @@ abstract class AbstractServerTask extends AbstractLibertyTask {
protected Map<String,String> combinedBootstrapProperties = null
protected List<String> combinedJvmOptions = null
protected Map<String,String> combinedEnvProperties = null
protected ServerConfigDocument scd = null;

protected def server
protected def springBootBuildTask
Expand Down Expand Up @@ -513,13 +514,22 @@ abstract class AbstractServerTask extends AbstractLibertyTask {
configureMultipleAppsConfigDropins(serverNode)
}

protected ServerConfigDocument getServerConfigDocument(CommonLogger log, File serverXML, File configDir, File bootstrapFile,
Map<String, String> bootstrapProp, File serverEnvFile, boolean giveConfigDirPrecedence, Map<String, File> libertyDirPropertyFiles) throws IOException {
if (scd == null || !scd.getServerXML().getCanonicalPath().equals(serverXML.getCanonicalPath())) {
scd = new ServerConfigDocument(log, serverXML, configDir, bootstrapFile, bootstrapProp, serverEnvFile, giveConfigDirPrecedence, libertyDirPropertyFiles)
}

return scd
}

protected boolean isAppConfiguredInSourceServerXml(String fileName) {
boolean configured = false;
File serverConfigFile = new File(getServerDir(project), 'server.xml')
if (serverConfigFile != null && serverConfigFile.exists()) {
try {
Map<String,String> props = combinedBootstrapProperties == null ? convertPropertiesToMap(server.bootstrapProperties) : combinedBootstrapProperties;
ServerConfigDocument scd = ServerConfigDocument.getInstance(CommonLogger.getInstance(project), serverConfigFile, server.configDirectory, server.bootstrapPropertiesFile, props, server.serverEnvFile,
getServerConfigDocument(new CommonLogger(project), serverConfigFile, server.configDirectory, server.bootstrapPropertiesFile, props, server.serverEnvFile,
false, getLibertyDirectoryPropertyFiles(null));
if (scd != null && isLocationFound( scd.getLocations(), fileName)) {
logger.debug("Application configuration is found in server.xml : " + fileName)
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 @@ -109,7 +109,8 @@ class DeployTask extends AbstractServerTask {
} else {
if (libertyConfigDropinsAppXml.exists()){
libertyConfigDropinsAppXml.delete()
ServerConfigDocument.markInstanceStale()
// force reinitialization of ServerConfigDocument
scd = null
}
}
}
Expand Down Expand Up @@ -681,7 +682,7 @@ class DeployTask extends AbstractServerTask {
File serverXML = new File(getServerDir(project).getCanonicalPath(), "server.xml")

try {
scd = ServerConfigDocument.getInstance(CommonLogger.getInstance(project), serverXML, server.configDirectory,
scd = getServerConfigDocument(new CommonLogger(project), serverXML, server.configDirectory,
server.bootstrapPropertiesFile, combinedBootstrapProperties, server.serverEnvFile, false, getLibertyDirectoryPropertyFiles(null))

//appName will be set to a name derived from appFile if no name can be found.
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 @@ -86,7 +86,7 @@ class StartTask extends AbstractServerTask {
if (serverConfigFile != null && serverConfigFile.exists()) {
try {
Map<String,String> props = combinedBootstrapProperties == null ? convertPropertiesToMap(server.bootstrapProperties) : combinedBootstrapProperties;
ServerConfigDocument scd = ServerConfigDocument.getInstance(CommonLogger.getInstance(project), serverConfigFile, server.configDirectory, server.bootstrapPropertiesFile, props, server.serverEnvFile,
getServerConfigDocument(new CommonLogger(project), serverConfigFile, server.configDirectory, server.bootstrapPropertiesFile, props, server.serverEnvFile,
false, getLibertyDirectoryPropertyFiles(null));
if (scd != null) {
appNames = scd.getNames()
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 @@ -23,13 +23,13 @@ import org.gradle.api.logging.LogLevel
import io.openliberty.tools.ant.ServerTask
import io.openliberty.tools.common.plugins.config.ServerConfigDocument

import io.openliberty.tools.gradle.utils.CommonLogger

class UndeployTask extends AbstractServerTask {

private static final String STOP_APP_MESSAGE_CODE_REG = "CWWKZ0009I.*"
private static final long APP_STOP_TIMEOUT_DEFAULT = 30 * 1000

protected ServerConfigDocument scd

protected List<File> appFiles = new ArrayList<File>()

UndeployTask() {
Expand Down Expand Up @@ -79,7 +79,7 @@ class UndeployTask extends AbstractServerTask {
File serverXML = new File(getServerDir(project).getCanonicalPath(), "server.xml")

try {
scd = ServerConfigDocument.getInstance(CommonLogger.getInstance(project), serverXML, server.configDirectory,
getServerConfigDocument(new CommonLogger(project), serverXML, server.configDirectory,
server.bootstrapPropertiesFile, combinedBootstrapProperties, server.serverEnvFile, false, getLibertyDirectoryPropertyFiles(null))

//appName will be set to a name derived from appFile if no name can be found.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* (C) Copyright IBM Corporation 2019, 2020.
* (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 All @@ -21,24 +21,12 @@ import org.gradle.api.Project

public class CommonLogger implements CommonLoggerI {

private static CommonLogger logger = null
private static Project project
private Project project

CommonLogger(Project project) {
public CommonLogger(Project project) {
this.project = project
}

public static init(Project project) {
logger = new CommonLogger(project)
}

public static CommonLogger getInstance(Project project) {
if (logger == null) {
CommonLogger.init(project)
}
return logger
}

@Override
public void debug(String msg) {
project.getLogger().debug(msg)
Expand Down

0 comments on commit 96ba5b2

Please sign in to comment.