[MAGNOLIA-6581] Classpath service won't serve resource if virtual tree has a file/folder overlap Created: 04/Mar/16  Updated: 15/Mar/21  Resolved: 15/Mar/21

Status: Closed
Project: Magnolia
Component/s: resource-loader
Affects Version/s: 5.4.5
Fix Version/s: None

Type: Bug Priority: Neutral
Reporter: Mikaël Geljić Assignee: Mikaël Geljić
Resolution: Outdated Votes: 0
Labels: classpath, resources
Remaining Estimate: 4d
Time Spent: Not Specified
Original Estimate: 4d

Attachments: File overlapping-resources-a-1.0-SNAPSHOT.jar     File overlapping-resources-b-1.0-SNAPSHOT.jar    
Issue Links:
Relates
relates to MAGNOLIA-6433 Resouces in filesystem and classpath ... Closed
relates to MAGNOLIA-6376 ClasspathResourceOrigin should warn u... Open
causality
caused by MAGNOLIA-6523 Refactor ClasspathResourceOrigin and ... Closed
supersession
supersedes MAGNOLIA-6575 ClasspathResourceOrigin doesn't relia... Closed
supersedes MAGNOLIA-6440 Duplicated resources on classpath may... Closed
Template:
Acceptance criteria:
Empty
Task DoD:
[ ]* Doc/release notes changes? Comment present?
[ ]* Downstream builds green?
[ ]* Solution information and context easily available?
[ ]* Tests
[ ]* FixVersion filled and not yet released
[ ]  Architecture Decision Record (ADR)
Bug DoR:
[ ]* Steps to reproduce, expected, and actual results filled
[ ]* Affected version filled
Story Points: 8

 Description   

Classpath service/origin should serve resource files no matter what; and regardless of how we model that as a virtual directory structure.

Assuming you have:

  • in module A: src/main/resources/test/samename (plain text)
  • in module B: src/main/resources/test/samename/subfile.txt (samename is now a virtual directory)

http://localhost:8080/magnoliaAuthor/.resources/test/samename is served properly
http://localhost:8080/magnoliaAuthor/.resources/test/samename/subfile.txt results in a 404

This is clearly highlighted in ClasspathEntryResolver, that it ignores sub-directory structures in such cases—which to me is just wrong.


Other potential harmful (and deferred) side-effect: create a "travel-demo" mgnl:content node in resources workspace, on next restart the whole travel-demo is down.
Defs are expectedly not registered; no static resource reachable in there either.



 Comments   
Comment by Mikaël Geljić [ 04/Mar/16 ]

mind that with my patch (branch classpath-entry-resolver on my fork), duplicates result in the following log, while individual files get served anyway indeed:

2016-03-04 13:34:30,363 WARN  nolia.resourceloader.layered.LayeredResourceOrigin: Resources at /travel-demo are not all directory/file: [JcrResource{origin=jcr,path=/travel-demo,file}, ClasspathResource{origin=classpath,path=/travel-demo,(directory)}]

That log shows up e.g. in the Resource Files app, not while browsing site by any means.

Comment by Mikaël Geljić [ 07/Mar/16 ]

Linking to MAGNOLIA-6575; we tracked the simplification refactoring there. Still, I realized the file/folder overlap story is only partially addressed there—it basically depends upon which entry (file or folder) is added first. Considering two modules as follows:

module A:

  • src/main/resources
    • foo
    • bar/foo

module B

  • src/main/resources
    • bar
    • foo/bar

There is still one of the two conflicting files which cannot be served (results in 400 btw, not 404).

Comment by Mikaël Geljić [ 07/Mar/16 ]

Attaching couple minimal jars reflecting situation above (within one "overlap" root directory)

Generated at Mon Feb 12 04:15:52 CET 2024 using Jira 9.4.2#940002-sha1:46d1a51de284217efdcb32434eab47a99af2938b.