Open a-kshesh opened 1 year ago
@a-kshesh Could you try this ?
private HashMap<String, String> city;
cc @baldimir @fjtirado @cristianonicolai
@radtriste Thanks. I tried HashMap and it is working. May I know why it is not able to instantiates the Map interface or do I have to explicitly do that?
@radtriste Thanks. I tried HashMap and it is working. May I know why it is not able to instantiates the Map interface or do I have to explicitly do that?
This was just a guess.
@mariofusco @danielezonca @tarilabs @tkobayas may help more on that
I tested the same and found this Java code generated internally.
package org.kie.kogito.app;
import java.io.IOException;
import org.infinispan.protostream.MessageMarshaller;
public class MapMessageMarshaller implements MessageMarshaller<java.util.Map> {
public java.lang.Class<java.util.Map> getJavaClass() {
return java.util.Map.class;
}
public String getTypeName() {
return "org.kie.kogito.app.Map";
}
public java.util.Map readFrom(ProtoStreamReader reader) throws IOException {
java.util.Map value = new java.util.Map();
return value;
}
public void writeTo(ProtoStreamWriter writer, java.util.Map t) throws IOException {
}
}
The readFrom
method is generated here: https://github.com/kiegroup/kogito-runtimes/blob/1.42.0.Final/kogito-codegen-modules/kogito-codegen-processes/src/main/java/org/kie/kogito/codegen/process/persistence/marshaller/AbstractMarshallerGenerator.java#L172-L173
I think the process team can look at this whether it should be fixed or is an expected behaviour. @cristianonicolai
Describe the bug
I am using the process-postgresql-persistence-quarkus example on my MAC to showcase my problem and in there for Address.java class, I changed
String city;
toprivate Map<String, String> city;
which leads to an error asExpected behavior
Mapmarshller throws that java.util.Map is abstract; cannot be instantiated. I tried to instantiate it private Map<String, String> city; = new HashMap<String,String>(); but it throws the same error. Kindly please advise on what needs to be done.
Thanks.
Actual behavior
I expect it to accept the Map abstract data type.
How to Reproduce?
Reproducer:
process-postgresql-persistence-quarkus example to showcase my problem and in there for Address.java class, I changed
private String city;
toprivate Map<String, String> city;
If I remove the kogito-addons-quarkus-persistence-jdbc dependency from the project then it works as expected.Output of
uname -a
orver
No response
Output of
java -version
openjdk version "17.0.7" 2023-04-18
GraalVM version (if different from Java)
No response
Kogito version or git rev (or at least Quarkus version if you are using Kogito via Quarkus platform BOM)
quarkus platform version 2.16.8.Final
Build tool (ie. output of
mvnw --version
orgradlew --version
)maven- 17
Additional information
I am not specifying the version of kogito-addons-quarkus-persistence-jdbc so I am assuming that it uses a current stable version of that.