fix incorrect JNI signature for PatchAction.FlagConflict constructor#15
Closed
turix2 wants to merge 2 commits intoautomerge:mainfrom
Closed
fix incorrect JNI signature for PatchAction.FlagConflict constructor#15turix2 wants to merge 2 commits intoautomerge:mainfrom
turix2 wants to merge 2 commits intoautomerge:mainfrom
Conversation
Collaborator
|
Thanks for catching this, could you also add a test which reproduces the problem so it doesn't occur again |
Author
Unfortunately, I don't have the build environment set up, and it's too much work for me to do so right now on my machine. Sorry! But the test wouldn't be that complicated. I think you just need to set up a merge conflict and then ask for the patches. Something like the following (which I just wrote here and have not even tried to compile) should do it: Document doc1 = new Document();
SyncState ss1 = new SyncState();
Document doc2 = new Document();
SyncState ss2 = new SyncState();
try (Transaction tx1 = doc1.startTransaction()) {
tx1.set(ObjectId.ROOT, "key", ObjectType.MAP);
tx1.commit();
}
try (Transaction tx2 = doc2.startTransaction()) {
tx2.set(ObjectId.ROOT, "key", ObjectType.MAP);
tx2.commit();
}
byte[] m1to2, m2to1;
PatchLog pl;
List<Patch> patches;
while (true) {
m1to2 = doc1.generateSyncMessage(ss1).orElse(new byte[0]);
pl = new PatchLog();
doc2.receiveSyncMessage(ss2, pl, m1to2);
patches = doc2.makePatches(pl); // may panic, but shouldn't after fix
m2to1 = doc2.generateSyncMessage(ss2).orElse(new byte[0]);
pl = new PatchLog();
doc1.receiveSyncMessage(ss1, pl, m2to1);
patches = doc1.makePatches(pl); // may panic, but shouldn't after fix
if (m1to2.length == 0 && m2to1.length == 0)
break;
}It may not panic on the first set of messages exchanged in the "handshake" between 1 and 2, but I think it will before they converge. |
alexjg
added a commit
that referenced
this pull request
Nov 4, 2025
The `FlagConflict` patch was not being correctly constructed by the JNI binding code, leading to exceptions when such patches were encountered. Thanks to [this PR](#15) for pointing out the issue.
Merged
alexjg
added a commit
that referenced
this pull request
Nov 4, 2025
The `FlagConflict` patch was not being correctly constructed by the JNI binding code, leading to exceptions when such patches were encountered. Thanks to [this PR](#15) for pointing out the issue.
Collaborator
|
Fixed by #29 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
When I do something like the following for an Automerge
Documentobject called_docwithSyncStatecalled_syncState:I get the following panic if there are any
PatchAction.FlagConflictactions among the patches:I believe this PR fixes that problem. The JNI signature to call the Java
FlagConflictconstructor from Rust was incorrect: there should only be 1 argument (theProp), not 2.