Adalennis opened a new issue, #9117:
URL: https://github.com/apache/hop/issues/9117
### Apache Hop version?
2.20.0-SNAPSHOT
### Java version?
OpenJDK 21.0.11
### Operating system
macOS
### What happened?
Found while documenting the result of these actions (#8970, fourth batch, PR
#9104). Reproduced with hop-run on main; the current behaviour is documented in
a NOTE on each action page, so the docs need an update when these are fixed.
**1. Compare folders reports different folders as identical (entries matched
by name only)**
`ActionFoldersCompare.execute` puts the entries of each folder in a map
keyed by the base name (lines 242 and 247), so the subfolder is ignored. With
*Include subfolders*, a folder with `s1/x.txt` and `s2/x.txt` and a folder with
`s1/x.txt` and `s2/y.txt` have the same number of entries and every name of the
first is found in the second: the action is true.
**2. Compare folders: the wildcard is not resolved, and an invalid one makes
any two folders identical**
`getFileWildcard()` (line 494) compiles the raw `wildcard` field, not
`resolve(wildcard)`, so `${MASK}` is not resolved even when MASK is set, and is
an invalid regular expression ("Illegal repetition"). The exception is caught
in `includeFile()`, so every entry is left out, both lists are empty, and two
different folders are reported identical (true). Because `getFileWildcard(...)`
is evaluated before `compareOnly.equals("specify")` (lines 459 and 469), a
stored invalid wildcard has the same effect with *Compare* set to *All*.
**3. Folder is empty: an invalid regular expression stops the workflow**
`Pattern.compile(getRealWildcard())` (line 138) runs outside the try, so a
`PatternSyntaxException` escapes `execute()`: the workflow stops with "A
serious error occurred during workflow execution" and no hop is followed. It is
compiled whenever *Wildcard (RegExp)* is set, also when *Limit search to
(RegExp)* is not selected.
**4. DOS to Unix: a result row with fewer than three fields stops the
workflow**
With *Copy previous results to args*, `execute()` reads
`resultRow.getString(1, null)` and `resultRow.getString(2, null)` (line 236)
without checking the number of fields. A row with one or two fields throws a
NullPointerException that escapes `execute()`, and the workflow stops.
**5. DOS to Unix matches the wildcard against the whole path**
`processFileFolder` calls `getFileWildcard(currentFile.toString(),
realWildcard)` (lines 504 and 510), so the regular expression is matched
against `file:///.../dos.txt`. A wildcard on the file name such as `dos\.txt`
matches nothing: no file is converted and the action is still true. Other
actions (Files exist, Folder is empty, Check files locked) match the base name.
**6. Check files locked: a result row with one field stops the check, and
the action is true**
`isOneArgumentsFileLocked` reads `resultRow.getString(1, "")` (line 160).
For a row with one field this throws a NullPointerException, which is only
caught in `execute()` (line 125, "Error running action!"): that row and the
rows after it are not checked, and the action stays true.
**7. Check files locked: an invalid wildcard checks nothing, and the action
is true**
`Pattern.compile(wildcard)` (line 314) runs in the file selector, inside its
try: every file logs an error and is skipped, nothing in the folder is checked,
and the action is true. A folder holding a file that counts as locked passes
the check.
### Issue Priority
Priority: 3
### Issue Component
Component: Hop Gui
--
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]