Enables efficient communication and data synchronization between clients and Spring server applications.
Note: This project is incubation and we are considering how to proceed with it.
Enables efficient communication and data synchronization between clients and Spring server applications.
License: Apache License 2.0
See http://tools.ietf.org/html/rfc7386 for details.
JsonPatchMaker is a temporary solution to (de)serializing JSON Patch to/from Patch objects. Aside from it's poor naming, it'd be wise to consider a common interface for implementing patch (de)serializers.
As it currently stands if you also attempt to include static resources at /**
it will conflict with /{resource}
. If the default were diffsync
or something similar then we wouldn't run into this conflict. Alternately it could provide no default and require the user of this class to ensure that property is set to something of their choosing.
In any case we ran into this issue and it took a little while to track down what was preventing our static resource from being requested.
Hi, I am trying to use SpringSync -> newDiff().diff() with two entities, at parent level, the entity is a non List, but at field level, i have multiple lists.When i checked the Diff class source code, if the entity passed at parent level is not a list , diffList() is not invoked which is expected, but this method is not invoked even for the fields which are lists. Because of this , if the modified entity has a collection with some add or delete ,patch is generated with operation : replace for the field size. Ideally this should have been an operation:add or operation: remove . Please correct me if am wrong in my understanding and also help me tackle this situation. Thanks in advance
In addition to HTTP-based differential synchronization, Spring Sync should support the ability to handle and send patches over WebSocket/STOMP.
I get the following exception when i create a diff between two entities which have a Calendar field:
org.springframework.sync.PatchException: Error performing diff:
at org.springframework.sync.Diff.diff(Diff.java:56)
at SyncCalendarTest.testCalendarUsage(SyncCalendarTest.java:30)
at ...
Caused by: java.lang.ClassCastException: [I cannot be cast to [Ljava.lang.Object;
at org.springframework.sync.Diff.diffNonList(Diff.java:123)
at org.springframework.sync.Diff.diffNonList(Diff.java:126)
at org.springframework.sync.Diff.diffList(Diff.java:74)
at org.springframework.sync.Diff.diff(Diff.java:49)
... 27 more
This is caused by the cast to Object[] in the line
diffList(operations, path + "/" + field.getName(), Arrays.asList((Object[]) origValue), Arrays.asList((Object[]) modValue));
however, some array fields in the class GregorianCalendar have the type int, which then can't be casted. So this bug might also be applicable to all other classes which use primitive arrays.
Do implementations of Equivalency.isEquivalent(โฆ)
have to check given values for null
?
Hi:
We have a web app were use the sugested JpaPersistenceCallback, and have a model where exist a parent entity with many items (OneToMany JPA hibernate context). At client side we want work only with the parent reference (single shadow) change properties and adding and remove items:
{"op":"add","path":"/items/0","value":{"name":"Item name"}}
Tha patch array operations dont work and we suppose that don't make a right JSON conversion since try to evaluate the value (LateObjectEvaluator ) with the entityValueType of the parent.
return value instanceof LateObjectEvaluator ? ((LateObjectEvaluator) value).evaluate(entityValueType) : value;
Maybe our approach is not the best solution to sync into a JPA context with OneToMany relations even if exists Lazy Fetch (where collections are PersistedBags) and could be better use shadow parent and items separated.
I hope your comments and sugestions, Great Job.
At the moment, Patch can only deal with changes to Objects and Lists of Objects. For many use cases, that is sufficient. But what if the objects being compare are java.util.Sets or have properties of type Set? What about Map or properties of type Map?
JSON Patch doesn't address these cases very well and thus Spring Sync's Patch (which is initially inspired from JSON Patch) doesn't deal with them very well, either.
Set is particularly tricky. What would the path look like if an entry in a set is to be removed? What would the path look like if the property on a Set entry were to change? Indeed, the path interpreter (which assumes a JSON Patch-style path) would need to be changed to support additional path syntax or even pluggable to support optional path syntax.
I've received several recommendations to use Javers instead of java-diff-utils for producing differences between Java objects. This should be considered for M2.
Per the last paragraph in section 4 of Neil Fraser's Differential Synchronization paper...
However, on a network with best-effort delivery, nothing is guaranteed. Therefore a simple checksum of Client Shadow ought to be sent along with the Edits and compared to Server Shadow after the patches have been applied. If the checksum fails to match, then something went wrong and one side or the other must transmit the whole body of the text to get the two parties back in sync. This will result in data loss equal to one synchronization cycle.
Spring Sync should accept a checksum from the client when applying a patch and verify the shadow's state before applying the patch to the local resource. This could be optional, applying the checksum only if one is provided, proceeding without verification otherwise. Or Spring Sync could be configured to fail if the client does not send a checksum.
Hi, It seems that Diff is not being applied to collections. Is this the normal behavior or is there any other way to enable. Details can be got from the screen shot. It can be seen that the size of organizationUnits of 'modified' is 1, even after the application of diff the size of organizationUnits of 'original' is still 0 and the patch tells that size of operations is 0. organizationUnits is a java.util.Set
(Possibly related to #14)
Given:
public class Project implements Serializable {
@Id
String id;
List<Story> stories = Lists.newArrayList();
}
applying the following patch:
[{"op":"add","path":"/stories/0","value":{"id":"story1420381381217.764656"}}]
I expect that an instance of Story
is created, and added to the stories
list. Instead, an instance of Project
is created, and added to the stories
list (which will later result in a casting exception)
Would like to know road map for Spring Sync, The concept is good and use cases are large with emergence of Client side MVC frames.
But seem like project is not active as it should be. Would like to know should I plan to use Spring Sync in one of the project.
The implementation of the Diff has quite a glaring missing null check, which produces the following exception in 1.0.0.M1
Caused by: org.springframework.sync.PatchException: Error performing diff:
at org.springframework.sync.Diff.diff(Diff.java:54) ~[spring-sync-1.0.0.M1.jar!/:1.0.0.M1]
at REMOVED
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_45]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_45]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_45]
at java.lang.reflect.Method.invoke(Method.java:497) ~[na:1.8.0_45]
at org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:221) ~[spring-web-4.1.6.RELEASE.jar!/:4.1.6.RELEASE]
at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:137) ~[spring-web-4.1.6.RELEASE.jar!/:4.1.6.RELEASE]
at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:110) ~[spring-webmvc-4.1.6.RELEASE.jar!/:4.1.6.RELEASE]
at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandleMethod(RequestMappingHandlerAdapter.java:776) ~[spring-webmvc-4.1.6.RELEASE.jar!/:4.1.6.RELEASE]
at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:705) ~[spring-webmvc-4.1.6.RELEASE.jar!/:4.1.6.RELEASE]
at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:85) ~[spring-webmvc-4.1.6.RELEASE.jar!/:4.1.6.RELEASE]
at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:959) ~[spring-webmvc-4.1.6.RELEASE.jar!/:4.1.6.RELEASE]
at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:893) ~[spring-webmvc-4.1.6.RELEASE.jar!/:4.1.6.RELEASE]
at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:966) ~[spring-webmvc-4.1.6.RELEASE.jar!/:4.1.6.RELEASE]
... 41 common frames omitted
Caused by: java.lang.NullPointerException: null
at org.springframework.sync.Diff.diffNonList(Diff.java:110) ~[spring-sync-1.0.0.M1.jar!/:1.0.0.M1]
at org.springframework.sync.Diff.diffNonList(Diff.java:116) ~[spring-sync-1.0.0.M1.jar!/:1.0.0.M1]
at org.springframework.sync.Diff.diff(Diff.java:49) ~[spring-sync-1.0.0.M1.jar!/:1.0.0.M1]
... 55 common frames omitted
In the current HEAD it has migrated down one line to line 111 in Diff.java
Spring Sync should implement the guaranteed delivery method as described in section 5 of Neil Fraser's Differential Synchronization paper.
Given the following JsonPatch (modelled as a Jackson ArrayNode
)
[{"op":"replace","path":"/stories","value":[{"id":"story1420386726248.278010"}]}]
when parsed into a Patch
, the value
of the ReplaceOperation
is null
To parse, I'm simply doing:
Patch patch = new JsonPatchMaker().fromJsonNode(jsonPatch);
Screenshot of the debug session:
I'm trying to make a diff of two JPA entities and unfortunately some of properties of these JPA entities are hibernate proxies, so I get the following exception:
2017-11-17 14:29:35,672 org.apache.catalina.core.ContainerBase.[Tomcat].[localhost].[/storefront].[dispatcherServlet] [https-jsse-nio-127.0.0.1-8112-exec-7] ERROR: Servlet.service() for servlet [dispatcherServlet] in context with path [/storefront] threw exception [Request processing failed; nested exception is org.springframework.sync.PatchException: Error performing diff:] with root cause
java.lang.IllegalArgumentException: Can not set javassist.util.proxy.MethodHandler field com.nemesis.platform.core.entity.catalog.CatalogVersionEntity_$$_jvst933_2c.handler to com.nemesis.platform.core.entity.catalog.CatalogVersionEntity
at sun.reflect.UnsafeFieldAccessorImpl.throwSetIllegalArgumentException(UnsafeFieldAccessorImpl.java:167)
at sun.reflect.UnsafeFieldAccessorImpl.throwSetIllegalArgumentException(UnsafeFieldAccessorImpl.java:171)
at sun.reflect.UnsafeFieldAccessorImpl.ensureObj(UnsafeFieldAccessorImpl.java:58)
at sun.reflect.UnsafeObjectFieldAccessorImpl.get(UnsafeObjectFieldAccessorImpl.java:36)
at java.lang.reflect.Field.get(Field.java:393)
at org.springframework.sync.Diff.diffNonList(Diff.java:117)
at org.springframework.sync.Diff.diffNonList(Diff.java:126)
at org.springframework.sync.Diff.diff(Diff.java:51)
at com.nemesis.platform.module.restservices.storefront.controller.RestDiffController.synchronize(RestDiffController.java:66)
at com.nemesis.platform.module.restservices.storefront.controller.RestDiffController$$FastClassBySpringCGLIB$$aa2b6dc9.invoke(<generated>)
at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:204)
at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:738)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:157)
at org.springframework.transaction.interceptor.TransactionInterceptor$1.proceedWithInvocation(TransactionInterceptor.java:99)
at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:282)
at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:96)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:673)
at com.nemesis.platform.module.restservices.storefront.controller.RestDiffController$$EnhancerBySpringCGLIB$$4092d952.synchronize(<generated>)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
Arrays.copyOf() was introduced in Java 1.6, but Android 2.2 does not support it. Ultimately, copyOf() simply calls down to System.arraycopy(), so there's no reason why Spring Sync couldn't keep its own copyOf() method internal to avoid compatibility issues with Android 2.2.
What's the status of this project? I still see the incubation note on the README.md.
Also, where are the artifacts located?
I see in the spring-sync-samples project that
repositories {
maven { url "https://repo.spring.io/libs-snapshot" }
}
dependencies {
compile("org.springframework.sync:spring-sync-config:1.0.0.BUILD-SNAPSHOT")
compile("org.springframework.sync:spring-sync-core:1.0.0.BUILD-SNAPSHOT")
compile("org.springframework.sync:spring-sync-web:1.0.0.BUILD-SNAPSHOT")
}
Are there builds beyond these snapshot releases?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.