pnowojski 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_r371270053
 
 

 ##########
 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:
   Don't we need this check?

----------------------------------------------------------------
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


With regards,
Apache Git Services

Reply via email to