You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cayenne.apache.org by nt...@apache.org on 2019/10/22 08:20:57 UTC
[cayenne] branch STABLE-4.1 updated: CAY-2635 Lambda expressions
break ROP serialization
This is an automated email from the ASF dual-hosted git repository.
ntimofeev pushed a commit to branch STABLE-4.1
in repository https://gitbox.apache.org/repos/asf/cayenne.git
The following commit(s) were added to refs/heads/STABLE-4.1 by this push:
new 21693ff CAY-2635 Lambda expressions break ROP serialization
21693ff is described below
commit 21693ff17c3ce744476a40910709a97cf2217b0c
Author: Nikita Timofeev <st...@gmail.com>
AuthorDate: Tue Oct 22 11:20:15 2019 +0300
CAY-2635 Lambda expressions break ROP serialization
---
RELEASE-NOTES.txt | 1 +
.../rop/protostuff/ProtostuffROPSerializationTest.java | 12 ++++++++++++
.../src/main/java/org/apache/cayenne/exp/Property.java | 16 ++++++++++++++--
3 files changed, 27 insertions(+), 2 deletions(-)
diff --git a/RELEASE-NOTES.txt b/RELEASE-NOTES.txt
index 431b410..ffaa7e0 100644
--- a/RELEASE-NOTES.txt
+++ b/RELEASE-NOTES.txt
@@ -19,6 +19,7 @@ CAY-2628 dbimport: unable to add several relationships to existing entity
CAY-2631 Can no longer use "byte[]" as root of scalar SQLSelect
CAY-2632 Modeler: issue saving cgen path for maven project
CAY-2633 Modeler: attribute sorting logic in cgen can corrupt model
+CAY-2635 Lambda expressions break ROP serialization
----------------------------------
Release: 4.1.RC1
diff --git a/cayenne-protostuff/src/test/java/org/apache/cayenne/rop/protostuff/ProtostuffROPSerializationTest.java b/cayenne-protostuff/src/test/java/org/apache/cayenne/rop/protostuff/ProtostuffROPSerializationTest.java
index 38ab617..851a309 100644
--- a/cayenne-protostuff/src/test/java/org/apache/cayenne/rop/protostuff/ProtostuffROPSerializationTest.java
+++ b/cayenne-protostuff/src/test/java/org/apache/cayenne/rop/protostuff/ProtostuffROPSerializationTest.java
@@ -19,6 +19,7 @@
package org.apache.cayenne.rop.protostuff;
+import org.apache.cayenne.exp.Property;
import org.apache.cayenne.rop.ROPSerializationService;
import org.apache.cayenne.rop.protostuff.persistent.ClientMtTable1;
import org.apache.cayenne.rop.protostuff.persistent.ClientMtTable2;
@@ -110,6 +111,17 @@ public class ProtostuffROPSerializationTest extends ProtostuffProperties {
assertCorrectness(clientTable2);
}
+ @Test
+ public void testPropertySerialization() throws Exception {
+ Property<Integer> property = Property.create("test", Integer.class);
+
+ byte[] data = serverService.serialize(property);
+ @SuppressWarnings("unchecked")
+ Property<Integer> clone = (Property<Integer>) serverService.deserialize(data, Property.class);
+
+ assertEquals(property.getExpression(), clone.getExpression());
+ }
+
private void assertCorrectness(ClientMtTable2 table2) {
ClientMtTable1 table1 = table2.getTable1();
assertEquals(GLOBAL_ATTRIBUTE2, table2.getGlobalAttribute());
diff --git a/cayenne-server/src/main/java/org/apache/cayenne/exp/Property.java b/cayenne-server/src/main/java/org/apache/cayenne/exp/Property.java
index 10c7e66..1224379 100644
--- a/cayenne-server/src/main/java/org/apache/cayenne/exp/Property.java
+++ b/cayenne-server/src/main/java/org/apache/cayenne/exp/Property.java
@@ -94,7 +94,13 @@ public class Property<E> {
*/
protected Property(final String name, final Class<? super E> type) {
this.name = name;
- expressionProvider = () -> ExpressionFactory.pathExp(name);
+ // can't use lambda here as it will break ROP serialization
+ expressionProvider = new ExpressionProvider() {
+ @Override
+ public Expression get() {
+ return ExpressionFactory.pathExp(name);
+ }
+ };
this.type = type;
}
@@ -109,7 +115,13 @@ public class Property<E> {
*/
protected Property(final String name, final Expression expression, final Class<? super E> type) {
this.name = name;
- expressionProvider = () -> expression.deepCopy();
+ // can't use lambda here as it will break ROP serialization
+ expressionProvider = new ExpressionProvider() {
+ @Override
+ public Expression get() {
+ return expression.deepCopy();
+ }
+ };
this.type = type;
}