From 9c0b8d17cf034ccb2158a5633e5e12e2a0446320 Mon Sep 17 00:00:00 2001 From: yuxiqian <34335406+yuxiqian@users.noreply.github.com> Date: Tue, 13 Aug 2024 11:14:34 +0800 Subject: [PATCH] [hotfix][runtime] Invalidate cache correctly to avoid classloader leakage --- .../operators/transform/TransformExpressionCompiler.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/flink-cdc-runtime/src/main/java/org/apache/flink/cdc/runtime/operators/transform/TransformExpressionCompiler.java b/flink-cdc-runtime/src/main/java/org/apache/flink/cdc/runtime/operators/transform/TransformExpressionCompiler.java index e22d7943d9..326ae7ba74 100644 --- a/flink-cdc-runtime/src/main/java/org/apache/flink/cdc/runtime/operators/transform/TransformExpressionCompiler.java +++ b/flink-cdc-runtime/src/main/java/org/apache/flink/cdc/runtime/operators/transform/TransformExpressionCompiler.java @@ -39,7 +39,10 @@ public class TransformExpressionCompiler { /** Triggers internal garbage collection of expired cache entries. */ public static void cleanUp() { - COMPILED_EXPRESSION_CACHE.cleanUp(); + // com.google.common.cache.Cache from Guava isn't guaranteed to clear all cached records + // when invoking Cache#cleanUp, which may cause classloader leakage. Use #invalidateAll + // instead to ensure all key / value pairs to be correctly discarded. + COMPILED_EXPRESSION_CACHE.invalidateAll(); } /** Compiles an expression code to a janino {@link ExpressionEvaluator}. */