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

com.fasterxml.jackson.databind.JsonMappingException: lateinit property value has not been initialized #731

Open
1 task done
asqatqazet opened this issue Nov 30, 2023 · 1 comment
Labels

Comments

@asqatqazet
Copy link

Search before asking

  • I searched in the issues and found nothing similar.

Describe the bug

I was serializing an object into xml and the object is read from xml as well, so some value declared as lateinit might be missing and not initializedd. from my opionion, this values can be leaved as null or empty if it is not initialized rather than throwing exception and not being able to progress.

To Reproduce

// Your code here
How the mapper is nitialized: 
   val xmlMapper = XmlMapper.builder()
            .defaultUseWrapper(false)
            .configure(ToXmlGenerator.Feature.WRITE_XML_DECLARATION, true)
            .configure(ToXmlGenerator.Feature.UNWRAP_ROOT_OBJECT_NODE, true)
            .build()
            .registerKotlinModule()


How my lateinit value is declared: 

    @field:JacksonXmlText
    lateinit var value: String private set


and there is builtin feature in kotlin to determine whether the value is initialized:

    fun isValueInitialized(): Boolean {
        return ::value.isInitialized
    }

Expected behavior

No response

Versions

Kotlin:
Jackson-module-kotlin:
Jackson-databind:

Additional context

No response

@asqatqazet asqatqazet added the bug label Nov 30, 2023
@cowtowncoder
Copy link
Member

I assume the issue is not really XML related? If so, would be nice to get JSON reproduction, instead of XML one.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants