lirui-apache commented on a change in pull request #10620:
[FLINK-15239][table-planner-blink] CompileUtils::COMPILED_CACHE leaks class
loaders
URL: https://github.com/apache/flink/pull/10620#discussion_r361455419
##########
File path:
flink-table/flink-table-runtime-blink/src/main/java/org/apache/flink/table/runtime/generated/CompileUtils.java
##########
@@ -59,14 +62,16 @@
* @return the compiled class
*/
public static <T> Class<T> compile(ClassLoader cl, String name, String
code) {
- Tuple2<ClassLoader, String> cacheKey = Tuple2.of(cl, name);
- Class<?> clazz = COMPILED_CACHE.getIfPresent(cacheKey);
- if (clazz == null) {
- clazz = doCompile(cl, name, code);
- COMPILED_CACHE.put(cacheKey, clazz);
+ try {
+ Cache<ClassLoader, Class> compiledClasses =
COMPILED_CACHE.get(name,
+ () ->
CacheBuilder.newBuilder().maximumSize(5).weakKeys().softValues().build());
+ return compiledClasses.get(cl, () -> doCompile(cl,
name, code));
+ } catch (ExecutionException | UncheckedExecutionException e) {
Review comment:
OK, although I think the test shouldn't be expecting any specific kind of
exception because exception is not a part of the method contract.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services