AHeise commented on a change in pull request #10952:
[FLINK-15777][filesystem]Determine Hadoop version with fs classpath.
URL: https://github.com/apache/flink/pull/10952#discussion_r371299272
##########
File path:
flink-filesystems/flink-hadoop-fs/src/main/java/org/apache/flink/runtime/fs/hdfs/HadoopRecoverableFsDataOutputStream.java
##########
@@ -175,44 +172,39 @@ private static void safelyTruncateFile(
}
}
- private static void ensureTruncateInitialized() throws
FlinkRuntimeException {
- if (HadoopUtils.isMinHadoopVersion(2, 7) && truncateHandle ==
null) {
- Method truncateMethod;
+ private static Method findTrunacteMethod(FileSystem fs) throws
FlinkRuntimeException {
+ Method truncateMethod = null;
+ if
(HadoopUtils.isMinHadoopVersion(fs.getClass().getClassLoader(), 2, 7)) {
try {
- truncateMethod =
FileSystem.class.getMethod("truncate", Path.class, long.class);
- }
- catch (NoSuchMethodException e) {
+ truncateMethod =
fs.getClass().getMethod("truncate", Path.class, long.class);
+ } catch (NoSuchMethodException e) {
throw new FlinkRuntimeException("Could not find
a public truncate method on the Hadoop File System.");
}
-
- if (!Modifier.isPublic(truncateMethod.getModifiers())) {
- throw new FlinkRuntimeException("Could not find
a public truncate method on the Hadoop File System.");
- }
-
- truncateHandle = truncateMethod;
Review comment:
`getMethod` is only return public members.
----------------------------------------------------------------
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