diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/partition/support/RemoteStepExecutionAggregator.java b/spring-batch-core/src/main/java/org/springframework/batch/core/partition/support/RemoteStepExecutionAggregator.java index 452935d713..bf10af4ee0 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/partition/support/RemoteStepExecutionAggregator.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/partition/support/RemoteStepExecutionAggregator.java @@ -1,5 +1,5 @@ /* - * Copyright 2006-2025 the original author or authors. + * Copyright 2006-2026 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -78,8 +78,7 @@ public void aggregate(StepExecution result, Collection executions return; } Set stepExecutionIds = executions.stream().map(stepExecution -> { - Long id = stepExecution.getId(); - Assert.state(id != null, "StepExecution has null id. It must be saved first: " + stepExecution); + long id = stepExecution.getId(); return id; }).collect(Collectors.toSet()); JobExecution jobExecution = jobRepository.getJobExecution(result.getJobExecutionId()); diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/repository/dao/jdbc/JdbcExecutionContextDao.java b/spring-batch-core/src/main/java/org/springframework/batch/core/repository/dao/jdbc/JdbcExecutionContextDao.java index 01851af818..330c5ba571 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/repository/dao/jdbc/JdbcExecutionContextDao.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/repository/dao/jdbc/JdbcExecutionContextDao.java @@ -1,5 +1,5 @@ /* - * Copyright 2006-2025 the original author or authors. + * Copyright 2006-2026 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -151,8 +151,7 @@ public void setCharset(Charset charset) { @Override public ExecutionContext getExecutionContext(JobExecution jobExecution) { - Long executionId = jobExecution.getId(); - Assert.notNull(executionId, "ExecutionId must not be null."); + long executionId = jobExecution.getId(); List results = getJdbcTemplate().query(getQuery(FIND_JOB_EXECUTION_CONTEXT), new ExecutionContextRowMapper(), executionId); @@ -166,8 +165,7 @@ public ExecutionContext getExecutionContext(JobExecution jobExecution) { @Override public ExecutionContext getExecutionContext(StepExecution stepExecution) { - Long executionId = stepExecution.getId(); - Assert.notNull(executionId, "ExecutionId must not be null."); + long executionId = stepExecution.getId(); List results = getJdbcTemplate().query(getQuery(FIND_STEP_EXECUTION_CONTEXT), new ExecutionContextRowMapper(), executionId); @@ -181,9 +179,8 @@ public ExecutionContext getExecutionContext(StepExecution stepExecution) { @Override public void updateExecutionContext(JobExecution jobExecution) { - Long executionId = jobExecution.getId(); + long executionId = jobExecution.getId(); ExecutionContext executionContext = jobExecution.getExecutionContext(); - Assert.notNull(executionId, "ExecutionId must not be null."); Assert.notNull(executionContext, "The ExecutionContext must not be null."); String serializedContext = serializeContext(executionContext); @@ -197,9 +194,8 @@ public void updateExecutionContext(StepExecution stepExecution) { // someone is already trying to do it. this.lock.lock(); try { - Long executionId = stepExecution.getId(); + long executionId = stepExecution.getId(); ExecutionContext executionContext = stepExecution.getExecutionContext(); - Assert.notNull(executionId, "ExecutionId must not be null."); Assert.notNull(executionContext, "The ExecutionContext must not be null."); String serializedContext = serializeContext(executionContext); @@ -214,9 +210,8 @@ public void updateExecutionContext(StepExecution stepExecution) { @Override public void saveExecutionContext(JobExecution jobExecution) { - Long executionId = jobExecution.getId(); + long executionId = jobExecution.getId(); ExecutionContext executionContext = jobExecution.getExecutionContext(); - Assert.notNull(executionId, "ExecutionId must not be null."); Assert.notNull(executionContext, "The ExecutionContext must not be null."); String serializedContext = serializeContext(executionContext); @@ -226,9 +221,8 @@ public void saveExecutionContext(JobExecution jobExecution) { @Override public void saveExecutionContext(StepExecution stepExecution) { - Long executionId = stepExecution.getId(); + long executionId = stepExecution.getId(); ExecutionContext executionContext = stepExecution.getExecutionContext(); - Assert.notNull(executionId, "ExecutionId must not be null."); Assert.notNull(executionContext, "The ExecutionContext must not be null."); String serializedContext = serializeContext(executionContext); @@ -241,9 +235,8 @@ public void saveExecutionContexts(Collection stepExecutions) { Assert.notNull(stepExecutions, "Attempt to save an null collection of step executions"); Map serializedContexts = CollectionUtils.newHashMap(stepExecutions.size()); for (StepExecution stepExecution : stepExecutions) { - Long executionId = stepExecution.getId(); + long executionId = stepExecution.getId(); ExecutionContext executionContext = stepExecution.getExecutionContext(); - Assert.notNull(executionId, "ExecutionId must not be null."); Assert.notNull(executionContext, "The ExecutionContext must not be null."); serializedContexts.put(executionId, serializeContext(executionContext)); } @@ -279,7 +272,7 @@ public void afterPropertiesSet() throws Exception { * @param serializedContext the serialized context to persist * @param sql with parameters (shortContext, longContext, executionId) */ - private void persistSerializedContext(Long executionId, String serializedContext, String sql) { + private void persistSerializedContext(long executionId, String serializedContext, String sql) { final String shortContext; final String longContext; diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/repository/dao/jdbc/JdbcJobExecutionDao.java b/spring-batch-core/src/main/java/org/springframework/batch/core/repository/dao/jdbc/JdbcJobExecutionDao.java index 840afc99e1..f944dbfed9 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/repository/dao/jdbc/JdbcJobExecutionDao.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/repository/dao/jdbc/JdbcJobExecutionDao.java @@ -1,5 +1,5 @@ /* - * Copyright 2006-2025 the original author or authors. + * Copyright 2006-2026 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -251,9 +251,6 @@ public void updateJobExecution(JobExecution jobExecution) { validateJobExecution(jobExecution); - Assert.notNull(jobExecution.getId(), - "JobExecution ID cannot be null. JobExecution must be saved before it can be updated"); - Assert.notNull(jobExecution.getVersion(), "JobExecution version cannot be null. JobExecution must be saved before it can be updated"); diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/repository/dao/jdbc/JdbcStepExecutionDao.java b/spring-batch-core/src/main/java/org/springframework/batch/core/repository/dao/jdbc/JdbcStepExecutionDao.java index 884bc446b9..e6371bddb2 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/repository/dao/jdbc/JdbcStepExecutionDao.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/repository/dao/jdbc/JdbcStepExecutionDao.java @@ -1,5 +1,5 @@ /* - * Copyright 2006-2025 the original author or authors. + * Copyright 2006-2026 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -215,8 +215,6 @@ private void validateStepExecution(StepExecution stepExecution) { public void updateStepExecution(StepExecution stepExecution) { validateStepExecution(stepExecution); - Assert.notNull(stepExecution.getId(), - "StepExecution Id cannot be null. StepExecution must saved" + " before it can be updated."); // Do not check for existence of step execution considering // it is saved at every commit point.