The reason the document is not being stored is because any time duration longer than 30 days is considered as a Unix timestamp by the Couchbase server. Therefore the expiry you provide in this case is considered a Unix timestamp in the past, so the document expiries immediately.
To achieve this, you can use the upsertOptions().expiry(Instant) overload that was included in the SDK3.1.0 release. So in your case, you can then just pass endTm into the expiry to use the absolute Unix timestamp. More details can found in the documentation: Key Value Operations | Couchbase Docs
If you are only using the 3.0 SDK, you can do a workaround where you create a Duration that is equal to the timestamp 365 days from now. EDIT: There is a bit more nuance to this; refer to David’s comment below for a more accurate description
Will is correct, expiry(Instant) has been part of the “committed” public API since version 3.1.0. If you’re not ready to upgrade to 3.1, this method is also present as an “uncommitted” feature in any version after version 3.0.7.
If you are only using the 3.0 SDK, you can do a workaround where you create a Duration that is equal to the timestamp 365 days from now.
This will work in the old SDKs, but if you’re using 3.0.6 or later I’d strongly recommend just passing in the natural duration.
TLDR; Upgrade to Java SDK version 3.0.6 (or later) and just write: