HalBuilder / halbuilder-core

HalBuilder Core
38 stars 26 forks source link

NPE while printing empty representation #44

Open C06A opened 6 years ago

C06A commented 6 years ago

In the follow code the print(...) method throws NPE when try to get the type of the tree.

        ResourceRepresentation<Void> empty = ResourceRepresentation.empty();
        JsonRepresentationWriter writer = JsonRepresentationWriter.create();
        ByteString jsonBS = writer.print(empty);
        System.out.println(jsonBS.utf8());

The empty resource should be printed into {} string. This would be empty JSON document.

On another hand because empty JSON is not valid HAL document I guess factory call ResourceRepresentation.empty() should not be allowed.

The same problem exists even of I provide href for self link. So any call to empty(...) produces invalid ResourceRepresentation instance.

talios commented 6 years ago

Technically { } should be a perfectly valid HAL document, as links are option, and as you say - it's a valid JSON object.

I'll take a look at it tonight. Is this a blocking issue for you at all?

C06A commented 6 years ago

I believe {“_links”: {“self”:{“href”:”....”}}} would be the minimal valid HAL document unlike JSON.

It is not blocking for me. I am just learning how to use HALBuilder for now.

CAB

Sent from my iPhone

On Apr 2, 2018, at 11:17 PM, Mark Derricutt notifications@github.com wrote:

Technically { } should be a perfectly valid HAL document, as links are option, and as you say - it's a valid JSON object.

I'll take a look at it tonight. Is this a blocking issue for you at all?

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or mute the thread.