ing-mattioni commented on code in PR #11245:
URL: https://github.com/apache/nifi/pull/11245#discussion_r3257740043


##########
nifi-extension-bundles/nifi-standard-bundle/nifi-standard-processors/src/main/java/org/apache/nifi/processors/standard/TailFile.java:
##########
@@ -427,9 +428,19 @@ private void initStates(final List<String> filesToTail, 
final Map<String, String
                 for (Entry<String, String> entry : statesMap.entrySet()) {
                     final String key = entry.getKey();
                     final String value = entry.getValue();
-                    if (key.endsWith(TailFileState.StateKeys.FILENAME) && 
filesToTail.contains(value)) {
-                        int index = Integer.parseInt(key.split("\\.")[1]);
-                        states.put(value, new TailFileObject(index, statesMap, 
preAllocatedBufferSize));
+                    if (key.endsWith(TailFileState.StateKeys.FILENAME) && 
filesToTailSet.contains(value)) {
+                        final int index;
+                        try {
+                            index = Integer.parseInt(key.split("\\.")[1]);
+                        } catch (final RuntimeException e) {
+                            getLogger().warn("Ignoring malformed TailFile 
state key {}", key, e);
+                            continue;
+                        }
+                        try {
+                            states.put(value, new TailFileObject(index, 
statesMap, preAllocatedBufferSize));
+                        } catch (final RuntimeException e) {
+                            getLogger().warn("Ignoring malformed TailFile 
state for {}", value, e);
+                        }

Review Comment:
   Agreed. I removed this broad catch as well. If the processor-controlled 
state cannot be restored, that should not be silently ignored by skipping the 
file.



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to