spring-batch
spring-batch copied to clipboard
ExecutionContextDao API Clarification [BATCH-1858]
Robert Fischer opened BATCH-1858 and commented
What should the behavior be here?
assertTrue(jobExecution.getExecutionContext() != null); mapExecutionContextDao.updateExecutionContext(jobExecution); jobExecution.setExecutionContext(null); mapExecutionContextDao.updateExecutionContext(jobExecution); assert???(mapExecutionContextDao.getExecutionContext(jobExecution) == null);
As of now, it will return non-null.
I'm aware that jobExecutions should never have a null execution context, and hence the trivial priority on this. We should probably be intentional about what we want to do here. I'd be inclined to either throw an exception if we are told to update the execution context with a null execution context on the assumption that something has gone horribly awry, or to allow it to be updated to null on the assumption that the user should know what they're doing.
Affects: 2.2.0
Dave Syer commented
Agree that it should never be null. We can throw an exception in the setter, but it does seem trivial, and there are plenty of other places where null checks are not done to reduce the volume of code where the probability of it happening is low.