Breaking changes in Couchbase Java client (3.0.6 -> 3.0.7)

When going from 3.0.6 -> 3.0.7, my builds started failing:
error: no suitable method found for expiry(Expiry)

[ERROR]     method InsertOptions.expiry(Duration) is not applicable
[ERROR]       (argument mismatch; Expiry cannot be converted to Duration)
[ERROR]     method InsertOptions.expiry(Instant) is not applicable
[ERROR]       (argument mismatch; Expiry cannot be converted to Instant)

Having similar problems with ReplaceOptions and UpsertOptions.

this is a sample of the code that causes the problem:

public static InsertOptions copy(InsertOptions insertOptions) {
    InsertOptions.Built built = insertOptions.build();
    InsertOptions updatedOptions = insertOptions.insertOptions()
            .expiry(built.expiry());

InsertOptions.Built.expiry(x) now returns Expiry instead of Duration… Why’d this change?

Would it be possible to get a overloaded method added to InsertOptions, ReplaceOptions and UpsertOptions (and any other XxxOptions) that takes an Expiry? Seems like that should’ve been there…

Note that the build() method is marked internal, we are not providing stability guarantees for the built options.

On the options we now accept the expiry for both Duration and Instant (the new instant is preferred).

@unhuman since you passed in the expiry at some point, you should have the original value around to use, right?

Unfortunately, I don’t necessarily have it… There’s no getter available on the Options… I could use reflection. Given we are based on Duration, flipping to Instant isn’t practical right now… This is a wrapper around the client that we have so our applications don’t all have to change when the client does…

@david.nault Not really since our defaults could be passed in from caller. For us, Duration is more meaningful since we want to say all objects of x type expire after 30s. An instant would require the caller to calculate that… Not horrible, but way less friendly.

@daschl Sure. Doesn’t help with this problem, but sure…

our concept is to have a template for these XxxxOptions and then copy that and override what we need…

Would it help if instead of a template, you had a method (or Consumer) that set the default options?

@unhuman Expiry has an encode method, which returns a long. You could use it to build an Instant out of it and set it back this way? I know its one object creation but it should be fairly cheap, because when we get an instant on expiry encode we’ll just extract its getEpochSecond.