Skip to content

Commit fe10069

Browse files
WIP bump minimum JDK to 17
1 parent 12184e9 commit fe10069

File tree

39 files changed

+217
-546
lines changed

39 files changed

+217
-546
lines changed

.github/workflows/release.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ jobs:
1414
- name: Set up JDK ${{ matrix.java }}
1515
uses: actions/setup-java@v3
1616
with:
17-
java-version: 11
17+
java-version: 17
1818
distribution: 'adopt'
1919

2020
- name: Setup Gradle

.github/workflows/tests.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ jobs:
1515
strategy:
1616
fail-fast: false
1717
matrix:
18-
java: [ 11, 17, 21 ]
18+
java: [ 17, 21 ]
1919
steps:
2020
- uses: actions/checkout@v4
2121
- name: Set up JDK ${{ matrix.java }}

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -314,7 +314,7 @@ We know that your time is precious and, therefore, deeply value any effort to co
314314

315315
Prerequisites:
316316

317-
- JDK >= 11
317+
- JDK >= 17
318318
- Docker or Podman
319319

320320
To build the SDK:

buildSrc/src/main/kotlin/java-conventions.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ dependencies { errorprone("com.google.errorprone:error_prone_core:2.28.0") }
1111

1212
// Configure the java toolchain to use. If not found, it will be downloaded automatically
1313
java {
14-
toolchain { languageVersion = JavaLanguageVersion.of(11) }
14+
toolchain { languageVersion = JavaLanguageVersion.of(17) }
1515

1616
withJavadocJar()
1717
withSourcesJar()

buildSrc/src/main/kotlin/kotlin-conventions.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ plugins {
55
}
66

77
java {
8-
toolchain { languageVersion = JavaLanguageVersion.of(11) }
8+
toolchain { languageVersion = JavaLanguageVersion.of(17) }
99

1010
withJavadocJar()
1111
withSourcesJar()

examples/src/main/java/my/restate/sdk/examples/Counter.java

Lines changed: 1 addition & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -48,13 +48,6 @@ public long get(SharedObjectContext ctx) {
4848
return ctx.get(TOTAL).orElse(0L);
4949
}
5050

51-
/** Get the current counter value. */
52-
@Shared
53-
@Handler
54-
public Node getNode(SharedObjectContext ctx) {
55-
return null;
56-
}
57-
5851
/** Add a value, and get both the previous value and the new value. */
5952
@Handler
6053
public CounterUpdateResult getAndAdd(ObjectContext ctx, long request) {
@@ -71,39 +64,5 @@ public static void main(String[] args) {
7164
RestateHttpEndpointBuilder.builder().bind(new Counter()).buildAndListen();
7265
}
7366

74-
public static class Node {
75-
private final String data;
76-
private final Node inner;
77-
78-
public Node(String data, Node inner) {
79-
this.data = data;
80-
this.inner = inner;
81-
}
82-
83-
public String getData() {
84-
return data;
85-
}
86-
87-
public Node getInner() {
88-
return inner;
89-
}
90-
}
91-
92-
public static class CounterUpdateResult {
93-
private final long newValue;
94-
private final long oldValue;
95-
96-
public CounterUpdateResult(long newValue, long oldValue) {
97-
this.newValue = newValue;
98-
this.oldValue = oldValue;
99-
}
100-
101-
public long getNewValue() {
102-
return newValue;
103-
}
104-
105-
public long getOldValue() {
106-
return oldValue;
107-
}
108-
}
67+
public record CounterUpdateResult(long newValue, long oldValue) {}
10968
}

examples/src/main/java/my/restate/sdk/examples/LoanWorkflow.java

Lines changed: 4 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@
88
// https://github.com/restatedev/sdk-java/blob/main/LICENSE
99
package my.restate.sdk.examples;
1010

11-
import com.fasterxml.jackson.annotation.JsonCreator;
12-
import com.fasterxml.jackson.annotation.JsonProperty;
1311
import dev.restate.sdk.Context;
1412
import dev.restate.sdk.JsonSerdes;
1513
import dev.restate.sdk.SharedWorkflowContext;
@@ -45,41 +43,8 @@ public enum Status {
4543
TRANSFER_FAILED
4644
}
4745

48-
public static class LoanRequest {
49-
50-
private final String customerName;
51-
private final String customerId;
52-
private final String customerBankAccount;
53-
private final BigDecimal amount;
54-
55-
@JsonCreator
56-
public LoanRequest(
57-
@JsonProperty("customerName") String customerName,
58-
@JsonProperty("customerId") String customerId,
59-
@JsonProperty("customerBankAccount") String customerBankAccount,
60-
@JsonProperty("amount") BigDecimal amount) {
61-
this.customerName = customerName;
62-
this.customerId = customerId;
63-
this.customerBankAccount = customerBankAccount;
64-
this.amount = amount;
65-
}
66-
67-
public String getCustomerName() {
68-
return customerName;
69-
}
70-
71-
public String getCustomerId() {
72-
return customerId;
73-
}
74-
75-
public String getCustomerBankAccount() {
76-
return customerBankAccount;
77-
}
78-
79-
public BigDecimal getAmount() {
80-
return amount;
81-
}
82-
}
46+
public record LoanRequest(
47+
String customerName, String customerId, String customerBankAccount, BigDecimal amount) {}
8348

8449
private static final Logger LOG = LogManager.getLogger(LoanWorkflow.class);
8550

@@ -123,8 +88,7 @@ public String run(WorkflowContext ctx, LoanRequest loanRequest) {
12388
executionTime =
12489
bankClient
12590
.transfer(
126-
new TransferRequest(
127-
loanRequest.getCustomerBankAccount(), loanRequest.getAmount()))
91+
new TransferRequest(loanRequest.customerBankAccount(), loanRequest.amount()))
12892
.await(Duration.ofDays(7));
12993
} catch (TerminalException | TimeoutException e) {
13094
LOG.warn("Transaction failed", e);
@@ -223,24 +187,5 @@ public Instant transfer(Context context, TransferRequest request) throws Termina
223187
}
224188
}
225189

