ifesdjeen commented on code in PR #3408:
URL: https://github.com/apache/cassandra/pull/3408#discussion_r1669867566


##########
test/simulator/main/org/apache/cassandra/simulator/systems/InterceptorOfGlobalMethods.java:
##########
@@ -383,12 +404,12 @@ public static CountDownLatch newCountDownLatch(int count)
 
         public static Semaphore newSemaphore(int count)
         {
-            return new Standard(count, false);
+            return methods.newSemaphore(count);
         }
 
         public static Semaphore newFairSemaphore(int count)
         {
-            return new Standard(count, true);
+            return methods.newSemaphore(count);

Review Comment:
   Well spotted, thanks!



##########
test/simulator/test/org/apache/cassandra/simulator/test/SimulationTestBase.java:
##########
@@ -229,10 +230,16 @@ public static void 
simulate(IIsolatedExecutor.SerializableRunnable[] runnables,
         InstanceClassLoader classLoader = new InstanceClassLoader(1, 1, 
AbstractCluster.CURRENT_VERSION.classpath,
                                                                   
Thread.currentThread().getContextClassLoader(),
                                                                   
sharedClassPredicate,
-                                                                  new 
InterceptClasses((x) -> () -> 1.0f, (x) -> () -> 1.0f, 
NemesisFieldSelectors.get(), ClassLoader.getSystemClassLoader(), 
sharedClassPredicate.negate())::apply);
+                                                                  new 
InterceptClasses((x) -> () -> 1.0f, (x) -> () -> 1.0f,
+                                                                               
        NemesisFieldSelectors.get(),
+                                                                               
        ClassLoader.getSystemClassLoader(),
+                                                                               
        sharedClassPredicate.negate())::apply);
 
         ThreadGroup tg = new ThreadGroup("test");
-        InterceptorOfGlobalMethods interceptorOfGlobalMethods = new 
InterceptingGlobalMethods(NONE, null, failures, random);
+        InterceptedWait.CaptureSites.Capture capture = new 
InterceptedWait.CaptureSites.Capture(false, false, false);
+        InterceptorOfGlobalMethods interceptorOfGlobalMethods = 
IsolatedExecutor.transferAdhoc((IIsolatedExecutor.SerializableQuadFunction<InterceptedWait.CaptureSites.Capture,
 LongConsumer, Consumer<Throwable>, RandomSource, InterceptorOfGlobalMethods>) 
InterceptingGlobalMethods::new, classLoader)
+                                                                               
 .apply(capture, (ignore) -> {}, failures, random);

Review Comment:
   Essentially, without this, we are not properly intercepting some of the 
things, like a `WaitQueue` and `Semaphore` so they would throw something like 
below. I do not know how previous test worked without this, but by he time I 
uncommented it was already throwing.
   
   ```
   java.lang.NullPointerException: null
        at 
org.apache.cassandra.simulator.systems.InterceptorOfGlobalMethods$Global.ifIntercepted(InterceptorOfGlobalMethods.java:437)
        at 
org.apache.cassandra.simulator.systems.InterceptingWaitQueue.register(InterceptingWaitQueue.java:52)
        at 
org.apache.cassandra.journal.Journal.awaitAvailableSegment(Journal.java:468)
        at org.apache.cassandra.journal.Journal.advanceSegment(Journal.java:454)
        at org.apache.cassandra.journal.Journal.start(Journal.java:157)
        at 
org.apache.cassandra.simulator.test.AccordJournalSimulationTest.check(AccordJournalSimulationTest.java:100)
        at 
org.apache.cassandra.simulator.test.AccordJournalSimulationTest.lambda$simpleRWTest$81c80a4a$2(AccordJournalSimulationTest.java:95)
        at 
org.apache.cassandra.simulator.systems.InterceptedExecution$InterceptedThreadStart.run(InterceptedExecution.java:216)
        at 
io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)
        at java.base/java.lang.Thread.run(Thread.java:829)
   ```
   
   ```
   java.lang.NullPointerException: null
        at 
org.apache.cassandra.simulator.systems.InterceptorOfGlobalMethods$Global.ifIntercepted(InterceptorOfGlobalMethods.java:437)
        at 
org.apache.cassandra.simulator.systems.InterceptingAwaitable$InterceptingCondition.maybeIntercept(InterceptingAwaitable.java:137)
        at 
org.apache.cassandra.simulator.systems.InterceptingAwaitable.awaitUninterruptibly(InterceptingAwaitable.java:97)
        at 
org.apache.cassandra.simulator.test.TrivialSimulationTest.lambda$semaphoreTest$81c80a4a$1(TrivialSimulationTest.java:119)
        at 
org.apache.cassandra.simulator.systems.InterceptedExecution$InterceptedThreadStart.run(InterceptedExecution.java:216)
   ```



-- 
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