[JBoss JIRA] (DROOLS-5655) ObjectDataCompiler converter does not compile all template rules
by Mario Fusco (Jira)
[ https://issues.redhat.com/browse/DROOLS-5655?page=com.atlassian.jira.plug... ]
Mario Fusco resolved DROOLS-5655.
---------------------------------
Resolution: Explained
The ObjectDataCompiler is actually unaware of drl syntax. It doesn't know what a constraint is and remove it from the generated text in case of a null value. What it does instead when a line is bound to one or more nulls is omitting the entire line from the drl. In your case you could workaround the problem and obtain the result you want (if I have understood correctly) by simply putting a constraint per line and paying attention when the comma separating the 2 constraints should or shouldn't be added. Something like that should work for you
{code:java}
$p : Person(
age >= @{minage}
@if{minage != null && maxage != null},@end{}
age < @{maxage}
) {code}
> ObjectDataCompiler converter does not compile all template rules
> ----------------------------------------------------------------
>
> Key: DROOLS-5655
> URL: https://issues.redhat.com/browse/DROOLS-5655
> Project: Drools
> Issue Type: Bug
> Reporter: Oualid AMCHAYD
> Assignee: Mario Fusco
> Priority: Major
> Attachments: image-2020-09-18-11-31-28-879.png
>
>
> When trying to compile a rule template with a datasource, the compilers does not compiles the rows with empty fields.
> Here is the code I am using:
> {code:java}
> ObjectDataCompiler converter = new ObjectDataCompiler();
>
> Collection<MyRule> rulesRep = rulerepo.findAll();
> InputStream personInputStream = null;
> try {
> personInputStream = ResourceFactory.newClassPathResource("rules.drt").getInputStream(); // convert sample.drt in resource to input stream
> } catch (IOException e) {
> e.printStackTrace();
> }
> KieFileSystem kieFileSystem = kieServices.newKieFileSystem();
>
> String personDrl = converter.compile(rulesRep, personInputStream);
> kieFileSystem.write("src/main/resources/person_rule.drl", kieServices.getResources().newReaderResource(new StringReader(personDrl)));
>
> {code}
> This is my datasource, which have two empty fields in two rows.
> !image-2020-09-18-11-31-28-879.png!
> And this is the result i got for the two rows with an empty fields :
> {code:java}
> rule "ageRule_1"
> when
> then
> $person.setStatus("Infant");
> end
> rule "ageRule_8"
> when
> then
> $person.setStatus("Old Aged");
> end
> {code}
> As you see the LHS are is generated in two rules.
> Am i missing something or this is a normal behaviour when having empty fields.
> Thanks in advance.
--
This message was sent by Atlassian Jira
(v7.13.8#713008)
5 years, 3 months
[JBoss JIRA] (DROOLS-5655) ObjectDataCompiler converter does not compile all template rules
by Mario Fusco (Jira)
[ https://issues.redhat.com/browse/DROOLS-5655?page=com.atlassian.jira.plug... ]
Mario Fusco updated DROOLS-5655:
--------------------------------
Sprint: 2020 Week 37-39 (from Sep 7)
> ObjectDataCompiler converter does not compile all template rules
> ----------------------------------------------------------------
>
> Key: DROOLS-5655
> URL: https://issues.redhat.com/browse/DROOLS-5655
> Project: Drools
> Issue Type: Bug
> Reporter: Oualid AMCHAYD
> Assignee: Mario Fusco
> Priority: Major
> Attachments: image-2020-09-18-11-31-28-879.png
>
>
> When trying to compile a rule template with a datasource, the compilers does not compiles the rows with empty fields.
> Here is the code I am using:
> {code:java}
> ObjectDataCompiler converter = new ObjectDataCompiler();
>
> Collection<MyRule> rulesRep = rulerepo.findAll();
> InputStream personInputStream = null;
> try {
> personInputStream = ResourceFactory.newClassPathResource("rules.drt").getInputStream(); // convert sample.drt in resource to input stream
> } catch (IOException e) {
> e.printStackTrace();
> }
> KieFileSystem kieFileSystem = kieServices.newKieFileSystem();
>
> String personDrl = converter.compile(rulesRep, personInputStream);
> kieFileSystem.write("src/main/resources/person_rule.drl", kieServices.getResources().newReaderResource(new StringReader(personDrl)));
>
> {code}
> This is my datasource, which have two empty fields in two rows.
> !image-2020-09-18-11-31-28-879.png!
> And this is the result i got for the two rows with an empty fields :
> {code:java}
> rule "ageRule_1"
> when
> then
> $person.setStatus("Infant");
> end
> rule "ageRule_8"
> when
> then
> $person.setStatus("Old Aged");
> end
> {code}
> As you see the LHS are is generated in two rules.
> Am i missing something or this is a normal behaviour when having empty fields.
> Thanks in advance.
--
This message was sent by Atlassian Jira
(v7.13.8#713008)
5 years, 3 months
[JBoss JIRA] (WFLY-13790) Memory leak caused by org.eclipse.yasson.internal.JsonBinding
by Alessio Soldano (Jira)
[ https://issues.redhat.com/browse/WFLY-13790?page=com.atlassian.jira.plugi... ]
Alessio Soldano reassigned WFLY-13790:
--------------------------------------
Assignee: r searls (was: Alessio Soldano)
> Memory leak caused by org.eclipse.yasson.internal.JsonBinding
> -------------------------------------------------------------
>
> Key: WFLY-13790
> URL: https://issues.redhat.com/browse/WFLY-13790
> Project: WildFly
> Issue Type: Bug
> Components: REST
> Affects Versions: 20.0.1.Final
> Reporter: Ahcene Kessal
> Assignee: r searls
> Priority: Major
>
> org.eclipse.yasson.internal.JsonBinding keeps a reference on an enum after the war is undeployed which results in a classloader leak.
> 1- Deploy the following application:
>
> {code:java}
> package au.com.spatiumxl.model;
> public class Book {
> public enum Status { READ, UNREAD }
> private String title;
> private Book.Status status;
> public Book(String title) {
> this.title = title;
> this.status = Book.Status.UNREAD;
> }
> public String getTitle() {
> return title;
> }
> public Book.Status getStatus() {
> return status;
> }
> }
> {code}
>
> {code:java}
> package au.com.spatiumxl.ejb;
> [...]
> import au.com.spatiumxl.model.Book;
> @Stateless
> @LocalBean
> public class BookService {
> public List<Book> getBooks() {
> List<Book> books = new ArrayList<>();
> books.add(new Book("title1"));
> return books;
> }
> }
> {code}
>
> {code:java}
> package au.com.spatiumxl.rest;
> [...]
> import au.com.spatiumxl.ejb.BookService;
> import au.com.spatiumxl.model.Book;
> @RequestScoped
> @Path("")public
> class BookEndPoint {
> @Inject BookService bookService;
> @GET @Path("/get-books")
> @Produces("application/json")
> public List<Book> getBooks() {
> return bookService.getBooks();
> }
> }
> {code}
>
> 2- On the browser go to: http://<host>/<context-root>/.../get-books
> 3- Undeploy the war
> 4- The memory analyser shows:
> {code:java}
> java.lang.Thread
> org.jboss.modules.ModuleClassLoader
> org.jboss.modules.Module
> org.jboss.modules.LocalModuleLoader
> java.util.concurrent.ConcurrentHashMap
> java.util.concurrent.ConcurrentHashMap$Node[]
> java.util.concurrent.ConcurrentHashMap$Node
> org.jboss.modules.ModuleLoader$FutureModule
> org.jboss.modules.Module
> org.jboss.modules.ModuleClassLoader
> java.util.Vector
> java.lang.Object[]
> org.jboss.resteasy.plugins.providers.jsonb.AbstractJsonBindingProvider
> org.eclipse.yasson.internal.JsonBinding
> org.eclipse.yasson.internal.JsonbContext
> org.eclipse.yasson.internal.MappingContext
> java.util.concurrent.ConcurrentHashMap
> java.util.concurrent.ConcurrentHashMap$Node[]
> java.util.concurrent.ConcurrentHashMap$Node
> org.eclipse.yasson.internal.model.ClassModel
> org.eclipse.yasson.internal.model.PropertyModel[]
> org.eclipse.yasson.internal.model.PropertyModel
> au.com.spatiumxl.model.Book$Status
> {code}
--
This message was sent by Atlassian Jira
(v7.13.8#713008)
5 years, 3 months