SOLR-5367: Unmarshalling delete by id commands with JavaBin can lead to class cast exception.

git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1533683 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Mark Robert Miller 2013-10-19 03:23:33 +00:00
parent 02e255ae46
commit 457d1ac0c0
3 changed files with 18 additions and 7 deletions

View File

@ -105,6 +105,9 @@ Bug Fixes
* SOLR-5216: Document updates to SolrCloud can cause a distributed deadlock.
(Mark Miller)
* SOLR-5367: Unmarshalling delete by id commands with JavaBin can lead to class cast
exception. (Mark Miller)
Optimizations
----------------------

View File

@ -94,7 +94,7 @@ public class JavaBinUpdateRequestCodec {
List<List<NamedList>> doclist;
Map<SolrInputDocument,Map<String,Object>> docMap;
List<String> delById;
Map<String,Long> delByIdMap;
Map<String,Map<String,Object>> delByIdMap;
List<String> delByQ;
final NamedList[] namedList = new NamedList[1];
JavaBinCodec codec = new JavaBinCodec() {
@ -166,7 +166,7 @@ public class JavaBinUpdateRequestCodec {
}
}
delById = (List<String>) namedList[0].get("delById");
delByIdMap = (Map<String,Long>) namedList[0].get("delByIdMap");
delByIdMap = (Map<String,Map<String,Object>>) namedList[0].get("delByIdMap");
delByQ = (List<String>) namedList[0].get("delByQ");
doclist = (List) namedList[0].get("docs");
docMap = (Map<SolrInputDocument,Map<String,Object>>) namedList[0].get("docsMap");
@ -201,8 +201,15 @@ public class JavaBinUpdateRequestCodec {
}
}
if (delByIdMap != null) {
for (Map.Entry<String,Long> entry : delByIdMap.entrySet()) {
updateRequest.deleteById(entry.getKey(), entry.getValue());
for (Map.Entry<String,Map<String,Object>> entry : delByIdMap.entrySet()) {
Map<String,Object> params = entry.getValue();
if (params != null) {
Long version = (Long) params.get("ver");
updateRequest.deleteById(entry.getKey(), version);
} else {
updateRequest.deleteById(entry.getKey());
}
}
}
if (delByQ != null) {

View File

@ -47,6 +47,7 @@ import org.apache.solr.common.util.XML;
*/
public class UpdateRequest extends AbstractUpdateRequest {
private static final String VER = "ver";
public static final String OVERWRITE = "ow";
public static final String COMMIT_WITHIN = "cw";
private Map<SolrInputDocument,Map<String,Object>> documents = null;
@ -148,7 +149,7 @@ public class UpdateRequest extends AbstractUpdateRequest {
deleteById = new LinkedHashMap<String,Map<String,Object>>();
}
Map<String,Object> params = new HashMap<String,Object>(1);
params.put("ver", version);
params.put(VER, version);
deleteById.put(id, params);
return this;
}
@ -224,7 +225,7 @@ public class UpdateRequest extends AbstractUpdateRequest {
Map<String,Object> map = entry.getValue();
Long version = null;
if (map != null) {
version = (Long) map.get("ver");
version = (Long) map.get(VER);
}
Slice slice = router.getTargetSlice(deleteId, null, null, col);
if (slice == null) {
@ -371,7 +372,7 @@ public class UpdateRequest extends AbstractUpdateRequest {
writer.append("<id");
Map<String,Object> map = entry.getValue();
if (map != null) {
Long version = (Long) map.get("ver");
Long version = (Long) map.get(VER);
if (version != null) {
writer.append(" version=\"" + version + "\"");
}