mirror of https://github.com/apache/lucene.git
SOLR-14993: Unable to download zookeeper files of 1byte in size
This commit is contained in:
parent
8c7b709c08
commit
77a205387f
|
@ -204,6 +204,8 @@ Bug Fixes
|
||||||
* SOLR-14983: Fix response returning original score instead of reranked score due to query and filter combining.
|
* SOLR-14983: Fix response returning original score instead of reranked score due to query and filter combining.
|
||||||
(Krishan Goyal, Jason Baik, Christine Poerschke)
|
(Krishan Goyal, Jason Baik, Christine Poerschke)
|
||||||
|
|
||||||
|
* SOLR-14993: Unable to download zookeeper files of 1byte in size (Erick Erickson, Allen Sooredoo)
|
||||||
|
|
||||||
Other Changes
|
Other Changes
|
||||||
---------------------
|
---------------------
|
||||||
|
|
||||||
|
|
|
@ -332,7 +332,7 @@ public class ZkMaintenanceUtils {
|
||||||
|
|
||||||
private static int copyDataDown(SolrZkClient zkClient, String zkPath, File file) throws IOException, KeeperException, InterruptedException {
|
private static int copyDataDown(SolrZkClient zkClient, String zkPath, File file) throws IOException, KeeperException, InterruptedException {
|
||||||
byte[] data = zkClient.getData(zkPath, null, null, true);
|
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);
|
log.info("Writing file {}", file);
|
||||||
Files.write(file.toPath(), data);
|
Files.write(file.toPath(), data);
|
||||||
return data.length;
|
return data.length;
|
||||||
|
|
|
@ -16,10 +16,12 @@
|
||||||
*/
|
*/
|
||||||
package org.apache.solr.common.cloud;
|
package org.apache.solr.common.cloud;
|
||||||
|
|
||||||
|
import java.io.FileInputStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.UnsupportedEncodingException;
|
import java.io.UnsupportedEncodingException;
|
||||||
import java.nio.charset.StandardCharsets;
|
import java.nio.charset.StandardCharsets;
|
||||||
import java.nio.file.Path;
|
import java.nio.file.Path;
|
||||||
|
import java.nio.file.Paths;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
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 {
|
private List<String> getTraverseedZNodes(SolrZkClient zkClient, String path, ZkMaintenanceUtils.VISIT_ORDER visitOrder) throws KeeperException, InterruptedException {
|
||||||
List<String> result = new ArrayList<>();
|
List<String> result = new ArrayList<>();
|
||||||
ZkMaintenanceUtils.traverseZkTree(zkClient, path, visitOrder, new ZkMaintenanceUtils.ZkVisitor() {
|
ZkMaintenanceUtils.traverseZkTree(zkClient, path, visitOrder, new ZkMaintenanceUtils.ZkVisitor() {
|
||||||
|
|
Loading…
Reference in New Issue