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

[docker] Do not close classloaders, to prevent spammy ClassNotFoundExceptions #656

Merged
merged 2 commits into from
Oct 27, 2023
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
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,13 @@ public class NarFileHandler
AssetManagerRegistry.AssetManagerPackageLoader,
TopicConnectionsRuntimeRegistry.TopicConnectionsPackageLoader {

private static final boolean CLOSE_CLASSLOADERS =
Boolean.parseBoolean(System.getProperty("langstream.nar.closeClassloaders", "true"));

static {
log.info("langstream.nar.closeClassloaders = {}", CLOSE_CLASSLOADERS);
}

private final Path packagesDirectory;
private final Path temporaryDirectory;

Expand Down Expand Up @@ -83,6 +90,17 @@ private static void deleteDirectory(Path dir) throws Exception {

public void close() {

// when you are in a docker container or a pod, the JVM is going to be killed
// no need to close the classloaders
// closing the classloaders would cause only a log of spammy ClassNotFoundErrors
// that because false positives reported by users
if (!CLOSE_CLASSLOADERS) {
log.info(
"Not closing classloaders, "
+ "in order to avoid class loading issues during development while the JVM is shutdown");
return;
}

for (PackageMetadata metadata : packages.values()) {
URLClassLoader classLoader = metadata.getClassLoader();
if (classLoader != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,4 @@ if [ "$START_HERDDB" = "true" ]; then
/herddb/herddb/bin/service server start
fi

exec java ${JAVA_OPTS} -Dlogging.config=/app/logback.xml -Djdk.lang.Process.launchMechanism=vfork -cp "/app/lib/*" "ai.langstream.runtime.tester.Main"
exec java ${JAVA_OPTS} -Dlangstream.nar.closeClassloaders=false -Dlogging.config=/app/logback.xml -Djdk.lang.Process.launchMechanism=vfork -cp "/app/lib/*" "ai.langstream.runtime.tester.Main"
Loading