gnodet commented on code in PR #1033:
URL: https://github.com/apache/maven/pull/1033#discussion_r1128428710


##########
maven-compat/src/main/java/org/apache/maven/artifact/repository/metadata/DefaultRepositoryMetadataManager.java:
##########
@@ -267,19 +266,17 @@ private boolean loadMetadata(
      * TODO share with DefaultPluginMappingManager.
      */
     protected Metadata readMetadata(File mappingFile) throws 
RepositoryMetadataReadException {
-        Metadata result;
 
-        try (Reader reader = ReaderFactory.newXmlReader(mappingFile)) {
-            MetadataXpp3Reader mappingReader = new MetadataXpp3Reader();
-
-            result = mappingReader.read(reader, false);
+        MetadataXpp3Reader mappingReader = new MetadataXpp3Reader();
+        try (InputStream in = Files.newInputStream(mappingFile.toPath())) {
+            Metadata result = mappingReader.read(in, false);
+            return result;
         } catch (FileNotFoundException e) {

Review Comment:
   I don't see the benefit of the change.
   `mappingReader.read( Files.newInputStream( mappingFile.toPath() ), false )` 
is exactly the same as `mappingReader.read( ReaderFactory.newXmlReader( 
mappingFile ), false )`.
   The reason is that the `read` method accepting an `InputStream` does create 
an xml reader using `ReaderFactory.newXmlReader`.



##########
maven-compat/src/main/java/org/apache/maven/artifact/repository/metadata/DefaultRepositoryMetadataManager.java:
##########
@@ -310,8 +307,8 @@ private void fixTimestamp(File metadataFile, Metadata 
metadata, Metadata referen
         if (changed) {
             getLogger().debug("Repairing metadata in " + metadataFile);
 
-            try (Writer writer = WriterFactory.newXmlWriter(metadataFile)) {
-                new MetadataXpp3Writer().write(writer, metadata);
+            try (OutputStream out = 
Files.newOutputStream(metadataFile.toPath())) {
+                new MetadataXpp3Writer().write(out, metadata);

Review Comment:
   If the change has an actual effect, this means that the `XmlWriter` created 
by the `WriterFactory` cannot detect the encoding properly.  If that's the 
case, it should also be fixed.



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to