Skip to content

build: Update to Java 17 #698

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ jobs:
runs-on: ubuntu-22.04
strategy:
matrix:
java: [ '11', '17', '21' ]
java: [ '17', '21' ]
name: Temurin ${{ matrix.java }}
steps:
- uses: actions/checkout@v3
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@ jobs:
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Set up JDK 11
- name: Set up JDK 17
uses: actions/setup-java@v3
with:
java-version: '11'
java-version: '17'
distribution: 'temurin'
cache: maven
- name: Set release version
Expand Down
2 changes: 1 addition & 1 deletion .sdkmanrc
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
# Enable auto-env through the sdkman_auto_env config
# Add key=value pairs of SDKs to use below
java=21-librca
java=17.0.14-librca
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* Ensure your Pull Request passes tests either locally or via Github Actions (once triggered by a maintainer it will run automatically on your PR)

### Tools needed to do development and execute tests
* Java 11 (since it's the lowest supported java version to date, although we do support newer versions and execute tests again those as well)
* Java 17 (since it's the lowest supported java version to date, although we do support newer versions and execute tests again those as well)
* Docker

### Running tests
Expand Down
9 changes: 6 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ See also [why not Quartz?](#why-db-scheduler-when-there-is-quartz)
<dependency>
<groupId>com.github.kagkarlsson</groupId>
<artifactId>db-scheduler</artifactId>
<version>15.1.1</version>
<version>16.0.0</version>
</dependency>
```

Expand Down Expand Up @@ -436,7 +436,7 @@ For Spring Boot applications, there is a starter `db-scheduler-spring-boot-start
<dependency>
<groupId>com.github.kagkarlsson</groupId>
<artifactId>db-scheduler-spring-boot-starter</artifactId>
<version>15.1.1</version>
<version>16.0.0</version>
</dependency>
```
**NOTE**: This includes the db-scheduler dependency itself.
Expand Down Expand Up @@ -634,6 +634,9 @@ There are a number of users that are using db-scheduler for high throughput use-

See [releases](https://github.com/kagkarlsson/db-scheduler/releases) for release-notes.

**Upgrading to 16.x**
* Java 17+ is required now, since we migrated our codebase to Java 17

**Upgrading to 15.x**
* Priority is a new opt-in feature. To be able to use it, column `priority` and index `priority_execution_time_idx`
must be added to the database schema. See table definitions for
Expand All @@ -659,7 +662,7 @@ See [releases](https://github.com/kagkarlsson/db-scheduler/releases) for release

**Prerequisites**

* Java 8+
* Java 17+
* Maven

Follow these steps:
Expand Down
5 changes: 2 additions & 3 deletions db-scheduler-boot-starter/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -94,9 +94,8 @@

<!-- Annotations -->
<dependency>
<groupId>javax.annotation</groupId>
<artifactId>javax.annotation-api</artifactId>
<version>1.3.2</version>
<groupId>jakarta.annotation</groupId>
<artifactId>jakarta.annotation-api</artifactId>
<scope>provided</scope>
</dependency>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ public void run() {

private void executePickedExecution(Execution execution, CurrentlyExecuting currentlyExecuting) {
final Optional<Task> task = taskResolver.resolve(execution.taskInstance.getTaskName());
if (!task.isPresent()) {
if (task.isEmpty()) {
LOG.error(
"Failed to find implementation for task with name '{}'. Should have been excluded in JdbcRepository.",
execution.taskInstance.getTaskName());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ public Optional<Execution> call() {

final Optional<Execution> pickedExecution = taskRepository.pick(candidate, clock.now());

if (!pickedExecution.isPresent()) {
if (pickedExecution.isEmpty()) {
// someone else picked id
LOG.debug("Execution picked by another scheduler. Continuing to next due execution.");
schedulerListeners.onCandidateEvent(CandidateEventType.ALREADY_PICKED);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,10 @@
*/
package com.github.kagkarlsson.scheduler.exceptions;

import java.io.Serial;

public class DataClassMismatchException extends DbSchedulerException {
private static final long serialVersionUID = 6333316294241471977L;
@Serial private static final long serialVersionUID = 6333316294241471977L;

public DataClassMismatchException(Class expectedClass, Class actualClass) {
super(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,10 @@
*/
package com.github.kagkarlsson.scheduler.exceptions;

import java.io.Serial;

public abstract class DbSchedulerException extends RuntimeException {
private static final long serialVersionUID = -2132850112553296790L;
@Serial private static final long serialVersionUID = -2132850112553296790L;

public DbSchedulerException(String message) {
super(message);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,10 @@
package com.github.kagkarlsson.scheduler.exceptions;

import com.github.kagkarlsson.scheduler.task.Execution;
import java.io.Serial;

public class ExecutionException extends TaskInstanceException {
private static final long serialVersionUID = -4732028463501966553L;
@Serial private static final long serialVersionUID = -4732028463501966553L;
private final long version;

public ExecutionException(String message, Execution execution) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,10 @@
*/
package com.github.kagkarlsson.scheduler.exceptions;

import java.io.Serial;

public class FailedToScheduleBatchException extends DbSchedulerException {
private static final long serialVersionUID = -2132850112553296792L;
@Serial private static final long serialVersionUID = -2132850112553296792L;

public FailedToScheduleBatchException(String message) {
super(message);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,14 @@
*/
package com.github.kagkarlsson.scheduler.exceptions;

import java.io.Serial;

public class MissingRawDataException extends DbSchedulerException {
private static final long serialVersionUID = 1L;
@Serial private static final long serialVersionUID = 1L;

public MissingRawDataException(Class<?> dataClass) {
super(
String.format(
"Scheduled execution has typed data, use getData() to read the deserialized object. Data-class : %s",
dataClass));
"Scheduled execution has typed data, use getData() to read the deserialized object. Data-class : %s"
.formatted(dataClass));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,10 @@
*/
package com.github.kagkarlsson.scheduler.exceptions;

import java.io.Serial;

public class SerializationException extends DbSchedulerException {
private static final long serialVersionUID = -5209721067354085350L;
@Serial private static final long serialVersionUID = -5209721067354085350L;

public SerializationException(String msg, Throwable cause) {
super(msg, cause);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,10 @@
*/
package com.github.kagkarlsson.scheduler.exceptions;

import java.io.Serial;

public class TaskInstanceCurrentlyExecutingException extends TaskInstanceException {
private static final long serialVersionUID = 6016933189040296444L;
@Serial private static final long serialVersionUID = 6016933189040296444L;

public TaskInstanceCurrentlyExecutingException(String taskName, String instanceId) {
super(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,21 +13,23 @@
*/
package com.github.kagkarlsson.scheduler.exceptions;

import java.io.Serial;

public class TaskInstanceException extends DbSchedulerException {
private static final long serialVersionUID = -2132850112553296791L;
@Serial private static final long serialVersionUID = -2132850112553296791L;
private static final String TASK_NAME_INSTANCE_MESSAGE_PART = " (task name: %s, instance id: %s)";

private final String taskName;
private final String instanceId;

public TaskInstanceException(String message, String taskName, String instanceId, Throwable ex) {
super(message + String.format(TASK_NAME_INSTANCE_MESSAGE_PART, taskName, instanceId), ex);
super(message + TASK_NAME_INSTANCE_MESSAGE_PART.formatted(taskName, instanceId), ex);
this.taskName = taskName;
this.instanceId = instanceId;
}

public TaskInstanceException(String message, String taskName, String instanceId) {
super(message + String.format(TASK_NAME_INSTANCE_MESSAGE_PART, taskName, instanceId));
super(message + TASK_NAME_INSTANCE_MESSAGE_PART.formatted(taskName, instanceId));
this.taskName = taskName;
this.instanceId = instanceId;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,10 @@
*/
package com.github.kagkarlsson.scheduler.exceptions;

import java.io.Serial;

public class TaskInstanceNotFoundException extends TaskInstanceException {
private static final long serialVersionUID = -3604591431614052358L;
@Serial private static final long serialVersionUID = -3604591431614052358L;

public TaskInstanceNotFoundException(String taskName, String instanceId) {
super("Failed to perform action on task because it was not found.", taskName, instanceId);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,12 @@
package com.github.kagkarlsson.scheduler.task.helper;

import com.github.kagkarlsson.scheduler.task.schedule.Schedule;
import java.io.Serial;
import java.io.Serializable;
import java.util.Objects;

public class PlainScheduleAndData implements ScheduleAndData, Serializable {
private static final long serialVersionUID = 1L;
@Serial private static final long serialVersionUID = 1L;
private final Schedule schedule;
private final Object data;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,7 @@ private CompositeParser(List<Parser> delegates) {
public Optional<Schedule> parse(String scheduleString) {
return delegates.stream()
.map(it -> it.parse(scheduleString))
.filter(Optional::isPresent)
.map(Optional::get)
.flatMap(Optional::stream)
.findFirst();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import com.cronutils.model.time.ExecutionTime;
import com.cronutils.parser.CronParser;
import com.github.kagkarlsson.scheduler.task.ExecutionComplete;
import java.io.Serial;
import java.io.Serializable;
import java.time.Duration;
import java.time.Instant;
Expand All @@ -32,7 +33,7 @@
/** Spring-style cron-pattern schedule */
public class CronSchedule implements Schedule, Serializable {

private static final long serialVersionUID = 1L;
@Serial private static final long serialVersionUID = 1L;

private static final String DISABLED = "-";
private static final Logger LOG = LoggerFactory.getLogger(CronSchedule.class);
Expand Down Expand Up @@ -76,7 +77,7 @@ public Instant getNextExecutionTime(ExecutionComplete executionComplete) {
ZonedDateTime lastDone = ZonedDateTime.ofInstant(executionComplete.getTimeDone(), zoneId);

Optional<ZonedDateTime> nextTime = cronExecutionTime.nextExecution(lastDone);
if (!nextTime.isPresent()) {
if (nextTime.isEmpty()) {
LOG.error(
"Cron-pattern did not return any further execution-times. This behavior is currently "
+ "not supported by the scheduler. Setting next execution-time to far-future, "
Expand Down Expand Up @@ -126,7 +127,7 @@ private CronType getCronType(CronStyle cronStyle) {
return CronType.SPRING53;
default:
throw new IllegalArgumentException(
String.format("No cron definition found for %s", this.cronStyle));
"No cron definition found for %s".formatted(this.cronStyle));
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
package com.github.kagkarlsson.scheduler.task.schedule;

import com.github.kagkarlsson.scheduler.task.ExecutionComplete;
import java.io.Serial;
import java.io.Serializable;
import java.time.Instant;
import java.time.LocalDate;
Expand All @@ -27,7 +28,7 @@

public class Daily implements Schedule, Serializable {

private static final long serialVersionUID = 1L;
@Serial private static final long serialVersionUID = 1L;

private final List<LocalTime> times;
private final ZoneId zone;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,15 @@
package com.github.kagkarlsson.scheduler.task.schedule;

import com.github.kagkarlsson.scheduler.task.ExecutionComplete;
import java.io.Serial;
import java.io.Serializable;
import java.time.Duration;
import java.time.Instant;
import java.util.Objects;

public class FixedDelay implements Schedule, Serializable {

private static final long serialVersionUID = 1L;
@Serial private static final long serialVersionUID = 1L;

private final Duration duration;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,11 @@
package com.github.kagkarlsson.scheduler.task.schedule;

import com.github.kagkarlsson.scheduler.task.helper.ScheduleAndData;
import java.io.Serial;
import java.time.ZoneId;

public class PersistentCronSchedule implements ScheduleAndData {
private static final long serialVersionUID = 1L;
@Serial private static final long serialVersionUID = 1L;
private final String cronPattern;
private final String zoneId;
private final Object data;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,11 @@ public void test_data_class_type_equals() {
Instant now = Instant.now();
OneTimeTask<Integer> task =
TestTasks.oneTime("OneTime", Integer.class, (instance, executionContext) -> {});
Execution execution = new Execution(now, task.instance("id1", new Integer(1)));
Execution execution = new Execution(now, task.instance("id1", Integer.valueOf(1)));

ScheduledExecution<Integer> scheduledExecution =
new ScheduledExecution<>(Integer.class, execution);
assertEquals(new Integer(1), scheduledExecution.getData());
assertEquals(Integer.valueOf(1), scheduledExecution.getData());
}

@Test
Expand All @@ -55,7 +55,7 @@ public void test_data_class_type_not_equals() {
TestTasks.oneTime("OneTime", Integer.class, (instance, executionContext) -> {});
Execution execution =
new Execution(
now, task.instance("id1", new Integer(1))); // Data class is an integer
now, task.instance("id1", Integer.valueOf(1))); // Data class is an integer

new ScheduledExecution<>(String.class, execution)
.getData(); // Instantiate with incorrect type
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,12 @@

import com.github.kagkarlsson.scheduler.task.helper.ScheduleAndData;
import com.github.kagkarlsson.scheduler.task.schedule.CronSchedule;
import java.io.Serial;

public class ScheduleAndDataForTest implements ScheduleAndData {
@Serial
private static final long serialVersionUID = 1L; // recommended when using Java serialization

private final CronSchedule schedule;
private final Long id;

Expand Down
2 changes: 1 addition & 1 deletion examples/features/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@
</execution>
</executions>
<configuration>
<jvmTarget>1.8</jvmTarget>
<jvmTarget>${jdk.version}</jvmTarget>
<compilerPlugins>
<plugin>kotlinx-serialization</plugin>
</compilerPlugins>
Expand Down
Loading
Loading