[
https://issues.apache.org/jira/browse/NIFI-15316?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Kim Seung Ho updated NIFI-15316:
--------------------------------
Description:
In GetFile.java, the isEmpty() check at line 423-425 is dead code.
{code:java}
// 코드 자리 표시자
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 "/".
was:
In GetFile.java, the isEmpty() check at line 423-425 is dead 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 "/".
Environment: Platform irrelevant (code logic issue)
> [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.6.0
> Environment: Platform irrelevant (code logic issue)
> Reporter: Kim Seung Ho
> Priority: Trivial
> Fix For: 2.6.0
>
>
> In GetFile.java, the isEmpty() check at line 423-425 is dead code.
> {code:java}
> // 코드 자리 표시자
> 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 "/".
--
This message was sent by Atlassian Jira
(v8.20.10#820010)