rmetzger commented on a change in pull request #14372: URL: https://github.com/apache/flink/pull/14372#discussion_r544222084
########## File path: flink-connectors/flink-connector-kinesis/src/main/java/org/apache/flink/streaming/connectors/kinesis/FlinkKinesisProducer.java ########## @@ -423,4 +432,43 @@ private void flushSync() throws Exception { } } } + + /** + * Remove references created by the producer, preventing the classloader to unload. References were + * analyzed as of version 0.14.0. + */ + private void runClassLoaderReleaseHook(ClassLoader classLoader) { + // unregister admin mbean + AwsSdkMetrics.unregisterMetricAdminMBean(); + + try { + // Remove FileAgeManager + Class<?> fileAgeManagerClazz = Class.forName("com.amazonaws.services.kinesis.producer.FileAgeManager", true, classLoader); + Field instanceField = fileAgeManagerClazz.getDeclaredField("instance"); + instanceField.setAccessible(true); + + // unset (static final) field FileAgeManager.instance + Field modifiersField = Field.class.getDeclaredField("modifiers"); + modifiersField.setAccessible(true); + modifiersField.setInt(instanceField, instanceField.getModifiers() & ~Modifier.FINAL); + Object fileAgeManager = instanceField.get(null); + instanceField.set(null, null); + + // shutdown thread pool Review comment: You are right. Only the thread pool is the problem. ---------------------------------------------------------------- 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: us...@infra.apache.org