mirror of https://github.com/apache/lucene.git
SOLR-13411: reject incremental update for route.field, uniqueKey and
_version_.
This commit is contained in:
parent
d9c43d9fa3
commit
3befb8be94
|
@ -185,6 +185,8 @@ Bug Fixes
|
|||
|
||||
* SOLR-14250: Do not log error when trying to consume non-existing input stream due to Expect: 100-continue (janhoy)
|
||||
|
||||
* SOLR-13411: Deny atomic update for route.field, uniqueKey, version and throw exception. (Dr Oleg Savrasov via Mikhail Khludnev)
|
||||
|
||||
Other Changes
|
||||
---------------------
|
||||
|
||||
|
|
|
@ -183,12 +183,17 @@ public class AtomicUpdateDocumentMerger {
|
|||
// first pass, check the things that are virtually free,
|
||||
// and bail out early if anything is obviously not a valid in-place update
|
||||
for (String fieldName : sdoc.getFieldNames()) {
|
||||
Object fieldValue = sdoc.getField(fieldName).getValue();
|
||||
if (fieldName.equals(uniqueKeyFieldName)
|
||||
|| fieldName.equals(CommonParams.VERSION_FIELD)
|
||||
|| fieldName.equals(routeFieldOrNull)) {
|
||||
continue;
|
||||
if (fieldValue instanceof Map ) {
|
||||
throw new SolrException(SolrException.ErrorCode.BAD_REQUEST,
|
||||
"Updating unique key, version or route field is not allowed: " + sdoc.getField(fieldName));
|
||||
} else {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
Object fieldValue = sdoc.getField(fieldName).getValue();
|
||||
if (! (fieldValue instanceof Map) ) {
|
||||
// not an in-place update if there are fields that are not maps
|
||||
return Collections.emptySet();
|
||||
|
|
|
@ -113,14 +113,20 @@ public class TestInPlaceUpdateWithRouteField extends SolrCloudTestCase {
|
|||
newVersion > initialVersion);
|
||||
Assert.assertThat( "Doc value must be updated", solrDocument.get("inplace_updatable_int"), is(newDocValue));
|
||||
Assert.assertThat("Lucene doc id should not be changed for In-Place Updates.", solrDocument.get("[docid]"), is(luceneDocId));
|
||||
|
||||
|
||||
sdoc.remove("shardName");
|
||||
checkWrongCommandFailure(sdoc);
|
||||
|
||||
sdoc.addField("shardName", map("set", "newShardName"));
|
||||
checkWrongCommandFailure(sdoc);
|
||||
}
|
||||
|
||||
private void checkWrongCommandFailure(SolrInputDocument sdoc) throws SolrServerException, IOException {
|
||||
try {
|
||||
sdoc.remove("shardName");
|
||||
new UpdateRequest()
|
||||
.add(sdoc).process(cluster.getSolrClient(), COLLECTION);
|
||||
fail("expect an exception w/o route field");
|
||||
}catch(SolrException ex) {
|
||||
assertThat("expecting 400 in "+ex.getMessage(), ex.code(), is(400));
|
||||
new UpdateRequest().add(sdoc).process(cluster.getSolrClient(), COLLECTION);
|
||||
fail("expect an exception for wrong update command");
|
||||
} catch (SolrException ex) {
|
||||
assertThat("expecting 400 in " + ex.getMessage(), ex.code(), is(400));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -203,7 +203,7 @@ public class TestUpdate extends SolrTestCaseJ4 {
|
|||
);
|
||||
resetExceptionIgnores();
|
||||
assertEquals(400, se.code());
|
||||
assertTrue(se.getMessage().contains("Invalid update of id field"));
|
||||
assertTrue(se.getMessage().contains("Updating unique key, version or route field is not allowed"));
|
||||
|
||||
afterUpdate.call();
|
||||
|
||||
|
|
Loading…
Reference in New Issue