Skip to content

Commit 957af28

Browse files
committed
BaseDocument not serializable
1 parent ebfb394 commit 957af28

File tree

8 files changed

+52
-64
lines changed

8 files changed

+52
-64
lines changed

driver/src/main/java/com/arangodb/entity/AbstractBaseDocument.java

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@
2626
import com.fasterxml.jackson.annotation.JsonIgnore;
2727
import com.fasterxml.jackson.annotation.JsonInclude;
2828

29-
import java.io.Serializable;
3029
import java.util.Collections;
3130
import java.util.HashMap;
3231
import java.util.Map;
@@ -36,9 +35,7 @@
3635
* @author Mark Vollmary
3736
* @author Michele Rastelli
3837
*/
39-
abstract class AbstractBaseDocument implements Serializable {
40-
41-
private static final long serialVersionUID = 846874908582L;
38+
abstract class AbstractBaseDocument {
4239

4340
private static final String[] META_PROPS = new String[]{
4441
DocumentFields.ID,

driver/src/main/java/com/arangodb/entity/BaseDocument.java

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,16 +20,13 @@
2020

2121
package com.arangodb.entity;
2222

23-
import java.io.Serializable;
2423
import java.util.Map;
2524

2625
/**
2726
* @author Mark Vollmary
2827
* @author Michele Rastelli
2928
*/
30-
public final class BaseDocument extends AbstractBaseDocument implements Serializable {
31-
32-
private static final long serialVersionUID = 733033350470L;
29+
public final class BaseDocument extends AbstractBaseDocument {
3330

3431
public BaseDocument() {
3532
super();

driver/src/main/java/com/arangodb/entity/BaseEdgeDocument.java

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,16 +23,13 @@
2323
import com.arangodb.internal.DocumentFields;
2424
import com.fasterxml.jackson.annotation.JsonIgnore;
2525

26-
import java.io.Serializable;
2726
import java.util.Map;
2827

2928
/**
3029
* @author Mark Vollmary
3130
* @author Michele Rastelli
3231
*/
33-
public final class BaseEdgeDocument extends AbstractBaseDocument implements Serializable {
34-
35-
private static final long serialVersionUID = 356629614444L;
32+
public final class BaseEdgeDocument extends AbstractBaseDocument {
3633

3734
private static final String[] META_PROPS = new String[]{
3835
DocumentFields.ID,

driver/src/main/resources/META-INF/native-image/com.arangodb/arangodb-java-driver/serialization-config.json

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,4 @@
11
[
2-
{
3-
"name": "com.arangodb.entity.AbstractBaseDocument"
4-
},
5-
{
6-
"name": "com.arangodb.entity.BaseDocument"
7-
},
8-
{
9-
"name": "com.arangodb.entity.BaseEdgeDocument"
10-
},
11-
{
12-
"name": "java.util.HashMap"
13-
},
142
{
153
"name": "com.arangodb.entity.ErrorEntity"
164
},

driver/src/test/java/com/arangodb/SerializableTest.java

Lines changed: 22 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,22 @@
11
package com.arangodb;
22

3-
import com.arangodb.entity.BaseDocument;
43
import com.arangodb.entity.ErrorEntity;
4+
import com.arangodb.internal.net.ArangoDBRedirectException;
55
import com.fasterxml.jackson.databind.JsonNode;
66
import com.fasterxml.jackson.databind.ObjectMapper;
77
import com.fasterxml.jackson.databind.node.JsonNodeFactory;
88
import org.junit.jupiter.api.Test;
99

1010
import java.io.*;
11+
import java.util.Collections;
12+
import java.util.List;
1113

1214
import static org.assertj.core.api.Assertions.assertThat;
1315

14-
public class SerializableTest {
16+
class SerializableTest {
1517

1618
@Test
17-
public void serializeBaseDocument() throws IOException, ClassNotFoundException {
18-
BaseDocument bd = new BaseDocument("poaids");
19-
bd.setId("apdso/02193");
20-
bd.setRevision("poip");
21-
bd.addAttribute("aaa", "bbb");
22-
23-
BaseDocument bd2 = roundTrip(bd);
24-
assertThat(bd).isEqualTo(bd2);
25-
}
26-
27-
@Test
28-
public void serializeArangoDBException() throws IOException, ClassNotFoundException {
19+
void serializeArangoDBException() throws IOException, ClassNotFoundException {
2920
ObjectMapper mapper = new ObjectMapper();
3021
JsonNode jn = JsonNodeFactory.instance.objectNode()
3122
.put("errorMessage", "boomError")
@@ -42,6 +33,23 @@ public void serializeArangoDBException() throws IOException, ClassNotFoundExcept
4233
assertThat(e2.getRequestId()).isEqualTo(e.getRequestId());
4334
}
4435

36+
@Test
37+
void serializeArangoDBRedirectException() throws IOException, ClassNotFoundException {
38+
ArangoDBRedirectException e = new ArangoDBRedirectException("foo", "bar");
39+
ArangoDBRedirectException e2 = roundTrip(e);
40+
assertThat(e2.getMessage()).isEqualTo(e.getMessage());
41+
assertThat(e2.getLocation()).isEqualTo(e.getLocation());
42+
}
43+
44+
@Test
45+
void serializeArangoDBMultipleException() throws IOException, ClassNotFoundException {
46+
List<Throwable> exceptions = Collections.singletonList(new RuntimeException("foo"));
47+
ArangoDBMultipleException e = new ArangoDBMultipleException(exceptions);
48+
ArangoDBMultipleException e2 = roundTrip(e);
49+
assertThat(e2.getExceptions()).hasSize(1);
50+
assertThat(e2.getExceptions().iterator().next().getMessage()).isEqualTo("foo");
51+
}
52+
4553
private <T> T roundTrip(T input) throws IOException, ClassNotFoundException {
4654
ByteArrayOutputStream os = new ByteArrayOutputStream();
4755
ObjectOutputStream objectOutputStream = new ObjectOutputStream(os);

resilience-tests/pom.xml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,11 @@
1111

1212
<artifactId>resilience-tests</artifactId>
1313

14+
<properties>
15+
<maven.compiler.target>17</maven.compiler.target>
16+
<maven.compiler.source>17</maven.compiler.source>
17+
</properties>
18+
1419
<dependencies>
1520
<dependency>
1621
<groupId>org.mock-server</groupId>

shaded-integration-tests/src/test/native/java/com/arangodb/SerializableTest.java

Lines changed: 22 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,22 @@
11
package com.arangodb;
22

3-
import com.arangodb.entity.BaseDocument;
43
import com.arangodb.entity.ErrorEntity;
4+
import com.arangodb.internal.net.ArangoDBRedirectException;
55
import com.fasterxml.jackson.databind.JsonNode;
66
import com.fasterxml.jackson.databind.ObjectMapper;
77
import com.fasterxml.jackson.databind.node.JsonNodeFactory;
88
import org.junit.jupiter.api.Test;
99

1010
import java.io.*;
11+
import java.util.Collections;
12+
import java.util.List;
1113

1214
import static org.assertj.core.api.Assertions.assertThat;
1315

14-
public class SerializableTest {
16+
class SerializableTest {
1517

1618
@Test
17-
public void serializeBaseDocument() throws IOException, ClassNotFoundException {
18-
BaseDocument bd = new BaseDocument("poaids");
19-
bd.setId("apdso/02193");
20-
bd.setRevision("poip");
21-
bd.addAttribute("aaa", "bbb");
22-
23-
BaseDocument bd2 = roundTrip(bd);
24-
assertThat(bd).isEqualTo(bd2);
25-
}
26-
27-
@Test
28-
public void serializeArangoDBException() throws IOException, ClassNotFoundException {
19+
void serializeArangoDBException() throws IOException, ClassNotFoundException {
2920
ObjectMapper mapper = new ObjectMapper();
3021
JsonNode jn = JsonNodeFactory.instance.objectNode()
3122
.put("errorMessage", "boomError")
@@ -42,6 +33,23 @@ public void serializeArangoDBException() throws IOException, ClassNotFoundExcept
4233
assertThat(e2.getRequestId()).isEqualTo(e.getRequestId());
4334
}
4435

36+
@Test
37+
void serializeArangoDBRedirectException() throws IOException, ClassNotFoundException {
38+
ArangoDBRedirectException e = new ArangoDBRedirectException("foo", "bar");
39+
ArangoDBRedirectException e2 = roundTrip(e);
40+
assertThat(e2.getMessage()).isEqualTo(e.getMessage());
41+
assertThat(e2.getLocation()).isEqualTo(e.getLocation());
42+
}
43+
44+
@Test
45+
void serializeArangoDBMultipleException() throws IOException, ClassNotFoundException {
46+
List<Throwable> exceptions = Collections.singletonList(new RuntimeException("foo"));
47+
ArangoDBMultipleException e = new ArangoDBMultipleException(exceptions);
48+
ArangoDBMultipleException e2 = roundTrip(e);
49+
assertThat(e2.getExceptions()).hasSize(1);
50+
assertThat(e2.getExceptions().iterator().next().getMessage()).isEqualTo("foo");
51+
}
52+
4553
private <T> T roundTrip(T input) throws IOException, ClassNotFoundException {
4654
ByteArrayOutputStream os = new ByteArrayOutputStream();
4755
ObjectOutputStream objectOutputStream = new ObjectOutputStream(os);

shaded/src/main/resources/META-INF/native-image/com.arangodb/arangodb-java-driver-shaded/serialization-config.json

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,4 @@
11
[
2-
{
3-
"name": "com.arangodb.entity.AbstractBaseDocument"
4-
},
5-
{
6-
"name": "com.arangodb.entity.BaseDocument"
7-
},
8-
{
9-
"name": "com.arangodb.entity.BaseEdgeDocument"
10-
},
11-
{
12-
"name": "java.util.HashMap"
13-
},
142
{
153
"name": "com.arangodb.entity.ErrorEntity"
164
},

0 commit comments

Comments
 (0)