Skip to content

Commit 4e9e636

Browse files
committed
fixing checkstyle and javadocs
Signed-off-by: salaboy <[email protected]>
1 parent 222b9a0 commit 4e9e636

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+9170
-2
lines changed

.github/workflows/build.yml

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ jobs:
152152
run: ./mvnw clean install -B -q -DskipTests
153153
- name: Integration tests using spring boot version ${{ matrix.spring-boot-version }}
154154
id: integration_tests
155-
run: PRODUCT_SPRING_BOOT_VERSION=${{ matrix.spring-boot-version }} ./mvnw -B -Pintegration-tests dependency:copy-dependencies verify
155+
run: PRODUCT_SPRING_BOOT_VERSION=${{ matrix.spring-boot-version }} ./mvnw -B -pl !durabletask-client -Pintegration-tests dependency:copy-dependencies verify
156156
env:
157157
DOCKER_HOST: ${{steps.setup_docker.outputs.sock}}
158158
- name: Upload failsafe test report for sdk-tests on failure
@@ -167,6 +167,32 @@ jobs:
167167
with:
168168
name: surefire-report-sdk-tests-jdk${{ matrix.java }}-sb${{ matrix.spring-boot-version }}
169169
path: sdk-tests/target/surefire-reports
170+
# Integration tests for Durable Task Client
171+
- name: Checkout Durable Task Sidecar
172+
uses: actions/checkout@v4
173+
with:
174+
repository: dapr/durabletask-go
175+
path: durabletask-sidecar
176+
177+
# TODO: Move the sidecar into a central image repository
178+
- name: Initialize Durable Task Sidecar
179+
run: docker run -d --name durabletask-sidecar -p 4001:4001 --rm -i $(docker build -q ./durabletask-sidecar)
180+
181+
- name: Display Durable Task Sidecar Logs
182+
run: nohup docker logs --since=0 durabletask-sidecar > durabletask-sidecar.log 2>&1 &
183+
184+
# wait for 10 seconds, so sidecar container can be fully up, this will avoid intermittent failing issues for integration tests causing by failed to connect to sidecar
185+
- name: Wait for 10 seconds
186+
run: sleep 10
187+
188+
- name: Integration Tests For Durable Tasks
189+
run: ./mvnw -B -pl durabletask-client -Pintegration-tests dependency:copy-dependencies verify || echo "TEST_FAILED=true" >> $GITHUB_ENV
190+
continue-on-error: true
191+
192+
- name: Kill Durable Task Sidecar
193+
run: docker kill durabletask-sidecar
194+
195+
170196

171197
publish:
172198
runs-on: ubuntu-latest

durabletask-client/pom.xml

