mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-07-31 17:39:05 +00:00
RM-7169 : Disposition Lifecycle job runs in a infinite loop (#528)
batchSize will default to 500 if the given value is smaller than 1 added unit test.
This commit is contained in:
committed by
GitHub
parent
9aee1567b4
commit
804c70d7f2
@@ -62,6 +62,7 @@ public class DispositionLifecycleJobExecuter extends RecordsManagementJobExecute
|
||||
|
||||
/** batching properties */
|
||||
private int batchSize;
|
||||
public static final int DEFAULT_BATCH_SIZE = 500;
|
||||
|
||||
/** list of disposition actions to automatically execute */
|
||||
private List<String> dispositionActions;
|
||||
@@ -175,6 +176,20 @@ public class DispositionLifecycleJobExecuter extends RecordsManagementJobExecute
|
||||
{
|
||||
boolean hasMore = true;
|
||||
int skipCount = 0;
|
||||
|
||||
if (batchSize < 1)
|
||||
{
|
||||
if (logger.isDebugEnabled())
|
||||
{
|
||||
logger.debug("Invalid value for batch size: " + batchSize + " default value used instead.");
|
||||
}
|
||||
batchSize = DEFAULT_BATCH_SIZE;
|
||||
}
|
||||
if (logger.isTraceEnabled())
|
||||
{
|
||||
logger.trace("Using batch size of " + batchSize);
|
||||
}
|
||||
|
||||
while (hasMore)
|
||||
{
|
||||
SearchParameters params = new SearchParameters();
|
||||
|
@@ -73,6 +73,7 @@ public class DispositionLifecycleJobExecuterUnitTest extends BaseUnitTest
|
||||
private static final String CUTOFF = "cutoff";
|
||||
private static final String RETAIN = "retain";
|
||||
private static final String DESTROY = "destroy";
|
||||
private static final int BATCH_SIZE = 1;
|
||||
|
||||
/** test query snippet */
|
||||
private static final String QUERY = "\"" + CUTOFF + "\" OR \"" + RETAIN + "\"";
|
||||
@@ -102,7 +103,7 @@ public class DispositionLifecycleJobExecuterUnitTest extends BaseUnitTest
|
||||
// setup data
|
||||
List<String> dispositionActions = buildList(CUTOFF, RETAIN);
|
||||
executer.setDispositionActions(dispositionActions);
|
||||
executer.setBatchSize(1);
|
||||
executer.setBatchSize(BATCH_SIZE);
|
||||
|
||||
// setup interactions
|
||||
doReturn(mockedResultSet).when(mockedSearchService).query(any(SearchParameters.class));
|
||||
@@ -333,4 +334,22 @@ public class DispositionLifecycleJobExecuterUnitTest extends BaseUnitTest
|
||||
verify(mockedNodeService).exists(node4);
|
||||
verify(mockedSearchService, times(2)).query(any(SearchParameters.class));
|
||||
}
|
||||
|
||||
/**
|
||||
* Given a batch size < 1
|
||||
* Then the executer use default value instead
|
||||
*/
|
||||
@Test
|
||||
public void testInvalidBatchSize()
|
||||
{
|
||||
executer.setBatchSize(0);
|
||||
executer.executeImpl();
|
||||
|
||||
ArgumentCaptor<SearchParameters> paramsCaptor = ArgumentCaptor.forClass(SearchParameters.class);
|
||||
verify(mockedSearchService, times(1)).query(paramsCaptor.capture());;
|
||||
assertEquals(executer.DEFAULT_BATCH_SIZE, paramsCaptor.getValue().getMaxItems());
|
||||
verify(mockedResultSet, times(1)).close();
|
||||
|
||||
executer.setBatchSize(BATCH_SIZE);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user