ignite-3727 minor
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/e4b44a81 Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/e4b44a81 Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/e4b44a81 Branch: refs/heads/ignite-3727-2 Commit: e4b44a811e8d3145023252d76155deb286ed2d1c Parents: 9cdc754 Author: sboikov <[email protected]> Authored: Mon Sep 12 23:23:07 2016 +0300 Committer: sboikov <[email protected]> Committed: Mon Sep 12 23:23:07 2016 +0300 ---------------------------------------------------------------------- .../managers/communication/GridIoManager.java | 9 +-- .../ignite/messaging/GridMessagingSelfTest.java | 4 + .../messaging/IgniteMessagingSendAsyncTest.java | 78 +++++++++----------- 3 files changed, 41 insertions(+), 50 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ignite/blob/e4b44a81/modules/core/src/main/java/org/apache/ignite/internal/managers/communication/GridIoManager.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/managers/communication/GridIoManager.java b/modules/core/src/main/java/org/apache/ignite/internal/managers/communication/GridIoManager.java index 6f5421e..3d9238a 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/managers/communication/GridIoManager.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/managers/communication/GridIoManager.java @@ -1782,7 +1782,7 @@ public class GridIoManager extends GridManagerAdapter<CommunicationSpi<Serializa GridMessageListener lsnrs; - for (; ; ) { + for (;;) { lsnrs = listenerPutIfAbsent0(topic, lsnr); if (lsnrs == null) { @@ -1895,7 +1895,7 @@ public class GridIoManager extends GridManagerAdapter<CommunicationSpi<Serializa msgSets = map.values(); } else { - for (; ; ) { + for (;;) { GridMessageListener lsnrs = listenerGet0(topic); // If removing listener before subscription happened. @@ -2131,7 +2131,7 @@ public class GridIoManager extends GridManagerAdapter<CommunicationSpi<Serializa /** * @param l Listener. * @return {@code true} if listener was added. Add can fail if this instance is empty and is about to be removed - * from map. + * from map. */ synchronized boolean add(GridMessageListener l) { GridMessageListener[] arr0 = arr; @@ -2173,8 +2173,7 @@ public class GridIoManager extends GridManagerAdapter<CommunicationSpi<Serializa } /** {@inheritDoc} */ - @SuppressWarnings({ - "SynchronizationOnLocalVariableOrMethodParameter", "ConstantConditions", + @SuppressWarnings({"SynchronizationOnLocalVariableOrMethodParameter", "ConstantConditions", "OverlyStrongTypeCast"}) @Override public void onMessage(UUID nodeId, Object msg) { if (!(msg instanceof GridIoUserMessage)) { http://git-wip-us.apache.org/repos/asf/ignite/blob/e4b44a81/modules/core/src/test/java/org/apache/ignite/messaging/GridMessagingSelfTest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/apache/ignite/messaging/GridMessagingSelfTest.java b/modules/core/src/test/java/org/apache/ignite/messaging/GridMessagingSelfTest.java index c6ce0dc..07f9fe4 100644 --- a/modules/core/src/test/java/org/apache/ignite/messaging/GridMessagingSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/messaging/GridMessagingSelfTest.java @@ -1066,6 +1066,8 @@ public class GridMessagingSelfTest extends GridCommonAbstractTest implements Ser Assert.assertNotNull(starFut); + U.sleep(500); + Assert.assertFalse(starFut.isDone()); discoSpi.stopBlock(); @@ -1108,6 +1110,8 @@ public class GridMessagingSelfTest extends GridCommonAbstractTest implements Ser } }, IllegalStateException.class, null); + U.sleep(500); + Assert.assertFalse(stopFut.isDone()); discoSpi.stopBlock(); http://git-wip-us.apache.org/repos/asf/ignite/blob/e4b44a81/modules/core/src/test/java/org/apache/ignite/messaging/IgniteMessagingSendAsyncTest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/apache/ignite/messaging/IgniteMessagingSendAsyncTest.java b/modules/core/src/test/java/org/apache/ignite/messaging/IgniteMessagingSendAsyncTest.java index 91ac6e2..0187579 100644 --- a/modules/core/src/test/java/org/apache/ignite/messaging/IgniteMessagingSendAsyncTest.java +++ b/modules/core/src/test/java/org/apache/ignite/messaging/IgniteMessagingSendAsyncTest.java @@ -1,19 +1,20 @@ /* -* 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. -*/ + * 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.ignite.messaging; import org.apache.ignite.Ignite; @@ -27,7 +28,7 @@ import java.util.concurrent.CountDownLatch; import java.util.concurrent.atomic.AtomicReference; /** - * Created by dgovorukhin on 09.09.2016. + * */ public class IgniteMessagingSendAsyncTest extends GridCommonAbstractTest { /** @@ -45,8 +46,7 @@ public class IgniteMessagingSendAsyncTest extends GridCommonAbstractTest { /** * {@inheritDoc} */ - @Override - protected void beforeTest() throws Exception { + @Override protected void beforeTest() throws Exception { super.beforeTest(); ignite1 = startGrid(1); @@ -56,8 +56,7 @@ public class IgniteMessagingSendAsyncTest extends GridCommonAbstractTest { /** * {@inheritDoc} */ - @Override - protected void afterTest() throws Exception { + @Override protected void afterTest() throws Exception { super.afterTest(); stopAllGrids(); @@ -73,13 +72,11 @@ public class IgniteMessagingSendAsyncTest extends GridCommonAbstractTest { final String msgStr = "message"; send(ignite1.message(), msgStr, new ProcedureApply() { - @Override - public void apply(String msg, Thread thread) { + @Override public void apply(String msg, Thread thread) { Assert.assertEquals(Thread.currentThread(), thread); Assert.assertEquals(msgStr, msg); } }); - } /** @@ -92,8 +89,7 @@ public class IgniteMessagingSendAsyncTest extends GridCommonAbstractTest { final String msgStr = "message"; send(ignite1.message().withAsync(), msgStr, new ProcedureApply() { - @Override - public void apply(String msg, Thread thread) { + @Override public void apply(String msg, Thread thread) { Assert.assertTrue(!Thread.currentThread().equals(thread)); Assert.assertEquals(msgStr, msg); } @@ -108,8 +104,7 @@ public class IgniteMessagingSendAsyncTest extends GridCommonAbstractTest { final String msgStr = "message"; sendWith2Node(ignite1.message(), msgStr, new ProcedureApply() { - @Override - public void apply(String msg, Thread thread) { + @Override public void apply(String msg, Thread thread) { Assert.assertEquals(Thread.currentThread(), thread); Assert.assertEquals(msgStr, msg); } @@ -124,8 +119,7 @@ public class IgniteMessagingSendAsyncTest extends GridCommonAbstractTest { final String msgStr = "message"; sendWith2Node(ignite1.message().withAsync(), msgStr, new ProcedureApply() { - @Override - public void apply(String msg, Thread thread) { + @Override public void apply(String msg, Thread thread) { Assert.assertTrue(!Thread.currentThread().equals(thread)); Assert.assertEquals(msgStr, msg); } @@ -137,17 +131,15 @@ public class IgniteMessagingSendAsyncTest extends GridCommonAbstractTest { * @param msgStr Message string. * @param cls Callback for compare result. */ - public void sendWith2Node( - final IgniteMessaging igniteMsg, - final String msgStr, - final ProcedureApply cls + private void sendWith2Node( + final IgniteMessaging igniteMsg, + final String msgStr, + final ProcedureApply cls ) throws Exception { - final CountDownLatch latch = new CountDownLatch(1); ignite2.message().localListen(TOPIC, new IgniteBiPredicate<UUID, String>() { - @Override - public boolean apply(UUID uuid, String msg) { + @Override public boolean apply(UUID uuid, String msg) { Assert.assertEquals(msgStr, msg); latch.countDown(); return false; @@ -159,16 +151,15 @@ public class IgniteMessagingSendAsyncTest extends GridCommonAbstractTest { latch.await(); } - /** * @param igniteMsg Ignite message. * @param msgStr Message string. * @param cls Callback for compare result. */ private void send( - IgniteMessaging igniteMsg, - String msgStr, - ProcedureApply cls + IgniteMessaging igniteMsg, + String msgStr, + ProcedureApply cls ) throws InterruptedException { final CountDownLatch latch = new CountDownLatch(1); @@ -176,8 +167,7 @@ public class IgniteMessagingSendAsyncTest extends GridCommonAbstractTest { final AtomicReference<String> val = new AtomicReference<>(); igniteMsg.localListen(TOPIC, new IgniteBiPredicate<UUID, String>() { - @Override - public boolean apply(UUID uuid, String msgStr) { + @Override public boolean apply(UUID uuid, String msgStr) { thread.set(Thread.currentThread()); val.set(msgStr); latch.countDown(); @@ -193,15 +183,13 @@ public class IgniteMessagingSendAsyncTest extends GridCommonAbstractTest { } /** - * only for this test procedure + * Only for this test procedure. */ private interface ProcedureApply { - /** * @param val Value. * @param thread Thread. */ void apply(String val, Thread thread); } - }
