[GitHub] [nifi] mattyb149 commented on a diff in pull request #7664: NIFI-12019 bugfix for SynchronousFileWatcher time check interval

2023-09-05 Thread via GitHub


mattyb149 commented on code in PR #7664:
URL: https://github.com/apache/nifi/pull/7664#discussion_r1316681639


##
nifi-commons/nifi-utils/src/main/java/org/apache/nifi/util/file/monitor/SynchronousFileWatcher.java:
##
@@ -77,21 +77,16 @@ public boolean checkAndReset() throws IOException {
 private boolean checkForUpdate() throws IOException {
 if (resourceLock.tryLock()) {
 try {
-final StateWrapper wrapper = lastState.get();
+final Object oldState = lastState.get().getState();
 final Object newState = monitor.getCurrentState(path);
-if (newState == null && wrapper.getState() == null) {
+if (newState == null && oldState == null) {
 return false;
 }
-if (newState == null || wrapper.getState() == null) {
-lastState.set(new StateWrapper(newState));
+lastState.set(new StateWrapper(newState));

Review Comment:
   Why the null checks then? Just to be defensive?



-- 
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: issues-unsubscr...@nifi.apache.org

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



[GitHub] [nifi] mattyb149 commented on a diff in pull request #7664: NIFI-12019 bugfix for SynchronousFileWatcher time check interval

2023-09-05 Thread via GitHub


mattyb149 commented on code in PR #7664:
URL: https://github.com/apache/nifi/pull/7664#discussion_r1316278797


##
nifi-commons/nifi-utils/src/main/java/org/apache/nifi/util/file/monitor/SynchronousFileWatcher.java:
##
@@ -77,21 +77,16 @@ public boolean checkAndReset() throws IOException {
 private boolean checkForUpdate() throws IOException {
 if (resourceLock.tryLock()) {
 try {
-final StateWrapper wrapper = lastState.get();
+final Object oldState = lastState.get().getState();
 final Object newState = monitor.getCurrentState(path);
-if (newState == null && wrapper.getState() == null) {
+if (newState == null && oldState == null) {
 return false;
 }
-if (newState == null || wrapper.getState() == null) {
-lastState.set(new StateWrapper(newState));
+lastState.set(new StateWrapper(newState));

Review Comment:
   If newState is `null` does this cause issues creating a wrapper around it?



-- 
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: issues-unsubscr...@nifi.apache.org

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