Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Overlay of Combined Resources #10760

Merged
merged 25 commits into from
Oct 25, 2023

Conversation

janbartel
Copy link
Contributor

Changes to the Resource class in jetty-12 lead to the breakage of war overlays for the jetty maven plugin, and also the scanning of directories when the base resource of a webapp is a CombinedResource.

@janbartel janbartel self-assigned this Oct 20, 2023
Copy link
Contributor

@gregw gregw left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know this was my suggested fix, but it is not correct. We need to stay within the Resource abstraction.

gregw added 8 commits October 23, 2023 13:08
Added `contains` and `getPathTo` methods to the Resource API, so they can be used by the AnnotationParser
Added `contains` and `getPathTo` methods to the Resource API, so they can be used by the AnnotationParser
Added `contains` and `getPathTo` methods to the Resource API, so they can be used by the AnnotationParser
Added `contains` and `getPathTo` methods to the Resource API, so they can be used by the AnnotationParser
Fixed numerous bugs in CombinedResource list and getAllResources
Added `contains` and `getPathTo` methods to the Resource API, so they can be used by the AnnotationParser
Fixed numerous bugs in CombinedResource list and getAllResources
Added `contains` and `getPathTo` methods to the Resource API, so they can be used by the AnnotationParser
Fixed numerous bugs in CombinedResource list and getAllResources
Added `contains` and `getPathTo` methods to the Resource API, so they can be used by the AnnotationParser
Fixed numerous bugs in CombinedResource list and getAllResources
Added `contains` and `getPathTo` methods to the Resource API, so they can be used by the AnnotationParser
Fixed numerous bugs in CombinedResource list and getAllResources
gregw
gregw previously approved these changes Oct 24, 2023
@gregw gregw requested review from lorban and removed request for sbordet October 24, 2023 00:02
Copy link
Contributor

@joakime joakime left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Out of 6 suspect APIs.
I've found 2 broken APIs so far.
Still working on writing tests for the other 4.

CombinedResource.copyTo(Resource)

  • test if destination is a different file system type (BROKEN, have fixed code)

CombinedResource.contains(Resource other)

  • test if other is a different file system type

CombinedResource.getPathTo(Resource other)

  • test if other is a different file system type

Resource.contains(Resource other)

  • test if other is a different file system type
  • test if self is 1 JAR, and other is a different JAR

Resource.getPathTo(Resource other)

  • test if other is a different file system type (BROKEN, not possible to fix, revert?)

Resource.getAllResources()

  • test what happens if you have a symlink loop

Path relative = base.relativize(path);

int count = relative.getNameCount();
int count = path.getNameCount();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This version of FileID.isHidden() isn't useful for anyone.

Only the isHidden(Path base, Path path) version is meaningful.

If we have a baseResource like /path/.hidden/jetty/base and a test path within it of web/index.html, then this should return false on isHidden(base, path).

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All the two arg version was/is doing is getting the relative path and checking the segments. This is just the version for code that already has the relative path.

@joakime
Copy link
Contributor

joakime commented Oct 24, 2023

I created a PR #10776 with extra testing (and fixes) for this PR.
@gregw need you to review that one too.

Added `contains` and `getPathTo` methods to the Resource API, so they can be used by the AnnotationParser
Fixed numerous bugs in CombinedResource list and getAllResources
Reduced fallback to URI string manipulation.
@gregw
Copy link
Contributor

gregw commented Oct 25, 2023

@joakime I merged your PR, but have subsequently modified it to reduce the usage of URI string manipulation, as that is very error prone (for example a startWith is not sufficient as you also need to check the next character is a '/').

@gregw gregw requested a review from joakime October 25, 2023 01:21
gregw added 2 commits October 25, 2023 12:30
Added `contains` and `getPathTo` methods to the Resource API, so they can be used by the AnnotationParser
Fixed numerous bugs in CombinedResource list and getAllResources
Reduced fallback to URI string manipulation.
Added `contains` and `getPathTo` methods to the Resource API, so they can be used by the AnnotationParser
Fixed numerous bugs in CombinedResource list and getAllResources
Reduced fallback to URI string manipulation.
Added `contains` and `getPathTo` methods to the Resource API, so they can be used by the AnnotationParser
Fixed numerous bugs in CombinedResource list and getAllResources
Reduced fallback to URI string manipulation.
@gregw gregw requested review from lorban and gregw October 25, 2023 11:38
@joakime
Copy link
Contributor

