Skip to content

Commit

Permalink
Merge pull request #294 from smhc/classpath-fix
Browse files Browse the repository at this point in the history
Use appropriate class loader for servermanger commands
  • Loading branch information
boris-petrov authored Oct 21, 2023
2 parents fea24b1 + 29ca2f8 commit c2d47c1
Showing 1 changed file with 19 additions and 4 deletions.
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

0 comments on commit c2d47c1

Please sign in to comment.