SOLR-884 -- CachedSqlEntityProcessor should check if the cache key is present in the query results

git-svn-id: https://svn.apache.org/repos/asf/lucene/solr/trunk@725684 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Shalin Shekhar Mangar 2008-12-11 13:43:23 +00:00
parent 714d1c7ad7
commit c1d1c274ae
2 changed files with 20 additions and 0 deletions

View File

@ -76,6 +76,9 @@ Bug Fixes
11. SOLR-841: DataImportHandler should throw exception if a field does not have column attribute
(Michael Henson, shalin)
12. SOLR-884: CachedSqlEntityProcessor should check if the cache key is present in the query results
(Noble Paul via shalin)
Documentation
----------------------

View File

@ -341,6 +341,12 @@ public class EntityProcessorBase extends EntityProcessor {
.get(query);
List<Map<String, Object>> rows = null;
Object key = resolver.resolve(cacheVariableName);
if (key == null) {
throw new DataImportHandlerException(DataImportHandlerException.WARN,
"The cache lookup value : " + cacheVariableName + " is resolved to be null in the entity :" +
context.getEntityAttribute("name"));
}
if (rowIdVsRows != null) {
rows = rowIdVsRows.get(key);
if (rows == null)
@ -355,6 +361,17 @@ public class EntityProcessorBase extends EntityProcessor {
rowIdVsRows = new HashMap<Object, List<Map<String, Object>>>();
for (Map<String, Object> row : rows) {
Object k = row.get(cachePk);
if (k == null) {
throw new DataImportHandlerException(DataImportHandlerException.WARN,
"No value available for the cache key : " + cachePk + " in the entity : " +
context.getEntityAttribute("name"));
}
if (!k.getClass().equals(key.getClass())) {
throw new DataImportHandlerException(DataImportHandlerException.WARN,
"The key in the cache type : " + k.getClass().getName() +
"is not same as the lookup value type " + key.getClass().getName() + " in the entity " +
context.getEntityAttribute("name"));
}
if (rowIdVsRows.get(k) == null)
rowIdVsRows.put(k, new ArrayList<Map<String, Object>>());
rowIdVsRows.get(k).add(row);