[JBoss JIRA] (DROOLS-5346) Enhance unit test to detect non-externalized lambda widely
by Toshiya Kobayashi (Jira)
[ https://issues.redhat.com/browse/DROOLS-5346?page=com.atlassian.jira.plug... ]
Toshiya Kobayashi commented on DROOLS-5346:
-------------------------------------------
For example, if you add the following code to BaseModelTest, you can easily check if unit tests generate non-externalized lambda or not.
{code:java}
public abstract class BaseModelTest {
static {
//System.setProperty("drools.externaliseCanonicalModelLambda", "true");
System.setProperty("drools.check.nonExternalisedLambda", "true");
}
{code}
> Enhance unit test to detect non-externalized lambda widely
> ----------------------------------------------------------
>
> Key: DROOLS-5346
> URL: https://issues.redhat.com/browse/DROOLS-5346
> Project: Drools
> Issue Type: Sub-task
> Components: executable model
> Affects Versions: 7.37.0.Final
> Reporter: Toshiya Kobayashi
> Assignee: Toshiya Kobayashi
> Priority: Major
> Fix For: 7.38.0.Final
>
>
> Currently "lambda is not externalized" issue is not widely detected in unit tests. We need to write a specific assertion like this:
> {code:java}
> @Test
> public void testExternalizeBindingVariableLambda() throws Exception {
> String str =
> "package defaultpkg;\n" +
> "import " + Person.class.getCanonicalName() + ";" +
> "global java.util.List list;\n" +
> "rule R when\n" +
> " $p : Person($n : name == \"Mario\")\n" +
> "then\n" +
> " list.add($n);\n" +
> "end";
> KieModuleModel kieModuleModel = KieServices.get().newKieModuleModel();
> kieModuleModel.setConfigurationProperty("drools.externaliseCanonicalModelLambda", Boolean.TRUE.toString());
> KieSession ksession = getKieSession(kieModuleModel, str );
> final List<String> list = new ArrayList<>();
> ksession.setGlobal("list", list);
> if (testRunType == RUN_TYPE.FLOW_DSL || testRunType == RUN_TYPE.PATTERN_DSL) {
> RuleImpl rule = (RuleImpl)ksession.getKieBase().getRule("defaultpkg", "R");
> Pattern pattern = (Pattern)rule.getLhs().getChildren().get(0);
> Declaration declaration = pattern.getDeclarations().get("$n");
> LambdaReadAccessor lambdaReadAccessor = (LambdaReadAccessor)declaration.getExtractor();
> Field field = LambdaReadAccessor.class.getDeclaredField("lambda");
> field.setAccessible(true);
> Function1.Impl function1 = (Function1.Impl)field.get(lambdaReadAccessor);
> Object lambda = function1.getLambda();
> assertThat(lambda.getClass().getName(), containsString("LambdaExtractor")); // materialized Lambda
> }
> Person me = new Person( "Mario", 40 );
> ksession.insert( me );
> ksession.fireAllRules();
> Assertions.assertThat(list).containsExactlyInAnyOrder("Mario");
> }
> {code}
> This JIRA is to enhance unit tests to assert it widely.
--
This message was sent by Atlassian Jira
(v7.13.8#713008)
5 years, 3 months
[JBoss JIRA] (DROOLS-5386) Accumulate with static method with pettern bind variable
by Toshiya Kobayashi (Jira)
[ https://issues.redhat.com/browse/DROOLS-5386?page=com.atlassian.jira.plug... ]
Toshiya Kobayashi updated DROOLS-5386:
--------------------------------------
Description:
This rule fails with PATTERN_DSL
{noformat}
rule R when
accumulate (
$p : Person(), $result : sum( MyUtil.add($p.getAge(), 10) ) )
then
insert($result);
end
{noformat}
It generates a lambda with duplicated parameters "_this" and "$p" which are the same Pattern input bind variable.
{code:java}
org.drools.model.Rule rule = D.rule("R").build(D.accumulate(D.pattern(var_$p).bind(var_C6D512FA5D3AACA24A83BF1EE132C0B2,
var_$p,
(_this, $p) -> MyUtil.add($p.getAge(),10)),
{code}
So fails at runtime
{noformat}
[ERROR] testAccumulateStaticMethodWithPatternBindVar[PATTERN_DSL](org.drools.modelcompiler.AccumulateTest) Time elapsed: 3.151 s <<< ERROR!
java.lang.RuntimeException: java.lang.ArrayIndexOutOfBoundsException: Array index out of range: 1
at org.drools.core.rule.SingleAccumulate.accumulate(SingleAccumulate.java:105)
at org.drools.core.phreak.PhreakAccumulateNode.addMatch(PhreakAccumulateNode.java:714)
at org.drools.core.phreak.PhreakAccumulateNode.doLeftInserts(PhreakAccumulateNode.java:168)
at org.drools.core.phreak.PhreakAccumulateNode.doNode(PhreakAccumulateNode.java:89)
at org.drools.core.phreak.RuleNetworkEvaluator.switchOnDoBetaNode(RuleNetworkEvaluator.java:583)
at org.drools.core.phreak.RuleNetworkEvaluator.evalBetaNode(RuleNetworkEvaluator.java:554)
at org.drools.core.phreak.RuleNetworkEvaluator.evalNode(RuleNetworkEvaluator.java:381)
at org.drools.core.phreak.RuleNetworkEvaluator.innerEval(RuleNetworkEvaluator.java:341)
at org.drools.core.phreak.RuleNetworkEvaluator.outerEval(RuleNetworkEvaluator.java:177)
at org.drools.core.phreak.RuleNetworkEvaluator.evaluateNetwork(RuleNetworkEvaluator.java:135)
at org.drools.core.phreak.RuleExecutor.reEvaluateNetwork(RuleExecutor.java:213)
at org.drools.core.phreak.RuleExecutor.evaluateNetworkAndFire(RuleExecutor.java:88)
at org.drools.core.concurrent.AbstractRuleEvaluator.internalEvaluateAndFire(AbstractRuleEvaluator.java:33)
at org.drools.core.concurrent.SequentialRuleEvaluator.evaluateAndFire(SequentialRuleEvaluator.java:43)
at org.drools.core.common.DefaultAgenda.fireLoop(DefaultAgenda.java:1101)
at org.drools.core.common.DefaultAgenda.internalFireAllRules(DefaultAgenda.java:1048)
at org.drools.core.common.DefaultAgenda.fireAllRules(DefaultAgenda.java:1040)
at org.drools.core.impl.StatefulKnowledgeSessionImpl.internalFireAllRules(StatefulKnowledgeSessionImpl.java:1336)
at org.drools.core.impl.StatefulKnowledgeSessionImpl.fireAllRules(StatefulKnowledgeSessionImpl.java:1327)
at org.drools.core.impl.StatefulKnowledgeSessionImpl.fireAllRules(StatefulKnowledgeSessionImpl.java:1311)
at org.drools.modelcompiler.AccumulateTest.testAccumulateStaticMethodWithPatternBindVar(AccumulateTest.java:2058)
...
Caused by: java.lang.ArrayIndexOutOfBoundsException: Array index out of range: 1
at org.drools.model.view.BindViewItem2.eval(BindViewItem2.java:89)
at org.drools.modelcompiler.constraints.BindingEvaluator.evaluate(BindingEvaluator.java:39)
at org.drools.modelcompiler.constraints.BindingEvaluator.evaluate(BindingEvaluator.java:35)
at org.drools.modelcompiler.constraints.LambdaAccumulator$BindingAcc.getAccumulatedObject(LambdaAccumulator.java:146)
at org.drools.modelcompiler.constraints.LambdaAccumulator.accumulate(LambdaAccumulator.java:86)
at org.drools.core.rule.SingleAccumulate.accumulate(SingleAccumulate.java:97)
... 53 more
{noformat}
was:
This rule fails with PATTERN_DSL
{noformat}
rule R when
accumulate (
$p : Person(), $result : sum( MyUtil.add($p.getAge(), 10) ) )
then
insert($result);
end
{noformat}
> Accumulate with static method with pettern bind variable
> --------------------------------------------------------
>
> Key: DROOLS-5386
> URL: https://issues.redhat.com/browse/DROOLS-5386
> Project: Drools
> Issue Type: Bug
> Components: executable model
> Affects Versions: 7.38.0.Final
> Reporter: Toshiya Kobayashi
> Assignee: Toshiya Kobayashi
> Priority: Major
>
> This rule fails with PATTERN_DSL
> {noformat}
> rule R when
> accumulate (
> $p : Person(), $result : sum( MyUtil.add($p.getAge(), 10) ) )
> then
> insert($result);
> end
> {noformat}
> It generates a lambda with duplicated parameters "_this" and "$p" which are the same Pattern input bind variable.
> {code:java}
> org.drools.model.Rule rule = D.rule("R").build(D.accumulate(D.pattern(var_$p).bind(var_C6D512FA5D3AACA24A83BF1EE132C0B2,
> var_$p,
> (_this, $p) -> MyUtil.add($p.getAge(),10)),
> {code}
> So fails at runtime
> {noformat}
> [ERROR] testAccumulateStaticMethodWithPatternBindVar[PATTERN_DSL](org.drools.modelcompiler.AccumulateTest) Time elapsed: 3.151 s <<< ERROR!
> java.lang.RuntimeException: java.lang.ArrayIndexOutOfBoundsException: Array index out of range: 1
> at org.drools.core.rule.SingleAccumulate.accumulate(SingleAccumulate.java:105)
> at org.drools.core.phreak.PhreakAccumulateNode.addMatch(PhreakAccumulateNode.java:714)
> at org.drools.core.phreak.PhreakAccumulateNode.doLeftInserts(PhreakAccumulateNode.java:168)
> at org.drools.core.phreak.PhreakAccumulateNode.doNode(PhreakAccumulateNode.java:89)
> at org.drools.core.phreak.RuleNetworkEvaluator.switchOnDoBetaNode(RuleNetworkEvaluator.java:583)
> at org.drools.core.phreak.RuleNetworkEvaluator.evalBetaNode(RuleNetworkEvaluator.java:554)
> at org.drools.core.phreak.RuleNetworkEvaluator.evalNode(RuleNetworkEvaluator.java:381)
> at org.drools.core.phreak.RuleNetworkEvaluator.innerEval(RuleNetworkEvaluator.java:341)
> at org.drools.core.phreak.RuleNetworkEvaluator.outerEval(RuleNetworkEvaluator.java:177)
> at org.drools.core.phreak.RuleNetworkEvaluator.evaluateNetwork(RuleNetworkEvaluator.java:135)
> at org.drools.core.phreak.RuleExecutor.reEvaluateNetwork(RuleExecutor.java:213)
> at org.drools.core.phreak.RuleExecutor.evaluateNetworkAndFire(RuleExecutor.java:88)
> at org.drools.core.concurrent.AbstractRuleEvaluator.internalEvaluateAndFire(AbstractRuleEvaluator.java:33)
> at org.drools.core.concurrent.SequentialRuleEvaluator.evaluateAndFire(SequentialRuleEvaluator.java:43)
> at org.drools.core.common.DefaultAgenda.fireLoop(DefaultAgenda.java:1101)
> at org.drools.core.common.DefaultAgenda.internalFireAllRules(DefaultAgenda.java:1048)
> at org.drools.core.common.DefaultAgenda.fireAllRules(DefaultAgenda.java:1040)
> at org.drools.core.impl.StatefulKnowledgeSessionImpl.internalFireAllRules(StatefulKnowledgeSessionImpl.java:1336)
> at org.drools.core.impl.StatefulKnowledgeSessionImpl.fireAllRules(StatefulKnowledgeSessionImpl.java:1327)
> at org.drools.core.impl.StatefulKnowledgeSessionImpl.fireAllRules(StatefulKnowledgeSessionImpl.java:1311)
> at org.drools.modelcompiler.AccumulateTest.testAccumulateStaticMethodWithPatternBindVar(AccumulateTest.java:2058)
> ...
> Caused by: java.lang.ArrayIndexOutOfBoundsException: Array index out of range: 1
> at org.drools.model.view.BindViewItem2.eval(BindViewItem2.java:89)
> at org.drools.modelcompiler.constraints.BindingEvaluator.evaluate(BindingEvaluator.java:39)
> at org.drools.modelcompiler.constraints.BindingEvaluator.evaluate(BindingEvaluator.java:35)
> at org.drools.modelcompiler.constraints.LambdaAccumulator$BindingAcc.getAccumulatedObject(LambdaAccumulator.java:146)
> at org.drools.modelcompiler.constraints.LambdaAccumulator.accumulate(LambdaAccumulator.java:86)
> at org.drools.core.rule.SingleAccumulate.accumulate(SingleAccumulate.java:97)
> ... 53 more
> {noformat}
--
This message was sent by Atlassian Jira
(v7.13.8#713008)
5 years, 3 months
[JBoss JIRA] (WFLY-13542) Container does not enforce bean-managed concurrency for timeout methods
by Fábio Silva (Jira)
[ https://issues.redhat.com/browse/WFLY-13542?page=com.atlassian.jira.plugi... ]
Fábio Silva updated WFLY-13542:
-------------------------------
Steps to Reproduce:
Sample bean:
{code:java}
import java.util.concurrent.locks.ReentrantLock;
import javax.ejb.Asynchronous;
import javax.ejb.ConcurrencyManagement;
import javax.ejb.ConcurrencyManagementType;
import javax.ejb.Schedule;
import javax.ejb.Singleton;
@Singleton
@ConcurrencyManagement(ConcurrencyManagementType.BEAN)
public class MySingleton {
private static final ReentrantLock locker = new ReentrantLock();
@Schedule(persistent = false, second = "0/1", minute = "*", hour = "*")
public void requestEntry() {
long id = Thread.currentThread().getId();
if (locker.tryLock()) {
System.out.println("Please come in, " + id + "!");
doSomething();
locker.unlock();
} else {
System.err.println("Please wait outside, " + id + "!");
}
}
private void doSomething() {
int timeout = (int) (Math.random() * 8000 + 1000);
try {
Thread.sleep(timeout);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
}
{code}
was:
Sample bean:
{code:java}
import java.util.concurrent.locks.ReentrantLock;
import javax.ejb.Asynchronous;
import javax.ejb.ConcurrencyManagement;
import javax.ejb.ConcurrencyManagementType;
import javax.ejb.Schedule;
import javax.ejb.Singleton;
@Singleton
@ConcurrencyManagement(ConcurrencyManagementType.BEAN)
public class MySingleton {
private static final ReentrantLock locker = new ReentrantLock();
@Schedule(persistent = false, second = "0/1", minute = "*", hour = "*")
public void requestEntry() {
long id = Thread.currentThread().getId();
if (locker.tryLock()) {
System.out.println("Please come in, " + id + "!");
doSomething();
locker.unlock();
} else {
System.err.println("Please wait outside, " + id + "!");
}
}
private void doSomething() {
int timeout = (int) (Math.random() * 8000 + 1000);
try {
Thread.sleep(timeout);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
}
{code}
> Container does not enforce bean-managed concurrency for timeout methods
> -----------------------------------------------------------------------
>
> Key: WFLY-13542
> URL: https://issues.redhat.com/browse/WFLY-13542
> Project: WildFly
> Issue Type: Bug
> Components: EJB
> Affects Versions: 19.1.0.Final
> Reporter: Fábio Silva
> Assignee: Cheng Fang
> Priority: Major
>
> Bean-managed concurrency for @Singleton EJBs is not enforced for timeout methods annotated with @Schedule. When a timeout is fired while the previous one is still running, the timeout method is not called. Instead, WildFly logs a warning like the following:
> {code:java}
> 20:58:54,000 WARN [org.jboss.as.ejb3.timer] (EJB default - 2) WFLYEJB0043: A previous execution of timer [id=aa716284-ef7b-4bb3-a356-a8ca187255c4 timedObjectId=myweb.myweb.MySingleton auto-timer?:true persistent?:false timerService=org.jboss.as.ejb3.timerservice.TimerServiceImpl@303bd2d5 previousRun=Sun May 31 20:57:10 BRT 2020 initialExpiration=null intervalDuration(in milli sec)=0 nextExpiration=Sun May 31 20:58:54 BRT 2020 timerState=IN_TIMEOUT info=null] ScheduleExpression [second=0/1;minute=*;hour=*;dayOfMonth=*;month=*;dayOfWeek=*;year=*;timezoneID=null;start=null;end=null] is still in progress, skipping this overlapping scheduled execution at: Sun May 31 20:58:54 BRT 2020.
> {code}
--
This message was sent by Atlassian Jira
(v7.13.8#713008)
5 years, 3 months
[JBoss JIRA] (WFLY-13542) Container does not enforce bean-managed concurrency for timeout methods
by Fábio Silva (Jira)
Fábio Silva created WFLY-13542:
----------------------------------
Summary: Container does not enforce bean-managed concurrency for timeout methods
Key: WFLY-13542
URL: https://issues.redhat.com/browse/WFLY-13542
Project: WildFly
Issue Type: Bug
Components: EJB
Affects Versions: 19.1.0.Final
Reporter: Fábio Silva
Assignee: Cheng Fang
Bean-managed concurrency for @Singleton EJBs is not enforced for timeout methods annotated with @Schedule. When a timeout is fired while the previous one is still running, the timeout method is not called. Instead, WildFly logs a warning like the following:
{code:java}
20:58:54,000 WARN [org.jboss.as.ejb3.timer] (EJB default - 2) WFLYEJB0043: A previous execution of timer [id=aa716284-ef7b-4bb3-a356-a8ca187255c4 timedObjectId=myweb.myweb.MySingleton auto-timer?:true persistent?:false timerService=org.jboss.as.ejb3.timerservice.TimerServiceImpl@303bd2d5 previousRun=Sun May 31 20:57:10 BRT 2020 initialExpiration=null intervalDuration(in milli sec)=0 nextExpiration=Sun May 31 20:58:54 BRT 2020 timerState=IN_TIMEOUT info=null] ScheduleExpression [second=0/1;minute=*;hour=*;dayOfMonth=*;month=*;dayOfWeek=*;year=*;timezoneID=null;start=null;end=null] is still in progress, skipping this overlapping scheduled execution at: Sun May 31 20:58:54 BRT 2020.
{code}
--
This message was sent by Atlassian Jira
(v7.13.8#713008)
5 years, 3 months