Skip to content

(mrbean) Problem with Optional<T>, AtomicReference<T> valued properties #8

@tvk

Description

@tvk

Hello,

I'd really like to use your mrbean module, but it does not seem to support java 8 optionals. Is this correct? Do you have planned adding support for this?

I've created a small testcase and that does not seem to work. It throws an GenericSignatureFormatError...
`

import java.util.Optional;

import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter;
import org.springframework.mock.http.MockHttpInputMessage;

import com.fasterxml.jackson.datatype.jdk8.Jdk8Module;
import com.fasterxml.jackson.module.mrbean.MrBeanModule;

public class ReadOptionalTest {

    public static final String json = "{\"string\":\"value\",\"optionalString\":\"anotherValue\"}";
    public static interface MyInterface {

        String getString();
        Optional<String> getOptionalString();
    }
    private MappingJackson2HttpMessageConverter messageConverter;

    @Before
    public void setup() {
        this.messageConverter = new MappingJackson2HttpMessageConverter();
        this.messageConverter.getObjectMapper().registerModules(new Jdk8Module(), new MrBeanModule());
    }

    @Test
    public void testReadObject() throws Exception {
        final MyInterface object = (MyInterface) messageConverter.read(MyInterface.class, new MockHttpInputMessage(json.getBytes()));
        Assert.assertNotNull(object);
    }
}

`

Best regards,
Thomas

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions