Git Product home page Git Product logo

spring-sync's Introduction

Spring Sync

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.

spring-sync's People

Contributors

habuma avatar royclarkson avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

spring-sync's Issues

Replace JsonPatchMaker

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.

Improve default for `spring.diffsync.path`

https://github.com/spring-projects/spring-sync/blob/master/spring-sync-web/src/main/java/org/springframework/sync/diffsync/web/DiffSyncController.java#L60

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.

Parent object with collection fields add or delete not generating the correct patch

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

Handle and send STOMP-based patches

In addition to HTTP-based differential synchronization, Spring Sync should support the ability to handle and send patches over WebSocket/STOMP.

Exception when diffing a class which uses primitive arrays (like GregorianCalendar)

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.

Manage patch operations into OneToMany relations (JPA context)

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.

Consider options for dealing with non-List collections

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.

Consider Javers as Java diff'ing option

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.

Apply shadow checksum

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.

Diff is not being applied to collections.

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
spring_sync_issue

Patch which adds to a collection instantiates wrong type

(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)

RoadMap for Spring Sync

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.

NullPointerException in Diff

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

Replace operation on Array is incorrectly parsed

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:

image

Diff hibernate proxies.

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)

Consider internalizing copyOf() to address Android 2.2 compatibility

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.

Project Status? Artifact Location?

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?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.