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

Use appropriate class loader for servermanger commands #294

Merged
merged 1 commit into from
Oct 21, 2023
Merged
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 @@ -44,6 +44,7 @@ final class Runner {
def serverManager = null
final def reader = ServiceProtocol.createReader()
final def writer = ServiceProtocol.createWriter(params.statusPort)
def cl = null
try {
writer.write("init ${reader.port}")
while(true) {
Expand All @@ -52,7 +53,7 @@ final class Runner {
params << new JsonSlurper().parseText(data)
paramsLoaded = true

def cl = createClassLoader()
cl = createClassLoader()
ClassLoader oldClassLoader = Thread.currentThread().getContextClassLoader()
Thread.currentThread().setContextClassLoader(cl)
try {
Expand All @@ -78,12 +79,26 @@ final class Runner {
}
else if(data == 'restart') {
serverManager.stopServer()
serverManager.startServer()
ClassLoader oldClassLoader = Thread.currentThread().getContextClassLoader()
Thread.currentThread().setContextClassLoader(cl)
try {
serverManager.startServer()
}
finally {
Thread.currentThread().setContextClassLoader(oldClassLoader)
}
}
else if(data == 'restartWithEvent') {
serverManager.stopServer()
def event = serverManager.startServer()
onServerStarted(writer, event.getServerStartInfo())
ClassLoader oldClassLoader = Thread.currentThread().getContextClassLoader()
Thread.currentThread().setContextClassLoader(cl)
try {
def event = serverManager.startServer()
onServerStarted(writer, event.getServerStartInfo())
}
finally {
Thread.currentThread().setContextClassLoader(oldClassLoader)
}
}
else if (data.startsWith('redeploy ')) {
List<String> webappList = data.replace('redeploy ', '').split(' ').toList()
Expand Down