azagrebin commented on a change in pull request #12981:
URL: https://github.com/apache/flink/pull/12981#discussion_r460106701
##########
File path:
flink-core/src/main/java/org/apache/flink/util/JavaGcCleanerWrapper.java
##########
@@ -303,32 +302,38 @@ private Runnable create(Object owner, Runnable
cleanupOperation) {
private static class PendingCleanersRunnerProvider {
private static final String REFERENCE_CLASS =
"java.lang.ref.Reference";
private final String cleanerName;
- private final ReflectionUtils reflectionUtils;
private final String waitForReferenceProcessingName;
private final Object[] waitForReferenceProcessingArgs;
private final Class<?>[] waitForReferenceProcessingArgTypes;
private PendingCleanersRunnerProvider(
String cleanerName,
- ReflectionUtils reflectionUtils,
String waitForReferenceProcessingName,
Object[] waitForReferenceProcessingArgs,
Class<?>[] waitForReferenceProcessingArgTypes) {
this.cleanerName = cleanerName;
- this.reflectionUtils = reflectionUtils;
this.waitForReferenceProcessingName =
waitForReferenceProcessingName;
this.waitForReferenceProcessingArgs =
waitForReferenceProcessingArgs;
this.waitForReferenceProcessingArgTypes =
waitForReferenceProcessingArgTypes;
}
+ @Nullable
private PendingCleanersRunner createPendingCleanersRunner() {
- Class<?> referenceClass =
reflectionUtils.findClass(REFERENCE_CLASS);
- Method waitForReferenceProcessingMethod =
reflectionUtils.findMethod(
- referenceClass,
- waitForReferenceProcessingName,
- waitForReferenceProcessingArgTypes);
- waitForReferenceProcessingMethod.setAccessible(true);
- return new
PendingCleanersRunner(waitForReferenceProcessingMethod,
waitForReferenceProcessingArgs);
+ try {
+ Class<?> referenceClass =
Class.forName(REFERENCE_CLASS);
+ Method waitForReferenceProcessingMethod =
referenceClass.getDeclaredMethod(
+ waitForReferenceProcessingName,
+ waitForReferenceProcessingArgTypes);
+
waitForReferenceProcessingMethod.setAccessible(true);
+ return new
PendingCleanersRunner(waitForReferenceProcessingMethod,
waitForReferenceProcessingArgs);
+ } catch (ClassNotFoundException | NoSuchMethodException
e) {
Review comment:
`findClass(String clazz, FunctionWithException<Class<?>,
FlinkRuntimeException>)` seems to be too much for one use atm. I do not see big
difference between checking `FlinkRuntimeException` and catching the exceptions
explicitly, except it is explicit which is mostly the asked reason. There is no
much code duplication or reuse. `ReflectionUtils` just packs the checked
exceptions.
----------------------------------------------------------------
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]