RawJsonDocument NPE in 2.0.1-SNAPSHOT

Seems like RawJsonDocument doesn’t work properly yet, although the code has been merged (or I’m doing something wrong?).

When creating a RawJsonDocument using a line like:

RawJsonDocument doc = RawJsonDocument.create(“anIdHere”,WELL_FORMED_CONFIRMED_JSON_HERE);

and then putting to a bucket with something like:

bucket.upsert(doc);

Always nets:

java.lang.NullPointerException
at com.couchbase.client.java.CouchbaseAsyncBucket.upsert(CouchbaseAsyncBucket.java:307)
at com.couchbase.client.java.CouchbaseBucket.upsert(CouchbaseBucket.java:290)
at com.couchbase.client.java.CouchbaseBucket.upsert(CouchbaseBucket.java:284)
at com.voltaireapp.voltaireingest.twitter.TwitterDataPuller.saveCollectionToCouchbase(TwitterDataPuller.java:172)
at com.voltaireapp.voltaireingest.twitter.TwitterDataPuller.pullTweets(TwitterDataPuller.java:157)
at com.voltaireapp.voltaireingest.twitter.TwitterDataPuller.main(TwitterDataPuller.java:343)

Looks like the RawJsonTranscoder isn’t being loaded in the upset method, seems to be the root of the NPE?

Advice?

Found a workaround, looks like the root issue here is the default transcoders map doesn’t include/hasn’t been updated to include a RawJsonTranscoder object.

Adding it as a custom seems to work just fine. Probably wise to add it to the default list in CouchbaseAsyncBucket’s constructor so JCBC-575 works out of the box?

List<Transcoder<? extends Document, ?>> transcoders = new Vector<Transcoder<? extends Document, ?>>();
	transcoders.add(new RawJsonTranscoder());

	Bucket bucket = cluster.openBucket(bucketString, password, transcoders);

You are right, thanks for pointing this out! This still needs to be done. It’s a quick addition, I raised a ticket to track it: http://www.couchbase.com/issues/browse/JCBC-590

Will be in for sure soon.

1 Like

Thank you! I appreciate the quick check and inclusion! Keep up the great work!

Can you try this 2.0.1-pre version and see if it works for you?

https://dl.dropboxusercontent.com/u/10007675/Couchbase-Java-Client-2.0.1-SNAPSHOT-b0921ce.zip

1 Like

Replied in other thread - thx again, @daschl.