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

JodaDateSerializer Discards Shape Override Preference #108

Closed
knocknarea opened this issue Sep 12, 2019 · 1 comment
Closed

JodaDateSerializer Discards Shape Override Preference #108

knocknarea opened this issue Sep 12, 2019 · 1 comment
Milestone

Comments

@knocknarea
Copy link

If you create a Serializer (for example LocalTimeSerializer) with a String shape preference, this preference get discarded at this point

if ((format != _format) || (shapeOverride != _shapeOverride)) {

example

class DTO {
   LocalTime timeIn;
}

Configure Module

module.addSerializer(LocalTime.class, new LocalTimeShapedDeserializer(
	    		new JacksonJodaDateFormat(ISODateTimeFormat.hourMinute()), 1));

When the above DTO is serialized, the time is rendered [ hh, mm, sec, ms ] instead of the desired and configured way

The fact that the LocalTime.class serializer has been created to use the string shape (in this instance "hh:mm") gets ignored and in the above code

            } else  {
                useTimestamp = null;
                shapeOverride = 0; // should this not be set to _shapeOverride??
            }
            // must not call if flag defined, to rely on defaults:
            if (useTimestamp != null) {
                format = format.withUseTimestamp(useTimestamp);
            }
            format = format.with(ann);
            if ((format != _format) || (shapeOverride != _shapeOverride)) {
                return withFormat(format, shapeOverride);
            }

@cowtowncoder
Copy link
Member

I would need full code for reproduction: although description helps, there are couple of aspects that are unclear to me, and easiest way is to just show code.

@cowtowncoder cowtowncoder added the need-test-case Reproduction of the problem requires a test case label Sep 22, 2019
@cowtowncoder cowtowncoder added the good first issue Issue that seems easy to resolve and is likely a good candidate for contributors new to project label Oct 3, 2019
@cowtowncoder cowtowncoder changed the title JodaDateSerializer Discards Shape Override Preference JodaDateSerializer Discards Shape Override Preference Oct 3, 2019
vboulaye added a commit to vboulaye/jackson-datatype-joda that referenced this issue Oct 5, 2019
@cowtowncoder cowtowncoder removed good first issue Issue that seems easy to resolve and is likely a good candidate for contributors new to project need-test-case Reproduction of the problem requires a test case labels Oct 5, 2019
@cowtowncoder cowtowncoder added this to the 2.10.1 milestone Oct 5, 2019
@cowtowncoder cowtowncoder changed the title JodaDateSerializer Discards Shape Override Preference JodaDateSerializer Discards Shape Override Preference Oct 5, 2019
cowtowncoder added a commit that referenced this issue Oct 5, 2019
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