Dapr client.saveStore(..) doesn't honour stateSerializer contentType
Expected Behavior
After calling client.saveStore(..) with some arbitrary state like in StateClient.java example. I would like that state stored should look like this using MongoDb:
Actual Behavior
Steps to Reproduce the Problem
Run example StateClient.java using Mongo as statestore.
dapr run --components-path ./components/state --app-id state-example -- java -jar target/dapr-java-sdk-examples-exec.jar io.dapr.examples.state.StateClient 'my message'
Release Note
RELEASE NOTE: FIX Dapr java SDK client uses default state serializer contentType when saving states. By the default json.
My suggestion to solve the problem is to use the defaultStateSerializer contentType when building the StateRequest.
Similarly like if one saves the state using 'saveBulkState' method:
Map<String, String> meta = new HashMap<>();
// Dapr built-in saveState method doesn't define the value contentType, causing to store in MongoDb a String
meta.put("contentType", "application/json");
StateOptions options =
new StateOptions(StateOptions.Consistency.EVENTUAL, StateOptions.Concurrency.LAST_WRITE);
SaveStateRequest request =
new SaveStateRequest(STATE_STORE_NAME).setStates(new State<>(FIRST_KEY_NAME, myClass, "", meta, options));
This would be a great opportunity to make this change if you are up opening a PR 🙂 @antoniomaria
I would be delighted to do it, I am just a bit newbie in open source collaboration. If someone assigns the ticket to my self, and can open a PR and.. start the review process.
I just opened a PR with my suggestion. It needs some E2E testing, or more junit coverage but I think, explains what I am trying to achieve. https://github.com/dapr/java-sdk/pull/1033
@cicoyle could you ask feedback for my https://github.com/dapr/java-sdk/pull/1033 ? it's has been idled for quite a while