Skip to content

Commit 96ba5b2

Browse files
authored
Merge pull request #876 from cherylking/makeThreadSafe
Changes needed because of ci.common changes
2 parents 00c852d + bdc273b commit 96ba5b2

File tree

6 files changed

+27
-28
lines changed

6 files changed

+27
-28
lines changed

.github/workflows/gradle.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ jobs:
1818
matrix:
1919
# test against latest update of each major Java version, as well as specific updates of LTS versions:
2020
RUNTIME: [ol, wlp]
21-
RUNTIME_VERSION: [23.0.0.11]
21+
RUNTIME_VERSION: [23.0.0.12]
2222
java: [21, 17, 11, 8]
2323
exclude:
2424
- java: 8
@@ -100,7 +100,7 @@ jobs:
100100
matrix:
101101
# test against latest update of each major Java version, as well as specific updates of LTS versions:
102102
RUNTIME: [ol, wlp]
103-
RUNTIME_VERSION: [23.0.0.11]
103+
RUNTIME_VERSION: [23.0.0.12]
104104
java: [21, 17, 11, 8]
105105
exclude:
106106
- java: 8

src/main/groovy/io/openliberty/tools/gradle/tasks/AbstractServerTask.groovy

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* (C) Copyright IBM Corporation 2017, 2023.
2+
* (C) Copyright IBM Corporation 2017, 2024.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -77,6 +77,7 @@ abstract class AbstractServerTask extends AbstractLibertyTask {
7777
protected Map<String,String> combinedBootstrapProperties = null
7878
protected List<String> combinedJvmOptions = null
7979
protected Map<String,String> combinedEnvProperties = null
80+
protected ServerConfigDocument scd = null;
8081

8182
protected def server
8283
protected def springBootBuildTask
@@ -513,13 +514,22 @@ abstract class AbstractServerTask extends AbstractLibertyTask {
513514
configureMultipleAppsConfigDropins(serverNode)
514515
}
515516

517+
protected ServerConfigDocument getServerConfigDocument(CommonLogger log, File serverXML, File configDir, File bootstrapFile,
518+
Map<String, String> bootstrapProp, File serverEnvFile, boolean giveConfigDirPrecedence, Map<String, File> libertyDirPropertyFiles) throws IOException {
519+
if (scd == null || !scd.getServerXML().getCanonicalPath().equals(serverXML.getCanonicalPath())) {
520+
scd = new ServerConfigDocument(log, serverXML, configDir, bootstrapFile, bootstrapProp, serverEnvFile, giveConfigDirPrecedence, libertyDirPropertyFiles)
521+
}
522+
523+
return scd
524+
}
525+
516526
protected boolean isAppConfiguredInSourceServerXml(String fileName) {
517527
boolean configured = false;
518528
File serverConfigFile = new File(getServerDir(project), 'server.xml')
519529
if (serverConfigFile != null && serverConfigFile.exists()) {
520530
try {
521531
Map<String,String> props = combinedBootstrapProperties == null ? convertPropertiesToMap(server.bootstrapProperties) : combinedBootstrapProperties;
522-
ServerConfigDocument scd = ServerConfigDocument.getInstance(CommonLogger.getInstance(project), serverConfigFile, server.configDirectory, server.bootstrapPropertiesFile, props, server.serverEnvFile,
532+
getServerConfigDocument(new CommonLogger(project), serverConfigFile, server.configDirectory, server.bootstrapPropertiesFile, props, server.serverEnvFile,
523533
false, getLibertyDirectoryPropertyFiles(null));
524534
if (scd != null && isLocationFound( scd.getLocations(), fileName)) {
525535
logger.debug("Application configuration is found in server.xml : " + fileName)

src/main/groovy/io/openliberty/tools/gradle/tasks/DeployTask.groovy

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* (C) Copyright IBM Corporation 2014, 2023.
2+
* (C) Copyright IBM Corporation 2014, 2024.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -109,7 +109,8 @@ class DeployTask extends AbstractServerTask {
109109
} else {
110110
if (libertyConfigDropinsAppXml.exists()){
111111
libertyConfigDropinsAppXml.delete()
112-
ServerConfigDocument.markInstanceStale()
112+
// force reinitialization of ServerConfigDocument
113+
scd = null
113114
}
114115
}
115116
}
@@ -681,7 +682,7 @@ class DeployTask extends AbstractServerTask {
681682
File serverXML = new File(getServerDir(project).getCanonicalPath(), "server.xml")
682683

683684
try {
684-
scd = ServerConfigDocument.getInstance(CommonLogger.getInstance(project), serverXML, server.configDirectory,
685+
scd = getServerConfigDocument(new CommonLogger(project), serverXML, server.configDirectory,
685686
server.bootstrapPropertiesFile, combinedBootstrapProperties, server.serverEnvFile, false, getLibertyDirectoryPropertyFiles(null))
686687

687688
//appName will be set to a name derived from appFile if no name can be found.

src/main/groovy/io/openliberty/tools/gradle/tasks/StartTask.groovy

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* (C) Copyright IBM Corporation 2014, 2023.
2+
* (C) Copyright IBM Corporation 2014, 2024.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -86,7 +86,7 @@ class StartTask extends AbstractServerTask {
8686
if (serverConfigFile != null && serverConfigFile.exists()) {
8787
try {
8888
Map<String,String> props = combinedBootstrapProperties == null ? convertPropertiesToMap(server.bootstrapProperties) : combinedBootstrapProperties;
89-
ServerConfigDocument scd = ServerConfigDocument.getInstance(CommonLogger.getInstance(project), serverConfigFile, server.configDirectory, server.bootstrapPropertiesFile, props, server.serverEnvFile,
89+
getServerConfigDocument(new CommonLogger(project), serverConfigFile, server.configDirectory, server.bootstrapPropertiesFile, props, server.serverEnvFile,
9090
false, getLibertyDirectoryPropertyFiles(null));
9191
if (scd != null) {
9292
appNames = scd.getNames()

src/main/groovy/io/openliberty/tools/gradle/tasks/UndeployTask.groovy

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* (C) Copyright IBM Corporation 2014, 2023.
2+
* (C) Copyright IBM Corporation 2014, 2024.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -23,13 +23,13 @@ import org.gradle.api.logging.LogLevel
2323
import io.openliberty.tools.ant.ServerTask
2424
import io.openliberty.tools.common.plugins.config.ServerConfigDocument
2525

26+
import io.openliberty.tools.gradle.utils.CommonLogger
27+
2628
class UndeployTask extends AbstractServerTask {
2729

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

31-
protected ServerConfigDocument scd
32-
3333
protected List<File> appFiles = new ArrayList<File>()
3434

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

8181
try {
82-
scd = ServerConfigDocument.getInstance(CommonLogger.getInstance(project), serverXML, server.configDirectory,
82+
getServerConfigDocument(new CommonLogger(project), serverXML, server.configDirectory,
8383
server.bootstrapPropertiesFile, combinedBootstrapProperties, server.serverEnvFile, false, getLibertyDirectoryPropertyFiles(null))
8484

8585
//appName will be set to a name derived from appFile if no name can be found.

src/main/groovy/io/openliberty/tools/gradle/utils/CommonLogger.groovy

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* (C) Copyright IBM Corporation 2019, 2020.
2+
* (C) Copyright IBM Corporation 2019, 2024.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -21,24 +21,12 @@ import org.gradle.api.Project
2121

2222
public class CommonLogger implements CommonLoggerI {
2323

24-
private static CommonLogger logger = null
25-
private static Project project
24+
private Project project
2625

27-
CommonLogger(Project project) {
26+
public CommonLogger(Project project) {
2827
this.project = project
2928
}
3029

31-
public static init(Project project) {
32-
logger = new CommonLogger(project)
33-
}
34-
35-
public static CommonLogger getInstance(Project project) {
36-
if (logger == null) {
37-
CommonLogger.init(project)
38-
}
39-
return logger
40-
}
41-
4230
@Override
4331
public void debug(String msg) {
4432
project.getLogger().debug(msg)

0 commit comments

Comments
 (0)