226-
public static class TransferRequest {
227-
private final String bankAccount;
228-
private final BigDecimal amount;
229-
230-
@JsonCreator
231-
public TransferRequest(
232-
@JsonProperty("bankAccount") String bankAccount,
233-
@JsonProperty("amount") BigDecimal amount) {
234-
this.bankAccount = bankAccount;
235-
this.amount = amount;
236-
}
237-
238-
public String getBankAccount() {
239-
return bankAccount;
240-
}
241-
242-
public BigDecimal getAmount() {
243-
return amount;
244-
}
245-
}
190+
public record TransferRequest(String bankAccount, BigDecimal amount) {}
246191
}

sdk-api-gen-common/src/main/java/dev/restate/sdk/gen/model/Handler.java

Lines changed: 7 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -11,54 +11,13 @@
1111
import java.util.Objects;
1212
import org.jspecify.annotations.Nullable;
1313

14-
public class Handler {
15-
16-
private final CharSequence name;
17-
private final HandlerType handlerType;
18-
private final @Nullable String inputAccept;
19-
private final PayloadType inputType;
20-
private final PayloadType outputType;
21-
private final @Nullable String documentation;
22-
23-
public Handler(
24-
CharSequence name,
25-
HandlerType handlerType,
26-
@Nullable String inputAccept,
27-
PayloadType inputType,
28-
PayloadType outputType,
29-
@Nullable String documentation) {
30-
this.name = name;
31-
this.handlerType = handlerType;
32-
this.inputAccept = inputAccept;
33-
this.inputType = inputType;
34-
this.outputType = outputType;
35-
this.documentation = documentation;
36-
}
37-
38-
public CharSequence getName() {
39-
return name;
40-
}
41-
42-
public HandlerType getHandlerType() {
43-
return handlerType;
44-
}
45-
46-
@Nullable
47-
public String getInputAccept() {
48-
return inputAccept;
49-
}
50-
51-
public PayloadType getInputType() {
52-
return inputType;
53-
}
54-
55-
public PayloadType getOutputType() {
56-
return outputType;
57-
}
58-
59-
public @Nullable String getDocumentation() {
60-
return documentation;
61-
}
14+
public record Handler(
15+
CharSequence name,
16+
HandlerType handlerType,
17+
@Nullable String inputAccept,
18+
PayloadType inputType,
19+
PayloadType outputType,
20+
@Nullable String documentation) {
6221

6322
public static Builder builder() {
6423
return new Builder();

sdk-api-gen-common/src/main/java/dev/restate/sdk/gen/model/HandlerType.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,5 @@ public enum HandlerType {
1212
SHARED,
1313
EXCLUSIVE,
1414
STATELESS,
15-
WORKFLOW;
15+
WORKFLOW
1616
}

sdk-api-gen-common/src/main/java/dev/restate/sdk/gen/model/PayloadType.java

Lines changed: 1 addition & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -8,66 +8,4 @@
88
// https://github.com/restatedev/sdk-java/blob/main/LICENSE
99
package dev.restate.sdk.gen.model;
1010

11-
import java.util.Objects;
12-
13-
public class PayloadType {
14-
15-
private final boolean isEmpty;
16-
private final String name;
17-
private final String boxed;
18-
private final String serdeDecl;
19-
20-
public PayloadType(boolean isEmpty, String name, String boxed, String serdeDecl) {
21-
this.isEmpty = isEmpty;
22-
this.name = name;
23-
this.boxed = boxed;
24-
this.serdeDecl = serdeDecl;
25-
}
26-
27-
public boolean isEmpty() {
28-
return isEmpty;
29-
}
30-
31-
public String getName() {
32-
return name;
33-
}
34-
35-
public String getBoxed() {
36-
return boxed;
37-
}
38-
39-
public String getSerdeDecl() {
40-
return serdeDecl;
41-
}
42-
43-
@Override
44-
public boolean equals(Object o) {
45-
if (this == o) return true;
46-
if (!(o instanceof PayloadType)) return false;
47-
PayloadType that = (PayloadType) o;
48-
return isEmpty == that.isEmpty
49-
&& Objects.equals(name, that.name)
50-
&& Objects.equals(boxed, that.boxed)
51-
&& Objects.equals(serdeDecl, that.serdeDecl);
52-
}
53-
54-
@Override
55-
public int hashCode() {
56-
return Objects.hash(name, boxed, serdeDecl);
57-
}
58-
59-
@Override
60-
public String toString() {
61-
return "PayloadType{"
62-
+ "name='"
63-
+ name
64-
+ '\''
65-
+ ", boxed='"
66-
+ boxed
67-
+ '\''
68-
+ ", serdeDecl='"
69-
+ serdeDecl
70-
+ '\''
71-
+ '}';
72-
}
73-
}
11+
public record PayloadType(boolean isEmpty, String name, String boxed, String serdeDecl) {}

0 commit comments

Comments
 (0)