Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Serializing and deserializing a blank URI returns null #398

Closed
pgieser opened this issue Feb 5, 2014 · 5 comments
Closed

Serializing and deserializing a blank URI returns null #398

pgieser opened this issue Feb 5, 2014 · 5 comments
Milestone

Comments

@pgieser
Copy link

pgieser commented Feb 5, 2014

Here is a failing test:

    public void test() throws Exception {
        URI blankUri = URI.create("");
        assertNotNull(blankUri);

        ObjectMapper objectMapper = new ObjectMapper();

        assertNotNull("serialized and deserialized blank URI should not be null",
                objectMapper.readValue(objectMapper.writeValueAsString(blankUri), URI.class));
    }
@cowtowncoder
Copy link
Member

Hmmh. Is empty String really valid for URI creation? Interesting...

@pgieser
Copy link
Author

pgieser commented Feb 5, 2014

It's an admitted edge case. The URI javadoc specifies a few exceptions to RFC 2396 that perhaps allow an empty string to be parsed without generating an exception.

@pgieser
Copy link
Author

pgieser commented Feb 5, 2014

Actually, I think the issue is that URI can represent not just absolute URI's, but also URI references.

From Wikipedia:

A URI reference may take the form of a full URI, or just the scheme-specific portion of one, or even some trailing component thereof – even the empty string.

@cowtowncoder
Copy link
Member

Ok. Given this definition there is a meaningful definition for empty String, aside from missing (null) value. Should be easy enough to fix; I am guessing deserializer just has specific check to consider it null.

@pgieser
Copy link
Author

pgieser commented Feb 5, 2014

Looks like FromStringDeserializer short-circuits to return null on an empty string instead of delegating immediately to URIDeserializer.

cowtowncoder added a commit that referenced this issue Feb 5, 2014
@cowtowncoder cowtowncoder added this to the 2.3 milestone Feb 5, 2014
attila-it4all added a commit to smartbit4all/platform that referenced this issue Jan 8, 2024
See FasterXML/jackson-databind#398, but we
don't need this edge case handling, client sends empty selection as
empty string, so this should be handled as null.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants