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

writer saves Map<String, CustomType> as Map<Object, Object> #404

Open
Extern-Till-Gehrke opened this issue Nov 15, 2023 · 1 comment
Open
Labels
Prio: Must Must feature for current milestone Type: bug Something isn't working

Comments

@Extern-Till-Gehrke
Copy link

Steps to reproduce

  • camunda-bpm-data version: 1.2.8
  • Camunda BPM version: 7.19.0 with spring boot camunda starter
  • JDK version: 11
  • Operating system: Windows
  • Complete executable reproducer: organization repo
  • Steps: (what exactly are you doing with the above reproducer?)
    I have following:
    public static final VariableFactory<Map<String, StorageFile>> DOCUMENTS = mapVariable(DOCUMENTS_KEY, String.class, StorageFile.class);
    via Spring boot rest endpoint following get executed:
public ResponseEntity<String> addFileToRequest(@RequestHeader("X-Tenant-ID") String gp, @PathVariable String reqId, @RequestBody StorageFile storageFile) {
       var pi = runtimeService.createProcessInstanceQuery().processInstanceBusinessKey(reqId).singleResult();
       securityService.checkBusinessPartner(pi, gp);
       log.debug("Found " + pi.getId() + " ProcessInstance for BusinessKey " + reqId);

       VariableReader reader = CamundaBpmData.reader(runtimeService, pi.getId());
       var linkedfiles = reader.getOrDefault(ProcessVariables.DOCUMENTS, new HashMap<>());
       var status = reader.get(ProcessVariables.STATUS);

       ...

       linkedfiles.put(storageFile.getUuid(), storageFile);
       VariableWriter<?> writer = CamundaBpmData.writer(runtimeService, pi.getId());
       writer.set(ProcessVariables.DOCUMENTS, linkedfiles);

}

and the failing reader running as Spring @org.springframework.scheduling.annotation.Scheduled:

List<ProcessInstance> processInstances = runtimeService.createProcessInstanceQuery().processDefinitionKey("document-request").active().orderByProcessInstanceId().desc().list();
            log.debug("found {} active process-request instances", processInstances.size());
            for (ProcessInstance pi : processInstances) {

                VariableReader variableReader = reader(runtimeService, pi.getId());
...
                var documents = variableReader.getOrDefault(ProcessVariables.DOCUMENTS, new HashMap<>());

Expected behaviour

In Camunda should the value of documents from Map<String, StorageFile> type

Actual behaviour

In Camunda Cockpit the Type (Value) of documents is Map<Object, Object> with the saved StorageFIle data and the reader() will fail with
Error reading documents: Wrong map type detected, expected Map<java.lang.String,my.package.StorageFile, but was not found in {78c33e4d-351d-449e-9932-d752d964f2ab={filename=dummy.pdf, size=1, owner=Name, uuid=78c33e4d-351d-449e-9932-d752d964f2ab, status=UPLOAD}}

(In case of exceptions provide full stack trace)

io.holunda.camunda.bpm.data.adapter.WrongVariableTypeException: Error reading documents: Wrong map type detected, expected Map<java.lang.String,my.package.StorageFile, but was not found in {78c33e4d-351d-449e-9932-d752d964f2ab={filename=dummy.pdf, size=1, owner=Name, uuid=78c33e4d-351d-449e-9932-d752d964f2ab, status=UPLOAD}} at io.holunda.camunda.bpm.data.adapter.map.AbstractMapReadWriteAdapter.getOrNull(AbstractMapReadWriteAdapter.java:63) ~[camunda-bpm-data-1.2.8.jar:na] at io.holunda.camunda.bpm.data.adapter.map.MapReadWriteAdapterRuntimeService.getOptional(MapReadWriteAdapterRuntimeService.java:37) ~[camunda-bpm-data-1.2.8.jar:na] at io.holunda.camunda.bpm.data.reader.RuntimeServiceVariableReader.getOptional(RuntimeServiceVariableReader.java:32) ~[camunda-bpm-data-1.2.8.jar:na] at io.holunda.camunda.bpm.data.reader.VariableReader.getOrDefault(VariableReader.java:72) ~[camunda-bpm-data-1.2.8.jar:na] at my.package.DocumentsStatusUpdateService.updateDocumentsStatus(DocumentsStatusUpdateService.java:56) ~[classes/:na] at jdk.internal.reflect.GeneratedMethodAccessor117.invoke(Unknown Source) ~[na:na] at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:na] at java.base/java.lang.reflect.Method.invoke(Method.java:566) ~[na:na] at org.springframework.scheduling.support.ScheduledMethodRunnable.run(ScheduledMethodRunnable.java:84) ~[spring-context-5.3.27.jar:5.3.27] at org.springframework.scheduling.support.DelegatingErrorHandlingRunnable.run(DelegatingErrorHandlingRunnable.java:54) ~[spring-context-5.3.27.jar:5.3.27] at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515) ~[na:na] at java.base/java.util.concurrent.FutureTask.runAndReset(FutureTask.java:305) ~[na:na] at java.base/java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:305) ~[na:na] at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128) ~[na:na] at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628) ~[na:na] at java.base/java.lang.Thread.run(Thread.java:834) ~[na:na]

@zambrovski zambrovski added the Type: breaking Breaks the existing functionality and should be looked at with care. label Nov 21, 2023
@zambrovski
Copy link
Member

Currently can't reproduce it using the example. Will still let it opened.

@zambrovski zambrovski added Type: bug Something isn't working Prio: Must Must feature for current milestone and removed Type: breaking Breaks the existing functionality and should be looked at with care. labels Nov 21, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Prio: Must Must feature for current milestone Type: bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants