uploadcare / uploadcare-java

Java API client that handles uploads and further operations with files by wrapping Uploadcare Upload and REST APIs.
https://uploadcare.com
Apache License 2.0
6 stars 13 forks source link

Annotate File.ColorMode to provide compatibility with Jackson 2.16.0-2.16.1 deserialization #66

Closed sbailliez closed 8 months ago

sbailliez commented 9 months ago

See https://github.com/FasterXML/jackson-databind/issues/4409 for context.

Jackson 2.16.0 and 2.16.1 break the uploadcare client because of the presence of RGBA and RGBa in FileColor.Mode

Code / screenshots

    public static class Bug {
        public File.ColorMode colorMode;
    }

    @Test
    public void enumFails() throws Exception {
        String json = "{ \"color_mode\": \"RGBa\"}";

        // duplicate the way the mapper is configured in uploadcare
        ObjectMapper mapper = new ObjectMapper();
        mapper.setPropertyNamingStrategy(PropertyNamingStrategies.SNAKE_CASE);
        mapper.disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES);

        Bug bug = mapper.readValue(json, Bug.class);
    }

The enum File.ColorMode needs to be annotated explicitly to behave properly.

Environment

rsedykh commented 9 months ago

Hi @sbailliez! We'll be able to look into this in a week.

JooHyukKim commented 9 months ago

@rsedykh FYI, thanks to @sbailliez's report we were able to add a patch to 2.16 version, so upgrade to 2.16 would do the trick 👍🏼

rsedykh commented 8 months ago

Thank you, guys! https://github.com/uploadcare/uploadcare-java/releases/tag/v3.5.3