Pankraz76 commented on code in PR #2312: URL: https://github.com/apache/maven/pull/2312#discussion_r2083277751
########## impl/maven-impl/src/main/java/org/apache/maven/impl/DefaultPluginXmlFactory.java: ########## @@ -45,58 +48,71 @@ @Named @Singleton public class DefaultPluginXmlFactory implements PluginXmlFactory { + @Override public PluginDescriptor read(@Nonnull XmlReaderRequest request) throws XmlReaderException { nonNull(request, "request"); Path path = request.getPath(); URL url = request.getURL(); Reader reader = request.getReader(); InputStream inputStream = request.getInputStream(); - if (path == null && url == null && reader == null && inputStream == null) { + if (inputStream == null && reader == null && path == null && url == null) { throw new IllegalArgumentException("path, url, reader or inputStream must be non null"); } + return read(request.isAddDefaultEntities(), request.isStrict(), inputStream, reader, path, url); + } + + private static PluginDescriptor read( + boolean addDefaultEntities, boolean strict, InputStream inputStream, Reader reader, Path path, URL url) { try { PluginDescriptorStaxReader xml = new PluginDescriptorStaxReader(); - xml.setAddDefaultEntities(request.isAddDefaultEntities()); + xml.setAddDefaultEntities(addDefaultEntities); if (inputStream != null) { - return xml.read(inputStream, request.isStrict()); + return read(xml, inputStream, strict); } else if (reader != null) { - return xml.read(reader, request.isStrict()); + return xml.read(reader, strict); } else if (path != null) { try (InputStream is = Files.newInputStream(path)) { - return xml.read(is, request.isStrict()); - } - } else { - try (InputStream is = url.openStream()) { - return xml.read(is, request.isStrict()); + return read(xml, is, strict); } Review Comment: now we have test for all 4 cases which of course are mandatory as different. But only in the stream the result is the same. @gnodet This is now clear as DRY was not given dedicated concern. <img width="1585" alt="image" src="https://github.com/user-attachments/assets/b678aa14-ff85-4ebe-8627-75a5fdb3ac9d" /> -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: issues-unsubscr...@maven.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org