You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@inlong.apache.org by GitBox <gi...@apache.org> on 2022/09/06 08:48:41 UTC

[GitHub] [inlong] healchow commented on a diff in pull request #5804: [INLONG-5803][Agent] Fix NPE when collect file data

healchow commented on code in PR #5804:
URL: https://github.com/apache/inlong/pull/5804#discussion_r963435195


##########
inlong-agent/agent-plugins/src/main/java/org/apache/inlong/agent/plugin/sources/reader/file/MonitorTextFile.java:
##########
@@ -111,17 +114,23 @@ public void run() {
                     }
                     listen();
                     TimeUnit.MILLISECONDS.sleep(interval);
-                } catch (Exception e) {
-                    LOGGER.error("monitor {} error:", this.fileReaderOperator.file.getName(), e);
                 }
+            } catch (Exception e) {
+                LOGGER.error("monitor {} error:", this.fileReaderOperator.file.getName(), e);
             }
         }
 
         private void listen() throws IOException {
             BasicFileAttributes attributesAfter = Files
                     .readAttributes(this.fileReaderOperator.file.toPath(), BasicFileAttributes.class);
-            if (attributesBefore.lastModifiedTime().compareTo(attributesAfter.lastModifiedTime()) < 0
-                    && !this.fileReaderOperator.iterator.hasNext()) {
+            if (attributesBefore.lastModifiedTime().compareTo(attributesAfter.lastModifiedTime()) < 0) {

Review Comment:
   Suggested adding a comment for the reason for return.



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

To unsubscribe, e-mail: commits-unsubscribe@inlong.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org