You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by er...@apache.org on 2020/11/22 14:23:54 UTC
[lucene-solr] branch master updated: SOLR-14993: Unable to download
zookeeper files of 1byte in size
This is an automated email from the ASF dual-hosted git repository.
erick pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/lucene-solr.git
The following commit(s) were added to refs/heads/master by this push:
new 77a2053 SOLR-14993: Unable to download zookeeper files of 1byte in size
77a2053 is described below
commit 77a205387f697ed8bf86af2623b111ec11c8ac95
Author: Erick Erickson <Er...@gmail.com>
AuthorDate: Sun Nov 22 09:23:44 2020 -0500
SOLR-14993: Unable to download zookeeper files of 1byte in size
---
solr/CHANGES.txt | 2 ++
.../apache/solr/common/cloud/ZkMaintenanceUtils.java | 2 +-
.../solr/common/cloud/TestZkMaintenanceUtils.java | 20 ++++++++++++++++++++
3 files changed, 23 insertions(+), 1 deletion(-)
diff --git a/solr/CHANGES.txt b/solr/CHANGES.txt
index a9b2514..8db9795 100644
--- a/solr/CHANGES.txt
+++ b/solr/CHANGES.txt
@@ -204,6 +204,8 @@ Bug Fixes
* SOLR-14983: Fix response returning original score instead of reranked score due to query and filter combining.
(Krishan Goyal, Jason Baik, Christine Poerschke)
+* SOLR-14993: Unable to download zookeeper files of 1byte in size (Erick Erickson, Allen Sooredoo)
+
Other Changes
---------------------
diff --git a/solr/solrj/src/java/org/apache/solr/common/cloud/ZkMaintenanceUtils.java b/solr/solrj/src/java/org/apache/solr/common/cloud/ZkMaintenanceUtils.java
index e3e61a4..04e80ac 100644
--- a/solr/solrj/src/java/org/apache/solr/common/cloud/ZkMaintenanceUtils.java
+++ b/solr/solrj/src/java/org/apache/solr/common/cloud/ZkMaintenanceUtils.java
@@ -332,7 +332,7 @@ public class ZkMaintenanceUtils {
private static int copyDataDown(SolrZkClient zkClient, String zkPath, File file) throws IOException, KeeperException, InterruptedException {
byte[] data = zkClient.getData(zkPath, null, null, true);
- if (data != null && data.length > 1) { // There are apparently basically empty ZNodes.
+ if (data != null && data.length > 0) { // There are apparently basically empty ZNodes.
log.info("Writing file {}", file);
Files.write(file.toPath(), data);
return data.length;
diff --git a/solr/solrj/src/test/org/apache/solr/common/cloud/TestZkMaintenanceUtils.java b/solr/solrj/src/test/org/apache/solr/common/cloud/TestZkMaintenanceUtils.java
index 661844a..4adb0ed 100644
--- a/solr/solrj/src/test/org/apache/solr/common/cloud/TestZkMaintenanceUtils.java
+++ b/solr/solrj/src/test/org/apache/solr/common/cloud/TestZkMaintenanceUtils.java
@@ -16,10 +16,12 @@
*/
package org.apache.solr.common.cloud;
+import java.io.FileInputStream;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.nio.charset.StandardCharsets;
import java.nio.file.Path;
+import java.nio.file.Paths;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
@@ -142,6 +144,24 @@ public class TestZkMaintenanceUtils extends SolrTestCaseJ4 {
}
}
+ // SOLR-14993
+ @Test
+ public void testOneByteFile() throws Exception {
+ try (SolrZkClient zkClient = new SolrZkClient(zkServer.getZkHost(), 10000)) {
+ byte[] oneByte = new byte[1];
+ oneByte[0] = 0x30;
+ zkClient.makePath("/test1byte/one", oneByte, true);
+
+ Path tmpDest = Paths.get(createTempDir().toFile().getAbsolutePath(), "MustBeOne");
+ ZkMaintenanceUtils.downloadFromZK(zkClient, "/test1byte/one", tmpDest);
+
+ try (FileInputStream fis = new FileInputStream(tmpDest.toFile())) {
+ byte[] data = fis.readAllBytes();
+ assertEquals("Should have downloaded a one-byte file", data.length, 1);
+ assertEquals("contents of the one-byte file should be 0x30", 0x30, data[0]);
+ }
+ }
+ }
private List<String> getTraverseedZNodes(SolrZkClient zkClient, String path, ZkMaintenanceUtils.VISIT_ORDER visitOrder) throws KeeperException, InterruptedException {
List<String> result = new ArrayList<>();
ZkMaintenanceUtils.traverseZkTree(zkClient, path, visitOrder, new ZkMaintenanceUtils.ZkVisitor() {