Bug #11867
Covnersion fails if the abl folder is symlinked
100%
Related issues
History
#1 Updated by Alexandru Lungu 11 days ago
- Assignee set to Dănuț Filimon
ConversionDriver crashes with a NullPointerException during incremental conversion whenever the file-set's <directory> reference (basepath, e.g. "./abl/") is a symlink pointing to a directory whose own final path component has a different name than the symlink itself.
- In the hotel_gui project, move the real source content aside and replace it with a symlink under a different target name, e.g.:
- mv abl abl_src
- ln -s abl_src abl (abl_src can be any name that differs from "abl" - that mismatch is what triggers the bug.)
- Confirm cfg/p2j.cfg.xml's profile has a file-set directory reference for this path, e.g.:
- <file-set>
- <directory recursive="true" path="./abl/" spec="(.[pPwWtT]|.cls)" />
- Run the conversion driver in incremental mode against that profile.
Expected is that the files under abl/ (via the symlink) are found and conversion proceeds normally, same as when abl is a real directory. But it fails with:
java.lang.NullPointerException: Cannot invoke
"com.goldencode.artifacts.ArtifactCollection.getArtifacts()" because
"col" is null
at com.goldencode.artifacts.ArtifactCollection.<init>(ArtifactCollection.java:112)
at com.goldencode.p2j.convert.TransformDriver.executeJob(TransformDriver.java:1149)
at com.goldencode.p2j.convert.ConversionDriver.main(ConversionDriver.java:1458)
Root cause:
FileListFactory.resolvePaths() (FileListFactory.java:429-447) reconstructs each matched file's relative path from a real (symlink-resolved) absolute path using segment-count arithmetic:
Path real = path.toRealPath();
Path base = real.subpath(0, real.getNameCount() - path.getNameCount());
Path resolved = real.subpath(base.getNameCount(), real.getNameCount());
This is only correct when the symlink's target ends in a path component named identically to the symlink itself. Whenever it differs (the normal case for any real symlink), the computed "resolved" path is wrong and does not exist relative to the project root. ExplicitFileList.listImpl() then silently drops every such entry because it only keeps files that actually exist on disk, so the whole file-set resolves to zero files.
That empty result reaches ArtifactManager.getArtifactCol(), whose "if (col.isEmpty()) return null;" turns the empty file-set into a null collection instead of an empty one; ArtifactManager.createProjectArtifacts() (PROFILE case) then wraps that null in a "success" ArtifactConversionResult (code=1), so job.artifacts ends up null. In incremental mode, TransformDriver.executeJob()'s "new ArtifactCollection(job.artifacts)" then throws the NPE above.
Suggested fix:
FileListFactory.resolvePaths() should not reconstruct the relative path from segment counts at all - it already has the original, normalized relative path and only needs toRealPath() to confirm the file exists; it should return the original path string rather than a path derived from the real (symlink-resolved) segments.
#2 Updated by Dănuț Filimon 11 days ago
- Related to Bug #11156: Conversion fails if source folder is a symlink added
#3 Updated by Dănuț Filimon 11 days ago
- Status changed from New to WIP
Looks like the same problem from #11156, I will rebase the branch and retest.
#4 Updated by Dănuț Filimon 9 days ago
- % Done changed from 0 to 100
- Status changed from WIP to Review
I committed 11156a/16754, the symbolic link will not be followed in resolvePaths().
Alexandru, please review.
#5 Updated by Dănuț Filimon 8 days ago
- reviewer Alexandru Lungu added