This is an automated email from the ASF dual-hosted git repository. clebertsuconic pushed a commit to branch main in repository https://gitbox.apache.org/repos/asf/activemq-artemis.git
commit df6f8be66925ddb609aab297c021c467037b6bb3 Author: Clebert Suconic <[email protected]> AuthorDate: Wed Jan 8 12:05:27 2025 -0500 ARTEMIS-5232 Removing SharedEventLoopGroupTest This test does not make sense much sense. The barrier does not seem to always work It is sleeping for 11 seconds for no reason. I didn't want to accept it when it was committed in the first place so i'm removing it --- .../impl/netty/SharedEventLoopGroupTest.java | 91 ---------------------- 1 file changed, 91 deletions(-) diff --git a/artemis-core-client/src/test/java/org/apache/activemq/artemis/core/remoting/impl/netty/SharedEventLoopGroupTest.java b/artemis-core-client/src/test/java/org/apache/activemq/artemis/core/remoting/impl/netty/SharedEventLoopGroupTest.java deleted file mode 100644 index 1fb467bc65..0000000000 --- a/artemis-core-client/src/test/java/org/apache/activemq/artemis/core/remoting/impl/netty/SharedEventLoopGroupTest.java +++ /dev/null @@ -1,91 +0,0 @@ -/* - * 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.apache.activemq.artemis.core.remoting.impl.netty; - -import static org.junit.jupiter.api.Assertions.assertFalse; -import static org.junit.jupiter.api.Assertions.assertTrue; - -import java.util.concurrent.BrokenBarrierException; -import java.util.concurrent.CyclicBarrier; -import java.util.concurrent.atomic.AtomicReference; - -import io.netty.channel.EventLoop; -import io.netty.channel.nio.NioEventLoopGroup; -import org.junit.jupiter.api.Test; - -public class SharedEventLoopGroupTest { - @Test - public void testSharedEventLoopGroupCreateOnShutdown() throws InterruptedException { - final CustomNioEventLoopGroup customNioEventLoopGroup = new CustomNioEventLoopGroup(); - final CyclicBarrier barrier = new CyclicBarrier(2); - - AtomicReference<SharedEventLoopGroup> sharedEventLoopGroup1 = new AtomicReference<>(); - Thread t1 = new Thread(() -> { - sharedEventLoopGroup1.set(SharedEventLoopGroup.getInstance(threadFactory -> customNioEventLoopGroup)); - customNioEventLoopGroup.setCyclicBarrier(barrier); - sharedEventLoopGroup1.get().shutdownGracefully(); - customNioEventLoopGroup.setCyclicBarrier(null); - }); - t1.start(); - - AtomicReference<SharedEventLoopGroup> sharedEventLoopGroup2 = new AtomicReference<>(); - Thread t2 = new Thread(() -> { - try { - barrier.await(); - sharedEventLoopGroup2.set(SharedEventLoopGroup.getInstance(threadFactory -> new NioEventLoopGroup(2, threadFactory))); - } catch (InterruptedException e) { - e.printStackTrace(); - } catch (BrokenBarrierException e) { - e.printStackTrace(); - } - }); - t2.start(); - - t1.join(); - t2.join(); - assertTrue(sharedEventLoopGroup1.get() == sharedEventLoopGroup2.get()); - - Thread.sleep(11000); - assertFalse(sharedEventLoopGroup2.get().isShuttingDown()); - } - - private static class CustomNioEventLoopGroup extends NioEventLoopGroup { - private CyclicBarrier barrier; - - public void setCyclicBarrier(CyclicBarrier barrier) { - this.barrier = barrier; - } - - // Here we wait 1sec to imitate the race condition referred by ARTEMIS-2257 - @Override - public EventLoop next() { - if (barrier != null) { - try { - // Wait for thread t2 arriving - barrier.await(); - // Wait until thread t2 calling SharedEventLoopGroup.getInstance() - Thread.sleep(500); - } catch (InterruptedException e) { - e.printStackTrace(); - } catch (BrokenBarrierException e) { - e.printStackTrace(); - } - } - return super.next(); - } - } -} \ No newline at end of file --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected] For further information, visit: https://activemq.apache.org/contact
