Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

API V2: ModelServerClient sometimes sends empty requests #190

Open
CamilleLetavernier opened this issue Mar 16, 2022 · 0 comments
Open

API V2: ModelServerClient sometimes sends empty requests #190

CamilleLetavernier opened this issue Mar 16, 2022 · 0 comments
Labels
bug Something isn't working modelserver EMF.cloud Model Server sponsored v2

Comments

@CamilleLetavernier
Copy link
Member

When generating a Json Patch by comparing 2 states of the model, we sometimes end up with an empty patch (When both models are identical). When using this empty patch with modelServerClient.edit(), this results in a no-op request.

Moreover, when combining this with Transactions (org.eclipse.emfcloud.modelserver.emf.common.ModelServerEditingDomain.closeCompoundCommand()), the resulting CompoundCommand is empty, thus unexecutable. This causes a runtime exception for the transaction.

To avoid empty requests an unnecessary exceptions, we should patch the ModelServerClientV2 to immediately ignore empty patches and avoid the client-server roundtrip entirely.

Currently, the workaround is that all client applications should guard against empty patches:

const patch = jsonpatch.compare(
    originalModel,
    updatedModel
);
if (patch.length === 0) {
    return;
}

const editResult = await this.modelServerClient.edit(
    this.modeluri,
    patch
);
...
@CamilleLetavernier CamilleLetavernier added bug Something isn't working modelserver EMF.cloud Model Server labels Mar 16, 2022
@ndoschek ndoschek added the v2 label Aug 23, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working modelserver EMF.cloud Model Server sponsored v2
Projects
None yet
Development

No branches or pull requests

3 participants