Lines changed: 167 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,167 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<project xmlns="http://maven.apache.org/POM/4.0.0"
3+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
5+
<modelVersion>4.0.0</modelVersion>
6+
<parent>
7+
<groupId>io.dapr</groupId>
8+
<artifactId>dapr-sdk-parent</artifactId>
9+
<version>1.17.0-SNAPSHOT</version>
10+
</parent>
11+
12+
<artifactId>durabletask-client</artifactId>
13+
14+
<properties>
15+
<protobuf.output.directory>${project.build.directory}/generated-sources</protobuf.output.directory>
16+
<protobuf.input.directory>${project.build.directory}/proto</protobuf.input.directory>
17+
</properties>
18+
19+
<dependencies>
20+
<dependency>
21+
<groupId>javax.annotation</groupId>
22+
<artifactId>javax.annotation-api</artifactId>
23+
<scope>provided</scope>
24+
</dependency>
25+
<dependency>
26+
<groupId>io.grpc</groupId>
27+
<artifactId>grpc-protobuf</artifactId>
28+
</dependency>
29+
<dependency>
30+
<groupId>io.grpc</groupId>
31+
<artifactId>grpc-stub</artifactId>
32+
</dependency>
33+
<dependency>
34+
<groupId>io.grpc</groupId>
35+
<artifactId>grpc-netty</artifactId>
36+
</dependency>
37+
<dependency>
38+
<groupId>com.google.protobuf</groupId>
39+
<artifactId>protobuf-java</artifactId>
40+
</dependency>
41+
<dependency>
42+
<groupId>com.fasterxml.jackson.core</groupId>
43+
<artifactId>jackson-core</artifactId>
44+
</dependency>
45+
<dependency>
46+
<groupId>com.fasterxml.jackson.core</groupId>
47+
<artifactId>jackson-databind</artifactId>
48+
</dependency>
49+
<dependency>
50+
<groupId>com.fasterxml.jackson.core</groupId>
51+
<artifactId>jackson-annotations</artifactId>
52+
</dependency>
53+
<dependency>
54+
<groupId>com.fasterxml.jackson.datatype</groupId>
55+
<artifactId>jackson-datatype-jsr310</artifactId>
56+
</dependency>
57+
<dependency>
58+
<groupId>io.grpc</groupId>
59+
<artifactId>grpc-testing</artifactId>
60+
<scope>test</scope>
61+
</dependency>
62+
<dependency>
63+
<groupId>org.junit.jupiter</groupId>
64+
<artifactId>junit-jupiter</artifactId>
65+
<scope>test</scope>
66+
</dependency>
67+
<dependency>
68+
<groupId>org.testcontainers</groupId>
69+
<artifactId>testcontainers</artifactId>
70+
</dependency>
71+
<dependency>
72+
<groupId>io.dapr</groupId>
73+
<artifactId>durabletask-client</artifactId>
74+
</dependency>
75+
</dependencies>
76+
<build>
77+
<plugins>
78+
<plugin>
79+
<groupId>org.sonatype.plugins</groupId>
80+
<artifactId>nexus-staging-maven-plugin</artifactId>
81+
</plugin>
82+
<plugin>
83+
<groupId>org.apache.maven.plugins</groupId>
84+
<artifactId>maven-failsafe-plugin</artifactId>
85+
<configuration>
86+
<classesDirectory>${project.build.outputDirectory}</classesDirectory>
87+
</configuration>
88+
</plugin>
89+
<plugin>
90+
<groupId>com.googlecode.maven-download-plugin</groupId>
91+
<artifactId>download-maven-plugin</artifactId>
92+
<version>1.6.0</version>
93+
<executions>
94+
<execution>
95+
<id>getDaprProto</id>
96+
<phase>initialize</phase>
97+
<goals>
98+
<goal>wget</goal>
99+
</goals>
100+
<configuration>
101+
<skipCache>true</skipCache>
102+
<url>${durabletask.proto.url}</url>
103+
<outputFileName>orchestrator_service.proto</outputFileName>
104+
<outputDirectory>${protobuf.input.directory}</outputDirectory>
105+
</configuration>
106+
</execution>
107+
</executions>
108+
</plugin>
109+
<plugin>
110+
<groupId>org.xolstice.maven.plugins</groupId>
111+
<artifactId>protobuf-maven-plugin</artifactId>
112+
<version>0.6.1</version>
113+
<configuration>
114+
<protocArtifact>com.google.protobuf:protoc:${protobuf.version}:exe:${os.detected.classifier}</protocArtifact>
115+
<pluginId>grpc-java</pluginId>
116+
<pluginArtifact>io.grpc:protoc-gen-grpc-java:${grpc.version}:exe:${os.detected.classifier}</pluginArtifact>
117+
<protoSourceRoot>${protobuf.input.directory}</protoSourceRoot>
118+
</configuration>
119+
<executions>
120+
<execution>
121+
<goals>
122+
<goal>compile</goal>
123+
<goal>compile-custom</goal>
124+
</goals>
125+
</execution>
126+
</executions>
127+
</plugin>
128+
<plugin>
129+
<groupId>org.apache.maven.plugins</groupId>
130+
<artifactId>maven-source-plugin</artifactId>
131+
<version>3.2.1</version>
132+
<executions>
133+
<execution>
134+
<id>attach-sources</id>
135+
<goals>
136+
<goal>jar-no-fork</goal>
137+
</goals>
138+
</execution>
139+
</executions>
140+
</plugin>
141+
<plugin>
142+
<groupId>org.apache.maven.plugins</groupId>
143+
<artifactId>maven-javadoc-plugin</artifactId>
144+
<version>3.2.0</version>
145+
<configuration>
146+
<notimestamp>true</notimestamp>
147+
</configuration>
148+
<executions>
149+
<execution>
150+
<id>attach-javadocs</id>
151+
<goals>
152+
<goal>jar</goal>
153+
</goals>
154+
</execution>
155+
</executions>
156+
</plugin>
157+
<plugin>
158+
<groupId>com.github.spotbugs</groupId>
159+
<artifactId>spotbugs-maven-plugin</artifactId>
160+
<configuration>
161+
<!-- Skip findbugs for auto-generated code -->
162+
<skip>true</skip>
163+
</configuration>
164+
</plugin>
165+
</plugins>
166+
</build>
167+
</project>
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
/*
2+
* Copyright 2025 The Dapr Authors
3+
* Licensed under the Apache License, Version 2.0 (the "License");
4+
* you may not use this file except in compliance with the License.
5+
* You may obtain a copy of the License at
6+
* http://www.apache.org/licenses/LICENSE-2.0
7+
* Unless required by applicable law or agreed to in writing, software
8+
* distributed under the License is distributed on an "AS IS" BASIS,
9+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10+
* See the License for the specific language governing permissions and
11+
limitations under the License.
12+
*/
13+
14+
package io.dapr.durabletask;
15+
16+
import java.util.ArrayList;
17+
import java.util.List;
18+
19+
/**
20+
* Exception that gets thrown when multiple {@link Task}s for an activity or sub-orchestration fails with an
21+
* unhandled exception.
22+
*
23+
* <p>Detailed information associated with each task failure can be retrieved using the {@link #getExceptions()}
24+
* method.</p>
25+
*/
26+
public class CompositeTaskFailedException extends RuntimeException {
27+
private final List<Exception> exceptions;
28+
29+
CompositeTaskFailedException() {
30+
this.exceptions = new ArrayList<>();
31+
}
32+
33+
CompositeTaskFailedException(List<Exception> exceptions) {
34+
this.exceptions = exceptions;
35+
}
36+
37+
CompositeTaskFailedException(String message, List<Exception> exceptions) {
38+
super(message);
39+
this.exceptions = exceptions;
40+
}
41+
42+
CompositeTaskFailedException(String message, Throwable cause, List<Exception> exceptions) {
43+
super(message, cause);
44+
this.exceptions = exceptions;
45+
}
46+
47+
CompositeTaskFailedException(Throwable cause, List<Exception> exceptions) {
48+
super(cause);
49+
this.exceptions = exceptions;
50+
}
51+
52+
CompositeTaskFailedException(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace,
53+
List<Exception> exceptions) {
54+
super(message, cause, enableSuppression, writableStackTrace);
55+
this.exceptions = exceptions;
56+
}
57+
58+
/**
59+
* Gets a list of exceptions that occurred during execution of a group of {@link Task}.
60+
* These exceptions include details of the task failure and exception information
61+
*
62+
* @return a list of exceptions
63+
*/
64+
public List<Exception> getExceptions() {
65+
return new ArrayList<>(this.exceptions);
66+
}
67+
68+
}
Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
/*
2+
* Copyright 2025 The Dapr Authors
3+
* Licensed under the Apache License, Version 2.0 (the "License");
4+
* you may not use this file except in compliance with the License.
5+
* You may obtain a copy of the License at
6+
* http://www.apache.org/licenses/LICENSE-2.0
7+
* Unless required by applicable law or agreed to in writing, software
8+
* distributed under the License is distributed on an "AS IS" BASIS,
9+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10+
* See the License for the specific language governing permissions and
11+
limitations under the License.
12+
*/
13+
14+
package io.dapr.durabletask;
15+
16+
import com.google.protobuf.Timestamp;
17+
18+
import javax.annotation.Nullable;
19+
import java.time.Instant;
20+
import java.time.temporal.ChronoUnit;
21+
22+
/**
23+
* Interface for serializing and deserializing data that gets passed to and from orchestrators and activities.
24+
*
25+
* <p>Implementations of this abstract class are free to use any serialization method. Currently, only strings are
26+
* supported as the serialized representation of data. Byte array payloads and streams are not supported by this
27+
* abstraction. Note that these methods all accept null values, in which case the return value should also be null.</p>
28+
*/
29+
public interface DataConverter {
30+
/**
31+
* Serializes the input into a text representation.
32+
*
33+
* @param value the value to be serialized
34+
* @return a serialized text representation of the value or <code>null</code> if the value is <code>null</code>
35+
*/
36+
@Nullable
37+
String serialize(@Nullable Object value);
38+
39+
/**
40+
* Deserializes the given text data into an object of the specified type.
41+
*
42+
* @param data the text data to deserialize into an object
43+
* @param target the target class to deserialize the input into
44+
* @param <T> the generic parameter type representing the target class to deserialize the input into
45+
* @return a deserialized object of type <code>T</code>
46+
* @throws DataConverterException if the text data cannot be deserialized
47+
*/
48+
@Nullable
49+
<T> T deserialize(@Nullable String data, Class<T> target);
50+
51+
// Data conversion errors are expected to be unrecoverable in most cases, hence an unchecked runtime exception
52+
class DataConverterException extends RuntimeException {
53+
public DataConverterException(String message, Throwable cause) {
54+
super(message, cause);
55+
}
56+
}
57+
58+
/**
59+
* Convert from Timestamp to Instant.
60+
*
61+
* @param ts timestamp to convert
62+
* @return instant
63+
*/
64+
static Instant getInstantFromTimestamp(Timestamp ts) {
65+
if (ts == null) {
66+
return null;
67+
}
68+
69+
// We don't include nanoseconds because of serialization round-trip issues
70+
return Instant.ofEpochSecond(ts.getSeconds(), ts.getNanos()).truncatedTo(ChronoUnit.MILLIS);
71+
}
72+
73+
/**
74+
* Convert from Instant to Timestamp.
75+
* @param instant to convert
76+
* @return timestamp
77+
*/
78+
static Timestamp getTimestampFromInstant(Instant instant) {
79+
if (instant == null) {
80+
return null;
81+
}
82+
83+
return Timestamp.newBuilder()
84+
.setSeconds(instant.getEpochSecond())
85+
.setNanos(instant.getNano())
86+
.build();
87+
}
88+
}

0 commit comments

Comments
 (0)