joakime commented Oct 25, 2023

This branch is failing the following tests ...

[ERROR] Failures: 
[ERROR]   ResourceListingTest.testBasicResourceXHtmlListingDeep:101 expected: <true> but was: <false>
[ERROR]   ResourceListingTest.testBasicResourceXHtmlListingRoot:72 expected: <true> but was: <false>
[ERROR]   ResourceListingTest.testListingEncoding:293 expected: <true> but was: <false>
[ERROR]   ResourceListingTest.testListingFilenamesOnly:199 expected: <true> but was: <false>\
[ERROR]   ResourceListingTest.testListingProperUrlEncoding:238 expected: <true> but was: <false>
[ERROR]   ResourceListingTest.testListingWithQuestionMarks:269 expected: <true> but was: <false>
[ERROR]   ResourceListingTest.testResourceCollectionXHtmlListingContext:143 expected: <true> but was: <false>

Oddly, these are failing on assertTrue(isValidXHtml(content)); tests.

@joakime
Copy link
Contributor

joakime commented Oct 25, 2023

Ah, those are failing due to ...

java.io.IOException: Server returned HTTP response code: 429 for URL: http://www.w3.org/MarkUp/DTD/xhtml-object-1.mod
	at java.base/sun.net.www.protocol.http.HttpURLConnection.getInputStream0(HttpURLConnection.java:2000)
	at java.base/sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1589)
	at java.xml/com.sun.org.apache.xerces.internal.impl.XMLEntityManager.setupCurrentEntity(XMLEntityManager.java:677)
	at java.xml/com.sun.org.apache.xerces.internal.impl.XMLEntityManager.startEntity(XMLEntityManager.java:1397)
	at java.xml/com.sun.org.apache.xerces.internal.impl.XMLEntityManager.startEntity(XMLEntityManager.java:1333)
	at java.xml/com.sun.org.apache.xerces.internal.impl.XMLDTDScannerImpl.startPE(XMLDTDScannerImpl.java:732)
	at java.xml/com.sun.org.apache.xerces.internal.impl.XMLDTDScannerImpl.skipSeparator(XMLDTDScannerImpl.java:2101)
	at java.xml/com.sun.org.apache.xerces.internal.impl.XMLDTDScannerImpl.scanDecls(XMLDTDScannerImpl.java:2064)
	at java.xml/com.sun.org.apache.xerces.internal.impl.XMLDTDScannerImpl.scanDTDExternalSubset(XMLDTDScannerImpl.java:299)
	at java.xml/com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl$DTDDriver.dispatch(XMLDocumentScannerImpl.java:1165)
	at java.xml/com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl$DTDDriver.next(XMLDocumentScannerImpl.java:1040)
	at java.xml/com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl$PrologDriver.next(XMLDocumentScannerImpl.java:943)
	at java.xml/com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next(XMLDocumentScannerImpl.java:605)
	at java.xml/com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(XMLDocumentFragmentScannerImpl.java:542)
	at java.xml/com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:889)
	at java.xml/com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:825)
	at java.xml/com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(XMLParser.java:141)
	at java.xml/com.sun.org.apache.xerces.internal.parsers.DOMParser.parse(DOMParser.java:247)
	at java.xml/com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderImpl.parse(DocumentBuilderImpl.java:342)
	at java.xml/javax.xml.parsers.DocumentBuilder.parse(DocumentBuilder.java:122)
	at org.eclipse.jetty.server@12.0.3-SNAPSHOT/org.eclipse.jetty.server.ResourceListingTest.isValidXHtml(ResourceListingTest.java:335)
	at org.eclipse.jetty.server@12.0.3-SNAPSHOT/org.eclipse.jetty.server.ResourceListingTest.testBasicResourceXHtmlListingDeep(ResourceListingTest.java:101)

Something @olamy is taking care of.

I'll merge this branch up from jetty-12.0.x HEAD now, it should correct these test failures.

@gregw
Copy link
Contributor

gregw commented Oct 25, 2023

Merging as CI failures are unrelated.

@gregw gregw merged commit 3ae4396 into jetty-12.0.x Oct 25, 2023
2 checks passed
@joakime joakime deleted the jetty-12.0.x-overlay-combined-resources branch October 26, 2023 15:44
@joakime joakime changed the title Jetty 12.0.x overlay combined resources Fix Overlay of Combined Resources Oct 30, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
No open projects
Status: ✅ Done
Development

Successfully merging this pull request may close these issues.

4 participants