Skip to content

Commit b19617a

Browse files
authored
Merge pull request DSpace#12113 from toniprieto/exception-oai-uncache-entities
Avoid exception during OAI update caused by uncached entities
2 parents e4eda59 + c3ac49d commit b19617a

1 file changed

Lines changed: 10 additions & 8 deletions

File tree

  • dspace-oai/src/main/java/org/dspace/xoai/app

dspace-oai/src/main/java/org/dspace/xoai/app/XOAI.java

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -193,9 +193,9 @@ private int index(Instant last) throws DSpaceSolrIndexerException, IOException {
193193
.findInArchiveOrWithdrawnDiscoverableModifiedSince(context, last);
194194
Iterator<Item> nonDiscoverableChangedItems = itemService
195195
.findInArchiveOrWithdrawnNonDiscoverableModifiedSince(context, last);
196+
int total = this.index(discoverableChangedItems, true) + this.index(nonDiscoverableChangedItems, true);
196197
Iterator<Item> possiblyChangedItems = getItemsWithPossibleChangesBefore(last);
197-
return this.index(discoverableChangedItems) + this.index(nonDiscoverableChangedItems)
198-
+ this.index(possiblyChangedItems);
198+
return total + this.index(possiblyChangedItems, false);
199199
} catch (SQLException ex) {
200200
throw new DSpaceSolrIndexerException(ex.getMessage(), ex);
201201
}
@@ -266,7 +266,7 @@ private int indexAll() throws DSpaceSolrIndexerException {
266266
null);
267267
Iterator<Item> nonDiscoverableItems = itemService
268268
.findInArchiveOrWithdrawnNonDiscoverableModifiedSince(context, null);
269-
return this.index(discoverableItems) + this.index(nonDiscoverableItems);
269+
return this.index(discoverableItems, true) + this.index(nonDiscoverableItems, true);
270270
} catch (SQLException ex) {
271271
throw new DSpaceSolrIndexerException(ex.getMessage(), ex);
272272
}
@@ -309,7 +309,7 @@ private boolean checkIfVisibleInOAI(Item item) throws IOException {
309309
}
310310
}
311311

312-
private int index(Iterator<Item> iterator) throws DSpaceSolrIndexerException {
312+
private int index(Iterator<Item> iterator, boolean uncacheEntities) throws DSpaceSolrIndexerException {
313313
try {
314314
int i = 0;
315315
int batchSize = configurationService.getIntProperty("oai.import.batch.size", 1000);
@@ -338,10 +338,12 @@ private int index(Iterator<Item> iterator) throws DSpaceSolrIndexerException {
338338
server.add(list);
339339
server.commit();
340340
list.clear();
341-
try {
342-
context.uncacheEntities();
343-
} catch (SQLException ex) {
344-
log.error("Error uncaching entities", ex);
341+
if (uncacheEntities) {
342+
try {
343+
context.uncacheEntities();
344+
} catch (SQLException ex) {
345+
log.error("Error uncaching entities", ex);
346+
}
345347
}
346348
}
347349
}

0 commit comments

Comments
 (0)