janhoy commented on code in PR #4249:
URL: https://github.com/apache/solr/pull/4249#discussion_r3279486385


##########
solr/core/src/java/org/apache/solr/handler/configsets/UploadConfigSet.java:
##########
@@ -85,22 +89,41 @@ public SolrJerseyResponse uploadConfigSet(
       filesToDelete = new ArrayList<>();
     }
 
-    try (ZipInputStream zis = new ZipInputStream(requestBody, 
StandardCharsets.UTF_8)) {
-      boolean hasEntry = false;
-      ZipEntry zipEntry;
-      while ((zipEntry = zis.getNextEntry()) != null) {
-        hasEntry = true;
-        String filePath = zipEntry.getName();
-        filesToDelete.remove(filePath);
-        if (!zipEntry.isDirectory()) {
-          configSetService.uploadFileToConfig(configSetName, filePath, 
zis.readAllBytes(), true);
+    // Write the request body to a temp file so we can use ZipFile, which 
reads the central
+    // directory and correctly handles entries that use the STORED method with 
an EXT (data
+    // descriptor) flag — a combination that ZipInputStream cannot process.  
This allows
+    // zero-byte files (e.g. created with `touch`) to be included in the 
uploaded configset.
+    final Path tempZip = Files.createTempFile("solr-configset-upload-", 
".zip");
+    try {
+      Files.copy(requestBody, tempZip, StandardCopyOption.REPLACE_EXISTING);

Review Comment:
   Do we need a guard against huge streams here, e.g. 2Gb, or is that handled 
elsewhere on the network layer?



-- 
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]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to