-
Enhancement
-
Resolution: Obsolete
-
Minor
-
None
-
0.10.1
-
None
-
2
-
2020 Week 19-21 (from May 4), 2020 Week 22-24 (from May 25), 2020 Week 25-27 (from Jun 15)
When you declare RuleUnitData in DRL, DataStore can work without initialization because generated DTO has DataStore initialization (= DataSource.createStore()). But SingletonStore doesn't work because generated DTO doesn't have SingletonStore initialization (DataSource.createSingleton()).
Hello.drl
declare Hello extends RuleUnitData // result : SingletonStore<Result> = DataSource.createSingleton() // This works result : SingletonStore<Result> // This doesn't work messages : DataStore<String> end
HelloDTO.java
public Hello get() { Hello unit = new Hello(); { org.kie.kogito.rules.DataStore<java.lang.String> messages = org.kie.kogito.rules.DataSource.createStore(); unit.setMessages(messages); this.messages.forEach(unit.getMessages()::add); } { unit.getResultList().set(this.resultList); } return unit; }
It fails with NPE when accessed REST endpoint.
Caused by: java.lang.NullPointerException at org.kie.kogito.examples.HelloDTO.get(HelloDTO.java:9) at org.kie.kogito.examples.HelloQueryHelloEndpoint.executeQuery(HelloQueryHelloEndpoint.java:31)
If you explicitly initialize in the DRL (SingletonStore<Result> = DataSource.createSingleton()), it works. So this issue is not serious. Just to align with DataStore behaviour.
Note: however, overwriting in DTO may lose flexibility. See https://issues.redhat.com/browse/KOGITO-2029
- is related to
-
KOGITO-2124 Add a global variable use case in rule examples
- Closed
- relates to
-
KOGITO-2029 Able to use a custom DataStream in declared RuleUnitData
- Open