JsonDocument.empty() method does not require arguments but the underlying code does


#1

Hi,

I am using Couchbase Java Client 2.0.2 to interact with Couchbase server 3.0.1.

I noticed that JsonDocument.empty() does not require arguments whereas the underlying code eventually does.
As a result an exception is being thrown -

IllegalArgumentException("The Document ID must not be null or empty.");

Here is the code -

public static JsonDocument empty() {
    return new JsonDocument(null, 0, null, 0);
}

private JsonDocument(String id, int expiry, JsonObject content, long cas) {
    super(id, expiry, content, cas);
}

`Super()` code -
protected AbstractDocument(String id, int expiry, T content, long cas) {
    if (id == null || id.isEmpty()) {
        throw new IllegalArgumentException("The Document ID must not be null or empty.");
   ...

Is that a bug?

Thanks!
Ronen.


#2

Good catch! I opened a ticket here: https://issues.couchbase.com/browse/JCBC-668

Thanks,
Michael


#3

Cool, thanks @daschl