[MAGNOLIA-6612] DevelopmentModeClasspathFile should use the same resource for last modified and output stream Created: 17/Mar/16 Updated: 15/Nov/22 |
|
| Status: | Accepted |
| Project: | Magnolia |
| Component/s: | resource-loader |
| Affects Version/s: | 5.4.5 |
| Fix Version/s: | None |
| Type: | Bug | Priority: | Neutral |
| Reporter: | Nils Breunese | Assignee: | Unassigned |
| Resolution: | Unresolved | Votes: | 0 |
| Labels: | classpath, resources | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Issue Links: |
|
||||||||||||||||||||
| 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
|
||||||||||||||||||||
| Date of First Response: | |||||||||||||||||||||
| Visible to: |
Mathijn Elhorst, Michiel Meeuwissen, Rico Jansen
|
||||||||||||||||||||
| Epic Link: | DevX Bucket | ||||||||||||||||||||
| Team: | |||||||||||||||||||||
| Description |
|
The getLastModified() method of DevelopmentModeClasspathFile uses this code to determine a resource URL:
final URL resourceUrl = ClasspathHelper.contextClassLoader().getResource(jarFile.getRelativePath());
However, the openStream() method returns jarFile.openInputStream() directly, which in our case (we use our own class loader in development) means that DevelopmentModeClasspathFile doesn't use the same resource for the output stream and the last modified date! We now use a patched version of DevelopmentModeClasspathFile in which openStream() determines the resourceURL exactly as in getLastModified() and then returns resourceURL.getInputStream(). We hope you'll incorporate this change into your code base, so we can drop our patched class with a future release. |
| Comments |
| Comment by Janek Valgma [ 09/Nov/22 ] |
|
Workaround here also fixes the problem I found, patching openStream() in DevelopmentModeClasspathFile to first get the URL like in getLastModified() and then if resourceUrl is not null return resourceUrl.openStream() else return classpathLocation.openStream() instead of opening jarResource I assume this might be because ClassGraph has it's own classloader. |
| Comment by Maxime Michel [ 11/Nov/22 ] |
|
Thanks Jdev for reporting your investigation back to us! |
| Comment by Roman Kovařík [ 14/Nov/22 ] |
|
Thanks Jdev, I can also confirm https://www.jrebel.com/products/jrebel/download/nightly-build workarounds the issue as well. |
| Comment by Janek Valgma [ 15/Nov/22 ] |
|
No problem, glad to hear it works! |