[
https://issues.apache.org/jira/browse/NIFI-15316?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
David Handermann resolved NIFI-15316.
-------------------------------------
Fix Version/s: 2.8.0
2.7.2
2.7.1
(was: 2.6.0)
Assignee: Michael W Moser
Resolution: Fixed
This was resolved as part of changes for NIFI-14095.
> [GetFile] Dead code in onTrigger - isEmpty() check unreachable after string
> concatenation
> -----------------------------------------------------------------------------------------
>
> Key: NIFI-15316
> URL: https://issues.apache.org/jira/browse/NIFI-15316
> Project: Apache NiFi
> Issue Type: Bug
> Components: Core Framework
> Affects Versions: 2.0.0, 2.7.0
> Environment: Platform irrelevant (code logic issue)
> Reporter: Kim Seung Ho
> Assignee: Michael W Moser
> Priority: Trivial
> Fix For: 2.8.0, 2.7.2, 2.7.1
>
>
> In GetFile.java, the isEmpty() check at line 423-425 is dead code.
> {code:java}
> // Before modification (current code)
> String relativePathString = relativePath.toString() + "/";
> if (relativePathString.isEmpty()) {
> relativePathString = "./";
> } {code}
> The variable `relativePathString` is assigned with `relativePath.toString() +
> "/"`
> which always contains at least "/" character, making the isEmpty() condition
> always false.
> The original intent was likely to check if relativePath is empty (when file
> is
> directly under the input directory), but the "/" is appended before the check.
> Fix: Check isEmpty() on relativePath.toString() before appending "/".
> {code:java}
> // After modification
> String relativePathString = relativePath.toString();
> if (relativePathString.isEmpty()) {
> relativePathString = "./";
> } else {
> relativePathString = relativePathString + "/";
> } {code}
> or, simply
> {code:java}
> // After modification
> String relativePathString = relativePath.toString();
> relativePathString = relativePathString.isEmpty() ? "./" : relativePathString
> + "/"; {code}
--
This message was sent by Atlassian Jira
(v8.20.10#820010)