Copilot commented on code in PR #7116:
URL: https://github.com/apache/incubator-kie/pull/7116#discussion_r4028168612


##########
drools-test-coverage/test-compiler-integration/src/test/java/org/drools/compiler/integrationtests/ExistsWithNotSubnetworkCrossPackageTest.java:
##########
@@ -0,0 +1,310 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.drools.compiler.integrationtests;
+
+import java.util.ArrayList;
+import java.util.List;

Review Comment:
   Unused Java imports (`ArrayList`, `List`) in this new test class can cause 
build failures under Checkstyle/Spotless configurations. Remove the unused 
imports to keep the test module clean and avoid CI lint failures.



##########
drools-core/src/main/java/org/drools/core/reteoo/SegmentMemory.java:
##########
@@ -862,14 +862,24 @@ public void splitEagerProtos(boolean proto1WasEager, 
SegmentPrototype other, Pat
                     newEager[newEager.length - 1] = other; // I don't think 
order matters, so just add to the end
                     endNode.setEagerSegmentPrototypes(newEager);
                 } else if (other.requiresEager()) {
-                    // proto2 is no longer eager, find proto1 and swap proto1 
with proto2
+                    // proto1 is no longer eager, find proto1 and swap proto1 
with proto2
                     for (int i = 0; i < eager.length; i++) {
                         if (eager[i] == this) {
                             eager[i] = other;
                             break;
                         }
                     }
                 } // else if ( requiresEager() && !proto2.requiresEager()) do 
nothing as proto1 already in the array
+            } else if (other.requiresEager()) {
+                // proto1 was not eager, but the split produced an eager 
proto2.
+                // This happens when proto1 contained both a NotNode and a 
JoinNode (suppressing the
+                // eager requirement), and the split removed the JoinNode from 
proto2's portion.
+                // proto2 must be added to the endNode's eager list so it gets 
eagerly initialised.
+                SegmentPrototype[] eager = endNode.getEagerSegmentPrototypes();
+                SegmentPrototype[] newEager = new 
SegmentPrototype[eager.length + 1];
+                System.arraycopy(eager, 0, newEager, 0, eager.length);
+                newEager[newEager.length - 1] = other;
+                endNode.setEagerSegmentPrototypes(newEager);

Review Comment:
   This branch always appends `other` to `endNode`’s eager list, which can 
introduce duplicate entries if `splitEagerProtos(false, sameOther, 
sameEndNode)` is reached more than once during incremental builds/splits. 
Consider checking whether `other` is already present in `eager` before 
appending to prevent duplicates and redundant eager initialization work.



##########
drools-test-coverage/test-compiler-integration/src/test/java/org/drools/compiler/integrationtests/ExistsWithNotSubnetworkCrossPackageTest.java:
##########
@@ -0,0 +1,310 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.drools.compiler.integrationtests;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.stream.Stream;
+
+import org.drools.testcoverage.common.util.KieBaseTestConfiguration;
+import org.drools.testcoverage.common.util.KieBaseUtil;
+import org.drools.testcoverage.common.util.TestParametersUtil2;
+import org.junit.jupiter.params.ParameterizedTest;
+import org.junit.jupiter.params.provider.MethodSource;
+import org.kie.api.KieBase;
+import org.kie.api.definition.type.FactType;
+import org.kie.api.runtime.KieSession;
+
+import static org.assertj.core.api.Assertions.assertThat;
+
+/**
+ * Regression test for: exists ( A() and not B() ) rule stops firing when a
+ * sibling rule in a different package shares the leading CE inside its own
+ * exists.
+ *
+ * Reproducer for https://github.com/apache/incubator-kie/issues/7109
+ * (works on 9.44.0.Final, broken on 10.0.0 – 10.2.0)

Review Comment:
   The PR metadata says this change closes issue #7115, but the new test class 
Javadoc references #7109. To avoid confusion when tracing regressions, update 
the Javadoc to reference #7115 (and optionally mention #7109 as related if 
needed).



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to