Skip to content

Commit 680e7fe

Browse files
committed
test with different jackson versions
1 parent d43f900 commit 680e7fe

File tree

6 files changed

+99
-9
lines changed

6 files changed

+99
-9
lines changed

.github/workflows/maven.yml

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,3 +129,46 @@ jobs:
129129
run: mvn -version
130130
- name: Test
131131
run: mvn --no-transfer-progress test -DargLine="-Duser.language=${{matrix.user-language}}"
132+
133+
jackson-test:
134+
timeout-minutes: 20
135+
runs-on: ubuntu-latest
136+
137+
strategy:
138+
fail-fast: false
139+
matrix:
140+
jackson-version:
141+
- 2.13.3
142+
- 2.12.7
143+
- 2.11.4
144+
- 2.10.5
145+
docker-img:
146+
- docker.io/arangodb/arangodb:3.9.1
147+
topology:
148+
- single
149+
db-ext-names:
150+
- false
151+
java-version:
152+
- 17
153+
user-language:
154+
- en
155+
156+
steps:
157+
- uses: actions/checkout@v2
158+
- name: Set up JDK
159+
uses: actions/setup-java@v2
160+
with:
161+
java-version: ${{matrix.java-version}}
162+
distribution: 'adopt'
163+
cache: maven
164+
- name: Start Database
165+
run: ./docker/start_db.sh
166+
env:
167+
ARANGO_LICENSE_KEY: ${{ secrets.ARANGO_LICENSE_KEY }}
168+
STARTER_MODE: ${{matrix.topology}}
169+
DOCKER_IMAGE: ${{matrix.docker-img}}
170+
DATABASE_EXTENDED_NAMES: ${{matrix.db-ext-names}}
171+
- name: Info
172+
run: mvn -version
173+
- name: Test
174+
run: mvn --no-transfer-progress test -Djackson.version=${{jackson-version}}

pom.xml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323

2424
<properties>
2525
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
26+
<jackson.version>2.13.3</jackson.version>
2627
</properties>
2728

2829
<developers>
@@ -242,6 +243,18 @@
242243
<groupId>org.apache.httpcomponents</groupId>
243244
<artifactId>httpclient</artifactId>
244245
</dependency>
246+
<dependency>
247+
<groupId>com.fasterxml.jackson.core</groupId>
248+
<artifactId>jackson-databind</artifactId>
249+
</dependency>
250+
<dependency>
251+
<groupId>com.fasterxml.jackson.core</groupId>
252+
<artifactId>jackson-core</artifactId>
253+
</dependency>
254+
<dependency>
255+
<groupId>com.fasterxml.jackson.core</groupId>
256+
<artifactId>jackson-annotations</artifactId>
257+
</dependency>
245258
<dependency>
246259
<groupId>com.arangodb</groupId>
247260
<artifactId>jackson-dataformat-velocypack</artifactId>
@@ -289,6 +302,13 @@
289302

290303
<dependencyManagement>
291304
<dependencies>
305+
<dependency>
306+
<groupId>com.fasterxml.jackson</groupId>
307+
<artifactId>jackson-bom</artifactId>
308+
<version>${jackson.version}</version>
309+
<scope>import</scope>
310+
<type>pom</type>
311+
</dependency>
292312
<dependency>
293313
<groupId>com.arangodb</groupId>
294314
<artifactId>jackson-dataformat-velocypack</artifactId>

src/main/java/com/arangodb/serde/InternalDeserializers.java

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,10 @@
1111
import com.fasterxml.jackson.core.JsonGenerator;
1212
import com.fasterxml.jackson.core.JsonParser;
1313
import com.fasterxml.jackson.core.TreeNode;
14-
import com.fasterxml.jackson.databind.*;
15-
import com.fasterxml.jackson.databind.node.ArrayNode;
16-
import com.fasterxml.jackson.databind.node.NumericNode;
17-
import com.fasterxml.jackson.databind.node.ObjectNode;
18-
import com.fasterxml.jackson.databind.node.TextNode;
14+
import com.fasterxml.jackson.databind.DeserializationContext;
15+
import com.fasterxml.jackson.databind.JsonDeserializer;
16+
import com.fasterxml.jackson.databind.JsonNode;
17+
import com.fasterxml.jackson.databind.node.*;
1918

2019
import java.io.ByteArrayOutputStream;
2120
import java.io.IOException;
@@ -26,6 +25,13 @@
2625

