Flags (0x802) indicate non-binary document for id

Server version: Couchbase Server Enterprise Edition 5.5.5 build 4521
We are still using java couchbase client 1.x. For our use case we stores raw byte array to couchbase.
Recently we migrated to java client 2.x. We uses BinaryDocument for the same use case. During our test, we have some java hosts with 1.x and the others are 2.x. In some case we saw this error: Flags (0x802) indicate non-binary document for id. It happens if data write by 1.x and read by 2.x, but it’s not always happening. And if use LegacyDocument get the data, this error is gone. But I thought BinaryDocument should be compatible with both 1.x and 2.x java client. Which Document class should I use?

@dushi792 SDK 2 redefined some of the flags so they have better interoperability with all other SDKs in other languages. In your case, you can use the LegacyDocument if you want to keep interacting with both SDK 1 and 2. This document is exactly there for that reason - so it ensures compatbility with Java SDK 1.

The Binary document uses flags to indicate a “binary” document so it would fit your needs but it uses SDK 2-compatible flags. Also it is VERY important that you do not use the deprecated BinaryDocument - please use the ByteArrayDocument instead because dealing with pooled buffers makes it easer to have leaks in prod. ByteArrayDocument shields you from that.

So if you still need to use both side-by-side use the LegacyDocument, and then at some point you can read with the LegacyDocument and save with the ByteArrayDocument so they all get the “new” flags.