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

Provider state params not serialized correctly in pact file #1234

Closed
diana-zaharia opened this issue Oct 23, 2020 · 3 comments
Closed

Provider state params not serialized correctly in pact file #1234

diana-zaharia opened this issue Oct 23, 2020 · 3 comments

Comments

@diana-zaharia
Copy link

Spotted issue in pact-jvm v4.1.9, but I assume all versions since 4.1.0 (which dropped Gson library for json parsing) are affected.

When sending any custom object as provider state param, it gets written to pact file as null
E.g. specifying a provider state as:

given("my custom object exists", "id", UUID.randomUUID())

will get written to pact file as:

"providerStates": [
  {
    "name": "my custom object exists",
    "params": {
      "id": null
    }
  }
]

Any primitives or boxed primitives seem to be serialized fine.

@uglyog
Copy link
Member

uglyog commented Nov 6, 2020

Version 4.1.10 has been released with this fix

@diana-zaharia
Copy link
Author

diana-zaharia commented Nov 6, 2020

Hey @uglyog thanks for the updates, I tried version 4.1.10 but it seems serialization is still not working for immutable objects.
Do you think there's anything that can be done about that? 😕

java.lang.IllegalAccessException: class kotlin.reflect.jvm.internal.calls.CallerImpl$FieldGetter cannot access a member of class java.util.UUID (in module java.base) with modifiers "private final"
kotlin.reflect.full.IllegalCallableAccessException: java.lang.IllegalAccessException: class kotlin.reflect.jvm.internal.calls.CallerImpl$FieldGetter cannot access a member of class java.util.UUID (in module java.base) with modifiers "private final"
	at kotlin.reflect.jvm.internal.KCallableImpl.call(KCallableImpl.kt:224)
	at au.com.dius.pact.core.support.Utils.objectToJsonMap(Utils.kt:85)
	at au.com.dius.pact.core.support.Utils.jsonSafeValue(Utils.kt:101)
	at au.com.dius.pact.core.model.ProviderState.toMap(ProviderState.kt:19)

@uglyog
Copy link
Member

uglyog commented Nov 15, 2020

@diana-zaharia It needs to be a POJO. Just call .toString() on the UUID.

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