2726
public final class InternalDeserializers {
2827

28+
private static <T> T readTreeAsValue(JsonParser p, DeserializationContext ctxt, JsonNode n, Class<T> targetType) throws IOException {
29+
try (TreeTraversingParser t = new TreeTraversingParser(n, p.getCodec())) {
30+
t.nextToken();
31+
return ctxt.readValue(t, targetType);
32+
}
33+
}
34+
2935
public static class CollectionLinksDeserializer extends JsonDeserializer<Collection<CollectionLink>> {
3036

3137
@Override
@@ -37,7 +43,7 @@ public Collection<CollectionLink> deserialize(JsonParser p, DeserializationConte
3743
Map.Entry<String, JsonNode> e = it.next();
3844
ObjectNode v = (ObjectNode) e.getValue();
3945
v.put("name", e.getKey());
40-
out.add(ctxt.readTreeAsValue(v, CollectionLink.class));
46+
out.add(readTreeAsValue(p, ctxt, v, CollectionLink.class));
4147
}
4248
return out;
4349
}
@@ -54,7 +60,7 @@ public FieldLink[] deserialize(JsonParser p, DeserializationContext ctxt) throws
5460
Map.Entry<String, JsonNode> e = it.next();
5561
ObjectNode v = (ObjectNode) e.getValue();
5662
v.put("name", e.getKey());
57-
out.add(ctxt.readTreeAsValue(v, FieldLink.class));
63+
out.add(readTreeAsValue(p, ctxt, v, FieldLink.class));
5864
}
5965
return out.toArray(new FieldLink[0]);
6066
}
@@ -126,7 +132,7 @@ public Response deserialize(final JsonParser p, final DeserializationContext ctx
126132
response.setType(it.next().intValue());
127133
response.setResponseCode(it.next().intValue());
128134
if (it.hasNext()) {
129-
response.setMeta(ctxt.readTreeAsValue(it.next(), Map.class));
135+
response.setMeta(readTreeAsValue(p, ctxt, it.next(), Map.class));
130136
}
131137
return response;
132138
}

src/main/java/com/arangodb/serde/InternalSerdeImpl.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,10 @@ final class InternalSerdeImpl extends JacksonSerdeImpl implements InternalSerde
1717

1818
private final ArangoSerde userSerde;
1919

20+
static {
21+
SerdeUtils.INSTANCE.checkSupportedJacksonVersion();
22+
}
23+
2024
InternalSerdeImpl(final ObjectMapper mapper, final ArangoSerde userSerde) {
2125
super(mapper);
2226
this.userSerde = userSerde;

src/main/java/com/arangodb/serde/SerdeUtils.java

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package com.arangodb.serde;
22

33
import com.arangodb.ArangoDBException;
4+
import com.arangodb.jackson.dataformat.velocypack.VPackMapper;
45
import com.fasterxml.jackson.core.JsonProcessingException;
56
import com.fasterxml.jackson.databind.JavaType;
67
import com.fasterxml.jackson.databind.JsonNode;
@@ -9,8 +10,11 @@
910

1011
import java.lang.reflect.Type;
1112
import java.util.ArrayList;
13+
import java.util.Arrays;
1214
import java.util.List;
1315
import java.util.Map;
16+
import java.util.logging.Level;
17+
import java.util.logging.Logger;
1418

1519
public enum SerdeUtils {
1620
INSTANCE;
@@ -68,4 +72,18 @@ public Type convertToType(final JavaType javaType) {
6872
return constructParametricType(javaType.getRawClass(), args.toArray(new Type[0]));
6973
}
7074

75+
void checkSupportedJacksonVersion() {
76+
Arrays.asList(
77+
com.fasterxml.jackson.databind.cfg.PackageVersion.VERSION,
78+
com.fasterxml.jackson.core.json.PackageVersion.VERSION
79+
).forEach(version -> {
80+
int major = version.getMajorVersion();
81+
int minor = version.getMinorVersion();
82+
if (major != 2 || minor < 10 || minor > 13) {
83+
Logger.getLogger(VPackMapper.class.getName())
84+
.log(Level.WARNING, "Unsupported Jackson version: {0}", version);
85+
}
86+
});
87+
}
88+
7189
}

src/test/java/com/arangodb/ArangoCollectionTest.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@
4141
import com.arangodb.util.RawBytes;
4242
import com.arangodb.util.RawJson;
4343
import com.fasterxml.jackson.annotation.JsonInclude;
44-
import com.fasterxml.jackson.annotation.JsonIncludeProperties;
4544
import com.fasterxml.jackson.core.JsonProcessingException;
4645
import com.fasterxml.jackson.databind.ObjectMapper;
4746
import org.junit.jupiter.api.BeforeAll;

0 commit comments

Comments
 (0)