This is an automated email from the ASF dual-hosted git repository.
krisden pushed a commit to branch branch_9x
in repository https://gitbox.apache.org/repos/asf/solr.git
The following commit(s) were added to refs/heads/branch_9x by this push:
new 5edb11e SOLR-15973: Fix
TestSchemaDesignerConfigSetHelper#testDownloadAndZip failure on Windows
5edb11e is described below
commit 5edb11efaaeb46ae18c4fd982fd4ef6685f9e77a
Author: Kevin Risden <[email protected]>
AuthorDate: Wed Feb 2 11:50:52 2022 -0500
SOLR-15973: Fix TestSchemaDesignerConfigSetHelper#testDownloadAndZip
failure on Windows
Also removes an unnecessary filePath.endsWith
check in ConfigSetsHandler since it has a similar
OS separator specific check that isn't needed.
---
.../solr/handler/admin/ConfigSetsHandler.java | 28 ++++++++++------------
.../TestSchemaDesignerConfigSetHelper.java | 6 +++--
2 files changed, 16 insertions(+), 18 deletions(-)
diff --git
a/solr/core/src/java/org/apache/solr/handler/admin/ConfigSetsHandler.java
b/solr/core/src/java/org/apache/solr/handler/admin/ConfigSetsHandler.java
index abf23ff..d3ff712 100644
--- a/solr/core/src/java/org/apache/solr/handler/admin/ConfigSetsHandler.java
+++ b/solr/core/src/java/org/apache/solr/handler/admin/ConfigSetsHandler.java
@@ -225,26 +225,22 @@ public class ConfigSetsHandler extends RequestHandlerBase
implements PermissionN
// For creating the baseZnode, the cleanup parameter is only allowed to be
true when singleFilePath is not passed.
createBaseNode(configSetService, overwritesExisting, requestIsTrusted,
configSetName);
- ZipInputStream zis = new ZipInputStream(inputStream,
StandardCharsets.UTF_8);
- ZipEntry zipEntry = null;
- boolean hasEntry = false;
- while ((zipEntry = zis.getNextEntry()) != null) {
- hasEntry = true;
- String filePath = zipEntry.getName();
- if (filePath.endsWith("/")) {
- filesToDelete.remove(filePath.substring(0, filePath.length() - 1));
- } else {
+ try(ZipInputStream zis = new ZipInputStream(inputStream,
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,
IOUtils.toByteArray(zis), true);
+ }
}
- if (!zipEntry.isDirectory()) {
- configSetService.uploadFileToConfig(configSetName, zipEntry.getName(),
IOUtils.toByteArray(zis), true);
+ if (!hasEntry) {
+ throw new SolrException(ErrorCode.BAD_REQUEST,
+ "Either empty zipped data, or non-zipped data was uploaded. In
order to upload a configSet, you must zip a non-empty directory to upload.");
}
}
- zis.close();
- if (!hasEntry) {
- throw new SolrException(ErrorCode.BAD_REQUEST,
- "Either empty zipped data, or non-zipped data was uploaded. In
order to upload a configSet, you must zip a non-empty directory to upload.");
- }
deleteUnusedFiles(configSetService, configSetName, filesToDelete);
// If the request is doing a full trusted overwrite of an untrusted
configSet (overwrite=true, cleanup=true), then trust the configSet.
diff --git
a/solr/core/src/test/org/apache/solr/handler/designer/TestSchemaDesignerConfigSetHelper.java
b/solr/core/src/test/org/apache/solr/handler/designer/TestSchemaDesignerConfigSetHelper.java
index d25d055..cb96303 100644
---
a/solr/core/src/test/org/apache/solr/handler/designer/TestSchemaDesignerConfigSetHelper.java
+++
b/solr/core/src/test/org/apache/solr/handler/designer/TestSchemaDesignerConfigSetHelper.java
@@ -126,9 +126,11 @@ public class TestSchemaDesignerConfigSetHelper extends
SolrCloudTestCase impleme
ZipEntry entry;
while ((entry = stream.getNextEntry()) != null) {
- if ("solrconfig.xml".equals(entry.getName())) {
+ // ZipEntry names have file separators that are OS specific. This
normalizes to forward slash.
+ String entryName = entry.getName().replace('\\', '/');
+ if ("solrconfig.xml".equals(entryName)) {
foundSolrConfig = true;
- } else if ("lang/stopwords_en.txt".equals(entry.getName())) {
+ } else if ("lang/stopwords_en.txt".equals(entryName)) {
foundStopWords = true;
}
}