Skip to content

Commit 02a3818

Browse files
kamilkrzywanskiaasysplkkrzywanski
authored
Querydsl 5.0.0 serialization fix (#515)
* Fix serialization of constructor args * Fix serialization of constructor args --------- Co-authored-by: kholysz <[email protected]> Co-authored-by: kkrzywanski <[email protected]>
1 parent 52869a8 commit 02a3818

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

querydsl-core/src/main/java/com/querydsl/core/types/ConstructorExpression.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ public T newInstance(Object... args) {
149149
}
150150

151151
private void readObject(ObjectInputStream ois) throws ClassNotFoundException, IOException {
152-
ois.readObject();
152+
ois.defaultReadObject();
153153
try {
154154
Field constructor = ConstructorExpression.class.getDeclaredField("constructor");
155155
constructor.setAccessible(true);

querydsl-core/src/test/java/com/querydsl/core/types/ConstructorExpressionTest.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,4 +131,16 @@ public void run() {
131131
};
132132
ThreadSafety.check(invoker, invoker);
133133
}
134+
135+
@Test
136+
public void constructorArgsShouldBeSerialized() {
137+
Expression<Long> longArg = ConstantImpl.create(1L);
138+
Expression<String> stringArg = ConstantImpl.create("");
139+
ConstructorExpression<ProjectionExample> projection =
140+
new ConstructorExpression<ProjectionExample>(
141+
ProjectionExample.class, new Class<?>[] {long.class, String.class}, longArg, stringArg);
142+
ConstructorExpression<ProjectionExample> deserializationResult =
143+
Serialization.serialize(projection);
144+
assertEquals(projection, deserializationResult);
145+
}
134146
}

0 commit comments

Comments
 (0)