]> source.dussan.org Git - jgit.git/commit
ObjectIdSerializer: Support serialization of known non-null ObjectId 56/119456/3
authorDavid Pursehouse <david.pursehouse@gmail.com>
Wed, 14 Mar 2018 23:25:43 +0000 (08:25 +0900)
committerDavid Pursehouse <david.pursehouse@gmail.com>
Thu, 15 Mar 2018 00:39:43 +0000 (09:39 +0900)
commit61e4f1665221626cfd31a5826bff527ef7ce5719
tree269068f34431b783de7e459513004a749d45fe2c
parentf389e18a2853d9f73336f4cf0e7ac2931dc4ce9b
ObjectIdSerializer: Support serialization of known non-null ObjectId

The implementation of ObjectIdSerializer, added in change I7599cf8bd,
is not equivalent to the original implementation in Gerrit [1].

The Gerrit implementation provides separate methods to (de)serialize
instances of ObjectId that are known to be non-null. In these methods,
no "marker" is written to the stream. Replacing Gerrit's implementation
with ObjectIdSerializer [2] broke persistent caches because it started
writing markers where they were not expected [3].

Since ObjectIdSerializer is included in JGit 4.11 we can't change the
existing #write and #read methods. Keep those as-is, but extend the
Javadoc to clarify that they support possibly null ObjectId instances.

Add new methods #writeWithoutMarker and #readWithoutMarker to support
the cases where the ObjectId is known to be non-null and the marker
should not be written to the serialization stream.

Also:

- Replace the hard-coded `0` and `1` markers with constants that can
  be linked from the Javadocs.

- Include the marker value in the "Invalid flag before ObjectId"
  exception message.

[1] https://gerrit-review.googlesource.com/c/gerrit/+/9792
[2] https://gerrit-review.googlesource.com/c/gerrit/+/165851
[3] https://gerrit-review.googlesource.com/c/gerrit/+/165952

Change-Id: Iaf84c3ec32ecf83efffb306fdb4940cc85740f3f
Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
org.eclipse.jgit.test/tst/org/eclipse/jgit/lib/ObjectIdSerializerTest.java
org.eclipse.jgit/src/org/eclipse/jgit/lib/ObjectIdSerializer.java