mirror of https://github.com/apache/lucene.git
SOLR-13238: BlobHandler generates non-padded md5
This commit is contained in:
parent
ae570e4694
commit
31735eeb40
|
@ -206,6 +206,8 @@ Bug Fixes
|
||||||
* SOLR-13240: Fixed UTILIZENODE action resulting in IllegalArgumentException.
|
* SOLR-13240: Fixed UTILIZENODE action resulting in IllegalArgumentException.
|
||||||
(Hendrik Haddorp, Richard Goodman, Tim Owen, shalin, noble, Christine Poerschke)
|
(Hendrik Haddorp, Richard Goodman, Tim Owen, shalin, noble, Christine Poerschke)
|
||||||
|
|
||||||
|
* SOLR-13238: BlobHandler generates non-padded md5 (Jeff Walraven via janhoy)
|
||||||
|
|
||||||
Other Changes
|
Other Changes
|
||||||
----------------------
|
----------------------
|
||||||
|
|
||||||
|
|
|
@ -20,7 +20,6 @@ import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.io.OutputStream;
|
import java.io.OutputStream;
|
||||||
import java.lang.invoke.MethodHandles;
|
import java.lang.invoke.MethodHandles;
|
||||||
import java.math.BigInteger;
|
|
||||||
import java.nio.ByteBuffer;
|
import java.nio.ByteBuffer;
|
||||||
import java.security.MessageDigest;
|
import java.security.MessageDigest;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
|
@ -28,6 +27,7 @@ import java.util.Date;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
|
import org.apache.commons.codec.binary.Hex;
|
||||||
import org.apache.lucene.document.Document;
|
import org.apache.lucene.document.Document;
|
||||||
import org.apache.lucene.index.IndexableField;
|
import org.apache.lucene.index.IndexableField;
|
||||||
import org.apache.lucene.index.Term;
|
import org.apache.lucene.index.Term;
|
||||||
|
@ -114,7 +114,7 @@ public class BlobHandler extends RequestHandlerBase implements PluginInfoInitial
|
||||||
}
|
}
|
||||||
MessageDigest m = MessageDigest.getInstance("MD5");
|
MessageDigest m = MessageDigest.getInstance("MD5");
|
||||||
m.update(payload.array(), payload.position(), payload.limit());
|
m.update(payload.array(), payload.position(), payload.limit());
|
||||||
String md5 = new BigInteger(1, m.digest()).toString(16);
|
String md5 = new String(Hex.encodeHex(m.digest()));
|
||||||
|
|
||||||
int duplicateCount = req.getSearcher().count(new TermQuery(new Term("md5", md5)));
|
int duplicateCount = req.getSearcher().count(new TermQuery(new Term("md5", md5)));
|
||||||
if (duplicateCount > 0) {
|
if (duplicateCount > 0) {
|
||||||
|
|
|
@ -20,7 +20,6 @@ import java.io.IOException;
|
||||||
import java.lang.invoke.MethodHandles;
|
import java.lang.invoke.MethodHandles;
|
||||||
import java.nio.ByteBuffer;
|
import java.nio.ByteBuffer;
|
||||||
import java.nio.charset.StandardCharsets;
|
import java.nio.charset.StandardCharsets;
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import org.apache.http.HttpEntity;
|
import org.apache.http.HttpEntity;
|
||||||
|
@ -86,6 +85,7 @@ public class TestBlobHandler extends AbstractFullDistribZkTestBase {
|
||||||
"type"),null));
|
"type"),null));
|
||||||
|
|
||||||
checkBlobPost(baseUrl, cloudClient);
|
checkBlobPost(baseUrl, cloudClient);
|
||||||
|
checkBlobPostMd5(baseUrl, cloudClient);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -108,6 +108,15 @@ public class TestBlobHandler extends AbstractFullDistribZkTestBase {
|
||||||
compareInputAndOutput(baseUrl + "/.system/blob/test/1?wt=filestream", bytarr, cloudClient);
|
compareInputAndOutput(baseUrl + "/.system/blob/test/1?wt=filestream", bytarr, cloudClient);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void checkBlobPostMd5(String baseUrl, CloudSolrClient cloudClient) throws Exception {
|
||||||
|
String blobName = "md5Test";
|
||||||
|
String stringValue = "MHMyugAGUxFzeqbpxVemACGbQ"; // Random string requires padding in md5 hash
|
||||||
|
String stringValueMd5 = "02d82dd5aabc47fae54ee3dd236ad83d";
|
||||||
|
postAndCheck(cloudClient, baseUrl, blobName, ByteBuffer.wrap(stringValue.getBytes(StandardCharsets.UTF_8)), 1);
|
||||||
|
MapWriter map = TestSolrConfigHandlerConcurrent.getAsMap(baseUrl + "/.system/blob/" + blobName, cloudClient);
|
||||||
|
assertEquals(stringValueMd5, map._getStr("response/docs[0]/md5", null));
|
||||||
|
}
|
||||||
|
|
||||||
public static void createSystemCollection(SolrClient client) throws SolrServerException, IOException {
|
public static void createSystemCollection(SolrClient client) throws SolrServerException, IOException {
|
||||||
CollectionAdminResponse response1;
|
CollectionAdminResponse response1;
|
||||||
CollectionAdminRequest.Create createCollectionRequest = CollectionAdminRequest.createCollection(".system",1,2);
|
CollectionAdminRequest.Create createCollectionRequest = CollectionAdminRequest.createCollection(".system",1,2);
|
||||||
|
@ -121,7 +130,6 @@ public class TestBlobHandler extends AbstractFullDistribZkTestBase {
|
||||||
|
|
||||||
String url;
|
String url;
|
||||||
MapWriter map = null;
|
MapWriter map = null;
|
||||||
List l;
|
|
||||||
final RTimer timer = new RTimer();
|
final RTimer timer = new RTimer();
|
||||||
int i = 0;
|
int i = 0;
|
||||||
for (; i < 150; i++) {//15 secs
|
for (; i < 150; i++) {//15 secs
|
||||||
|
|
Loading…
Reference in New Issue