[geode] branch develop updated (d1e003c -> c068979)
This is an automated email from the ASF dual-hosted git repository. udo pushed a change to branch develop in repository https://gitbox.apache.org/repos/asf/geode.git. from d1e003c GEODE-8603: fix StressNew for support branches (#5717) add c068979 GEODE-8683: Honor maximum-time-between-pings in gateway receiver (#5701) No new revisions were added by this update. Summary of changes: .../apache/geode/internal/cache/tier/Acceptor.java | 2 + .../internal/cache/tier/sockets/AcceptorImpl.java | 7 +++ .../cache/tier/sockets/ClientHealthMonitor.java| 33 +++--- .../cache/tier/sockets/ServerConnection.java | 2 +- .../tier/sockets/ClientHealthMonitorTest.java | 4 ++ .../geode/internal/cache/wan/WANTestBase.java | 34 +- .../wan/parallel/ParallelWANStatsDUnitTest.java| 52 ++ 7 files changed, 126 insertions(+), 8 deletions(-)
[geode] branch support/1.12 updated: * GEODE-8652: NioSslEngine.close() Bypasses Locks (#5712)
This is an automated email from the ASF dual-hosted git repository. burcham pushed a commit to branch support/1.12 in repository https://gitbox.apache.org/repos/asf/geode.git The following commit(s) were added to refs/heads/support/1.12 by this push: new 68b8559 * GEODE-8652: NioSslEngine.close() Bypasses Locks (#5712) 68b8559 is described below commit 68b8559ef149acaee9b4f7846683d28cefff76f8 Author: Bill Burcham AuthorDate: Thu Nov 5 17:30:29 2020 -0800 * GEODE-8652: NioSslEngine.close() Bypasses Locks (#5712) - NioSslEngine.close() proceeds even if readers (or writers) are operating on its ByteBuffers, allowing Connection.close() to close its socket and proceed. - NioSslEngine.close() needed a lock only on the output buffer, so we split what was a single lock into two. Also instead of using synchronized we use a ReentrantLock so we can call tryLock() and time out if needed in NioSslEngine.close(). - Since readers/writers may hold locks on these input/output buffers when NioSslEngine.close() is called a reference count is maintained and the buffers are returned to the pool only when the last user is done. - To manage the locking and reference counting a new AutoCloseable ByteBufferSharing interface is introduced with a trivial implementation: ByteBufferSharingNoOp and a real implementation: ByteBufferSharingImpl. - Added a new unit test, and a new concurrency test for ByteBufferSharingImpl: both ensure that ByteBuffers are returned to the pool exactly once. Added a new DUnit test for the interaction between ByteBufferSharingImpl and NioSslEngine and Connection. Co-authored-by: Bill Burcham Co-authored-by: Darrel Schneider Co-authored-by: Ernie Burghardt Co-authored-by: Dan Smith (cherry picked from commit af267c005a63317cbb8528cdb38eccf6a8747818) --- .../tcp/ConnectionCloseSSLTLSDUnitTest.java| 235 +++ .../org/apache/geode/internal/tcp/server.keystore | Bin 0 -> 1256 bytes ...LSocketHostNameVerificationIntegrationTest.java | 4 +- .../internal/net/SSLSocketIntegrationTest.java | 57 ++- .../apache/geode/codeAnalysis/excludedClasses.txt | 1 + .../geode/internal/net/ByteBufferSharing.java | 55 +++ .../geode/internal/net/ByteBufferSharingImpl.java | 168 .../geode/internal/net/ByteBufferSharingNoOp.java | 52 +++ .../org/apache/geode/internal/net/NioFilter.java | 69 ++-- .../apache/geode/internal/net/NioPlainEngine.java | 27 +- .../apache/geode/internal/net/NioSslEngine.java| 369 - .../org/apache/geode/internal/tcp/Connection.java | 34 +- .../org/apache/geode/internal/tcp/MsgReader.java | 15 +- .../internal/net/ByteBufferConcurrencyTest.java| 165 .../internal/net/ByteBufferSharingImplTest.java| 179 + .../geode/internal/net/NioPlainEngineTest.java | 47 ++- .../geode/internal/net/NioSslEngineTest.java | 440 +++-- 17 files changed, 1428 insertions(+), 489 deletions(-) diff --git a/geode-core/src/distributedTest/java/org/apache/geode/internal/tcp/ConnectionCloseSSLTLSDUnitTest.java b/geode-core/src/distributedTest/java/org/apache/geode/internal/tcp/ConnectionCloseSSLTLSDUnitTest.java new file mode 100644 index 000..586cd53 --- /dev/null +++ b/geode-core/src/distributedTest/java/org/apache/geode/internal/tcp/ConnectionCloseSSLTLSDUnitTest.java @@ -0,0 +1,235 @@ +/* + * 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.geode.internal.tcp; + +import static java.util.concurrent.TimeUnit.MINUTES; +import static org.apache.geode.distributed.ConfigurationProperties.CONSERVE_SOCKETS; +import static org.apache.geode.distributed.ConfigurationProperties.ENABLE_CLUSTER_CONFIGURATION; +import static org.apache.geode.distributed.ConfigurationProperties.LOCATORS; +import static org.apache.geode.distributed.ConfigurationProperties.NAME; +import static org.apache.geode.distributed.ConfigurationProperties.SOCKET_BUFFER_SIZE; +import static org.apache.geode.distributed.ConfigurationProperties.SOCKET_LEASE_TIME; +import static
[geode] branch support/1.12 updated: * GEODE-8652: NioSslEngine.close() Bypasses Locks (#5712)
This is an automated email from the ASF dual-hosted git repository. burcham pushed a commit to branch support/1.12 in repository https://gitbox.apache.org/repos/asf/geode.git The following commit(s) were added to refs/heads/support/1.12 by this push: new 68b8559 * GEODE-8652: NioSslEngine.close() Bypasses Locks (#5712) 68b8559 is described below commit 68b8559ef149acaee9b4f7846683d28cefff76f8 Author: Bill Burcham AuthorDate: Thu Nov 5 17:30:29 2020 -0800 * GEODE-8652: NioSslEngine.close() Bypasses Locks (#5712) - NioSslEngine.close() proceeds even if readers (or writers) are operating on its ByteBuffers, allowing Connection.close() to close its socket and proceed. - NioSslEngine.close() needed a lock only on the output buffer, so we split what was a single lock into two. Also instead of using synchronized we use a ReentrantLock so we can call tryLock() and time out if needed in NioSslEngine.close(). - Since readers/writers may hold locks on these input/output buffers when NioSslEngine.close() is called a reference count is maintained and the buffers are returned to the pool only when the last user is done. - To manage the locking and reference counting a new AutoCloseable ByteBufferSharing interface is introduced with a trivial implementation: ByteBufferSharingNoOp and a real implementation: ByteBufferSharingImpl. - Added a new unit test, and a new concurrency test for ByteBufferSharingImpl: both ensure that ByteBuffers are returned to the pool exactly once. Added a new DUnit test for the interaction between ByteBufferSharingImpl and NioSslEngine and Connection. Co-authored-by: Bill Burcham Co-authored-by: Darrel Schneider Co-authored-by: Ernie Burghardt Co-authored-by: Dan Smith (cherry picked from commit af267c005a63317cbb8528cdb38eccf6a8747818) --- .../tcp/ConnectionCloseSSLTLSDUnitTest.java| 235 +++ .../org/apache/geode/internal/tcp/server.keystore | Bin 0 -> 1256 bytes ...LSocketHostNameVerificationIntegrationTest.java | 4 +- .../internal/net/SSLSocketIntegrationTest.java | 57 ++- .../apache/geode/codeAnalysis/excludedClasses.txt | 1 + .../geode/internal/net/ByteBufferSharing.java | 55 +++ .../geode/internal/net/ByteBufferSharingImpl.java | 168 .../geode/internal/net/ByteBufferSharingNoOp.java | 52 +++ .../org/apache/geode/internal/net/NioFilter.java | 69 ++-- .../apache/geode/internal/net/NioPlainEngine.java | 27 +- .../apache/geode/internal/net/NioSslEngine.java| 369 - .../org/apache/geode/internal/tcp/Connection.java | 34 +- .../org/apache/geode/internal/tcp/MsgReader.java | 15 +- .../internal/net/ByteBufferConcurrencyTest.java| 165 .../internal/net/ByteBufferSharingImplTest.java| 179 + .../geode/internal/net/NioPlainEngineTest.java | 47 ++- .../geode/internal/net/NioSslEngineTest.java | 440 +++-- 17 files changed, 1428 insertions(+), 489 deletions(-) diff --git a/geode-core/src/distributedTest/java/org/apache/geode/internal/tcp/ConnectionCloseSSLTLSDUnitTest.java b/geode-core/src/distributedTest/java/org/apache/geode/internal/tcp/ConnectionCloseSSLTLSDUnitTest.java new file mode 100644 index 000..586cd53 --- /dev/null +++ b/geode-core/src/distributedTest/java/org/apache/geode/internal/tcp/ConnectionCloseSSLTLSDUnitTest.java @@ -0,0 +1,235 @@ +/* + * 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.geode.internal.tcp; + +import static java.util.concurrent.TimeUnit.MINUTES; +import static org.apache.geode.distributed.ConfigurationProperties.CONSERVE_SOCKETS; +import static org.apache.geode.distributed.ConfigurationProperties.ENABLE_CLUSTER_CONFIGURATION; +import static org.apache.geode.distributed.ConfigurationProperties.LOCATORS; +import static org.apache.geode.distributed.ConfigurationProperties.NAME; +import static org.apache.geode.distributed.ConfigurationProperties.SOCKET_BUFFER_SIZE; +import static org.apache.geode.distributed.ConfigurationProperties.SOCKET_LEASE_TIME; +import static
[geode-native] branch develop updated: GEODE-8688: Fix flaky C++ native client integration tests (#686)
This is an automated email from the ASF dual-hosted git repository. bbender pushed a commit to branch develop in repository https://gitbox.apache.org/repos/asf/geode-native.git The following commit(s) were added to refs/heads/develop by this push: new 5c7d47d GEODE-8688: Fix flaky C++ native client integration tests (#686) 5c7d47d is described below commit 5c7d47d34c2b8a53874ec6f53e66c2290fd0427c Author: Alberto Gomez AuthorDate: Fri Nov 6 22:52:10 2020 +0100 GEODE-8688: Fix flaky C++ native client integration tests (#686) * GEODE-8688: Fix flaky C++ native client integration tests The following integration test cases under integration/test (new integration tests) ar flaky (do not fail normally when run locally but fail very often when run in CI). - PartitionRegionOpsTest.getPartitionedRegionWithRedundancyServerGoesDownSingleHop - PartitionRegionOpsTest.putPartitionedRegionWithRedundancyServerGoesDownSingleHop There were two reasons that can make them fail. One of them is that sometimes the connections to the server have expired before the server is restarted and therefore, when traffic is sent to the restarted server, no errors are found. To fix this, the pool configuration for the test client has been changed so that connections do not expire. The other reason is that sometimes the error in the connection is found by the ping thread that is invoking the ThinClientPoolDM::sendRequestToEP() method and in this method, when the IO error or TIMEOUT error are encountered, the endpoint is not removed from the metadata (by means of the removeBucketServerLocation method). The code has been updated to remove the metadata also in this case. With these two changes, the test cases are not flaky anymore. --- .../integration/test/PartitionRegionOpsTest.cpp| 8 +++--- cppcache/src/ThinClientPoolDM.cpp | 30 +++--- cppcache/src/ThinClientPoolDM.hpp | 2 ++ 3 files changed, 22 insertions(+), 18 deletions(-) diff --git a/cppcache/integration/test/PartitionRegionOpsTest.cpp b/cppcache/integration/test/PartitionRegionOpsTest.cpp index 27fea22..29989d7 100644 --- a/cppcache/integration/test/PartitionRegionOpsTest.cpp +++ b/cppcache/integration/test/PartitionRegionOpsTest.cpp @@ -74,6 +74,8 @@ std::shared_ptr createPool(Cluster& cluster, Cache& cache, auto poolFactory = cache.getPoolManager().createFactory(); cluster.applyLocators(poolFactory); poolFactory.setPRSingleHopEnabled(singleHop); + poolFactory.setLoadConditioningInterval(std::chrono::milliseconds::zero()); + poolFactory.setIdleTimeout(std::chrono::milliseconds::zero()); return poolFactory.create("default"); } @@ -144,9 +146,9 @@ void verifyMetadataWasRemovedAtFirstError() { } } } - ASSERT_TRUE((timeoutErrors == metadataRemovedDueToTimeout) && - (ioErrors == metadataRemovedDueToIoErr) && - (metadataRemovedDueToTimeout != metadataRemovedDueToIoErr)); + EXPECT_EQ(timeoutErrors, metadataRemovedDueToTimeout); + EXPECT_EQ(ioErrors, metadataRemovedDueToIoErr); + EXPECT_NE(metadataRemovedDueToTimeout, metadataRemovedDueToIoErr); } void putPartitionedRegionWithRedundancyServerGoesDown(bool singleHop) { diff --git a/cppcache/src/ThinClientPoolDM.cpp b/cppcache/src/ThinClientPoolDM.cpp index dcc816b..95c9867 100644 --- a/cppcache/src/ThinClientPoolDM.cpp +++ b/cppcache/src/ThinClientPoolDM.cpp @@ -1426,14 +1426,7 @@ GfErrType ThinClientPoolDM::sendSyncRequest( GF_SAFE_DELETE_CON(conn); } excludeServers.insert(ServerLocation(ep->name())); - if ((error == GF_IOERR || error == GF_TIMEOUT) && - m_clientMetadataService) { -auto sl = std::make_shared(ep->name()); -LOGINFO("Removing bucketServerLocation %s due to %s", -sl->toString().c_str(), -(error == GF_IOERR ? "GF_IOERR" : "GF_TIMEOUT")); -m_clientMetadataService->removeBucketServerLocation(sl); - } + removeEPFromMetadataIfError(error, ep); } } else { return error; // server exception while sending credential message to @@ -1533,6 +1526,17 @@ GfErrType ThinClientPoolDM::sendSyncRequest( return error; } +void ThinClientPoolDM::removeEPFromMetadataIfError(const GfErrType& error, + const TcrEndpoint* ep) { + if ((error == GF_IOERR || error == GF_TIMEOUT) && (m_clientMetadataService)) { +auto sl = std::make_shared(ep->name()); +LOGINFO("Removing bucketServerLocation %s due to %s", +sl->toString().c_str(), +(error == GF_IOERR ? "GF_IOERR" : "GF_TIMEOUT")); +m_clientMetadataService->removeBucketServerLocation(sl); + } +} + void ThinClientPoolDM::removeEPConnections(int numConn,
[geode-native] branch develop updated: GEODE-8688: Fix flaky C++ native client integration tests (#686)
This is an automated email from the ASF dual-hosted git repository. bbender pushed a commit to branch develop in repository https://gitbox.apache.org/repos/asf/geode-native.git The following commit(s) were added to refs/heads/develop by this push: new 5c7d47d GEODE-8688: Fix flaky C++ native client integration tests (#686) 5c7d47d is described below commit 5c7d47d34c2b8a53874ec6f53e66c2290fd0427c Author: Alberto Gomez AuthorDate: Fri Nov 6 22:52:10 2020 +0100 GEODE-8688: Fix flaky C++ native client integration tests (#686) * GEODE-8688: Fix flaky C++ native client integration tests The following integration test cases under integration/test (new integration tests) ar flaky (do not fail normally when run locally but fail very often when run in CI). - PartitionRegionOpsTest.getPartitionedRegionWithRedundancyServerGoesDownSingleHop - PartitionRegionOpsTest.putPartitionedRegionWithRedundancyServerGoesDownSingleHop There were two reasons that can make them fail. One of them is that sometimes the connections to the server have expired before the server is restarted and therefore, when traffic is sent to the restarted server, no errors are found. To fix this, the pool configuration for the test client has been changed so that connections do not expire. The other reason is that sometimes the error in the connection is found by the ping thread that is invoking the ThinClientPoolDM::sendRequestToEP() method and in this method, when the IO error or TIMEOUT error are encountered, the endpoint is not removed from the metadata (by means of the removeBucketServerLocation method). The code has been updated to remove the metadata also in this case. With these two changes, the test cases are not flaky anymore. --- .../integration/test/PartitionRegionOpsTest.cpp| 8 +++--- cppcache/src/ThinClientPoolDM.cpp | 30 +++--- cppcache/src/ThinClientPoolDM.hpp | 2 ++ 3 files changed, 22 insertions(+), 18 deletions(-) diff --git a/cppcache/integration/test/PartitionRegionOpsTest.cpp b/cppcache/integration/test/PartitionRegionOpsTest.cpp index 27fea22..29989d7 100644 --- a/cppcache/integration/test/PartitionRegionOpsTest.cpp +++ b/cppcache/integration/test/PartitionRegionOpsTest.cpp @@ -74,6 +74,8 @@ std::shared_ptr createPool(Cluster& cluster, Cache& cache, auto poolFactory = cache.getPoolManager().createFactory(); cluster.applyLocators(poolFactory); poolFactory.setPRSingleHopEnabled(singleHop); + poolFactory.setLoadConditioningInterval(std::chrono::milliseconds::zero()); + poolFactory.setIdleTimeout(std::chrono::milliseconds::zero()); return poolFactory.create("default"); } @@ -144,9 +146,9 @@ void verifyMetadataWasRemovedAtFirstError() { } } } - ASSERT_TRUE((timeoutErrors == metadataRemovedDueToTimeout) && - (ioErrors == metadataRemovedDueToIoErr) && - (metadataRemovedDueToTimeout != metadataRemovedDueToIoErr)); + EXPECT_EQ(timeoutErrors, metadataRemovedDueToTimeout); + EXPECT_EQ(ioErrors, metadataRemovedDueToIoErr); + EXPECT_NE(metadataRemovedDueToTimeout, metadataRemovedDueToIoErr); } void putPartitionedRegionWithRedundancyServerGoesDown(bool singleHop) { diff --git a/cppcache/src/ThinClientPoolDM.cpp b/cppcache/src/ThinClientPoolDM.cpp index dcc816b..95c9867 100644 --- a/cppcache/src/ThinClientPoolDM.cpp +++ b/cppcache/src/ThinClientPoolDM.cpp @@ -1426,14 +1426,7 @@ GfErrType ThinClientPoolDM::sendSyncRequest( GF_SAFE_DELETE_CON(conn); } excludeServers.insert(ServerLocation(ep->name())); - if ((error == GF_IOERR || error == GF_TIMEOUT) && - m_clientMetadataService) { -auto sl = std::make_shared(ep->name()); -LOGINFO("Removing bucketServerLocation %s due to %s", -sl->toString().c_str(), -(error == GF_IOERR ? "GF_IOERR" : "GF_TIMEOUT")); -m_clientMetadataService->removeBucketServerLocation(sl); - } + removeEPFromMetadataIfError(error, ep); } } else { return error; // server exception while sending credential message to @@ -1533,6 +1526,17 @@ GfErrType ThinClientPoolDM::sendSyncRequest( return error; } +void ThinClientPoolDM::removeEPFromMetadataIfError(const GfErrType& error, + const TcrEndpoint* ep) { + if ((error == GF_IOERR || error == GF_TIMEOUT) && (m_clientMetadataService)) { +auto sl = std::make_shared(ep->name()); +LOGINFO("Removing bucketServerLocation %s due to %s", +sl->toString().c_str(), +(error == GF_IOERR ? "GF_IOERR" : "GF_TIMEOUT")); +m_clientMetadataService->removeBucketServerLocation(sl); + } +} + void ThinClientPoolDM::removeEPConnections(int numConn,
[geode] 01/03: GEODE-8136: Move UncheckedUtils to geode-common (#5123)
This is an automated email from the ASF dual-hosted git repository. burcham pushed a commit to branch support/1.13 in repository https://gitbox.apache.org/repos/asf/geode.git commit d70cd816ff183033b059198c9db8302c76a7af65 Author: Kirk Lund AuthorDate: Tue May 26 10:24:44 2020 -0700 GEODE-8136: Move UncheckedUtils to geode-common (#5123) Create UncheckedUtilsTest to unit test UncheckedUtils. Extract FunctionExecution methods to new TypedFunctionService in geode-core. --- .../geode/util/internal}/UncheckedUtils.java | 19 --- .../geode/util/internal/UncheckedUtilsTest.java| 60 ++ .../cache/PartitionedRegionSingleHopDUnitTest.java | 14 ++--- ...istributedRegionFunctionExecutionDUnitTest.java | 59 +++-- ...oningWithColocationAndPersistenceDUnitTest.java | 12 ++--- .../FunctionExecutionOnLonerRegressionTest.java| 27 ++ .../client/internal/ClientMetadataService.java | 4 +- .../geode/internal/cache/GemFireCacheImpl.java | 49 -- .../cache/InternalCacheForClientAccess.java| 6 +-- .../apache/geode/internal/cache/LocalRegion.java | 7 ++- .../util/TypedFunctionService.java}| 20 +--- .../tier/sockets/CacheClientProxyFactory.java | 4 +- .../internal/ClusterAlertMessagingTest.java| 6 +-- .../apache/geode/internal/tcp/TCPConduitTest.java | 4 +- 14 files changed, 151 insertions(+), 140 deletions(-) diff --git a/geode-core/src/main/java/org/apache/geode/internal/cache/util/UncheckedUtils.java b/geode-common/src/main/java/org/apache/geode/util/internal/UncheckedUtils.java similarity index 68% copy from geode-core/src/main/java/org/apache/geode/internal/cache/util/UncheckedUtils.java copy to geode-common/src/main/java/org/apache/geode/util/internal/UncheckedUtils.java index c03e990..61dbd8d 100644 --- a/geode-core/src/main/java/org/apache/geode/internal/cache/util/UncheckedUtils.java +++ b/geode-common/src/main/java/org/apache/geode/util/internal/UncheckedUtils.java @@ -12,18 +12,23 @@ * or implied. See the License for the specific language governing permissions and limitations under * the License. */ -package org.apache.geode.internal.cache.util; - -import org.apache.geode.cache.execute.Execution; +package org.apache.geode.util.internal; +/** + * Utilities for casting and working with unchecked raw types. + */ @SuppressWarnings({"unchecked", "unused"}) public class UncheckedUtils { - public static T cast(Object object) { -return (T) object; + protected UncheckedUtils() { +// do not instantiate } - public static Execution cast(Execution execution) { -return execution; + /** + * Casts an instance of a raw type to a parameterized type. Preference should be given to + * converting all code from using raw types to using parameterized types when possible. + */ + public static T uncheckedCast(Object object) { +return (T) object; } } diff --git a/geode-common/src/test/java/org/apache/geode/util/internal/UncheckedUtilsTest.java b/geode-common/src/test/java/org/apache/geode/util/internal/UncheckedUtilsTest.java new file mode 100644 index 000..7c282b7 --- /dev/null +++ b/geode-common/src/test/java/org/apache/geode/util/internal/UncheckedUtilsTest.java @@ -0,0 +1,60 @@ +/* + * 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.geode.util.internal; + +import static org.apache.geode.util.internal.UncheckedUtils.uncheckedCast; +import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.catchThrowable; + +import java.util.ArrayList; +import java.util.List; + +import org.junit.Test; + +@SuppressWarnings("unchecked") +public class UncheckedUtilsTest { + + @Test + public void uncheckedCast_rawList_empty() { +List rawList = new ArrayList(); + +List value = uncheckedCast(rawList); + +assertThat(value).isSameAs(rawList); + } + + @Test + public void uncheckedCast_rawList_nonEmpty() { +List rawList = new ArrayList(); +rawList.add("1"); +rawList.add("2"); + +List value = uncheckedCast(rawList); + +assertThat(value).isSameAs(rawList); + } + + @Test + public void
[geode] 02/03: GEODE-8540: Create new DistributedBlackboard Rule (#5557)
This is an automated email from the ASF dual-hosted git repository. burcham pushed a commit to branch support/1.13 in repository https://gitbox.apache.org/repos/asf/geode.git commit 8fb7f6c7db9ef2ec0ff8b618a578738e1426d801 Author: Kirk Lund AuthorDate: Wed Sep 30 09:39:30 2020 -0700 GEODE-8540: Create new DistributedBlackboard Rule (#5557) Package up DUnitBlackboard as a JUnit Rule named DistributedBlackboard. --- .../dunit/internal/DUnitBlackboardDUnitTest.java | 75 +++--- .../DistributedBlackboardDistributedTest.java | 297 + .../InternalBlackboard.java => Blackboard.java}| 54 ++-- .../apache/geode/test/dunit/DUnitBlackboard.java | 55 ++-- .../test/dunit/internal/InternalBlackboard.java| 33 ++- .../dunit/internal/InternalBlackboardImpl.java | 59 ++-- .../test/dunit/rules/DistributedBlackboard.java| 138 ++ 7 files changed, 584 insertions(+), 127 deletions(-) diff --git a/geode-dunit/src/distributedTest/java/org/apache/geode/test/dunit/internal/DUnitBlackboardDUnitTest.java b/geode-dunit/src/distributedTest/java/org/apache/geode/test/dunit/internal/DUnitBlackboardDUnitTest.java index ae78247..5e151d7 100755 --- a/geode-dunit/src/distributedTest/java/org/apache/geode/test/dunit/internal/DUnitBlackboardDUnitTest.java +++ b/geode-dunit/src/distributedTest/java/org/apache/geode/test/dunit/internal/DUnitBlackboardDUnitTest.java @@ -14,83 +14,70 @@ */ package org.apache.geode.test.dunit.internal; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNull; -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; +import static java.util.concurrent.TimeUnit.SECONDS; +import static org.apache.geode.test.dunit.VM.getVM; +import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.catchThrowable; -import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeoutException; import org.junit.Test; -import org.apache.geode.test.dunit.Host; import org.apache.geode.test.dunit.VM; - +@SuppressWarnings("serial") public class DUnitBlackboardDUnitTest extends JUnit4DistributedTestCase { + @Test - public void canPassDataBetweenVMs() throws Exception { + public void canPassDataBetweenVMs() { final String MBOX = "myMailbox"; -VM vm0 = Host.getHost(0).getVM(0); -VM vm1 = Host.getHost(0).getVM(1); +VM vm0 = getVM(0); +VM vm1 = getVM(1); vm0.invoke("put data in mailbox", () -> getBlackboard().setMailbox(MBOX, "testing")); -String result = (String) vm1.invoke("get data from mailbox", () -> { - return getBlackboard().getMailbox(MBOX); -}); +String result = vm1.invoke("get data from mailbox", () -> getBlackboard().getMailbox(MBOX)); -assertEquals("testing", result); +assertThat(result).isEqualTo("testing"); } @Test - public void canSignalAnotherVM() throws Exception { + public void canSignalAnotherVM() { final String GATE = "myGate"; -VM vm0 = Host.getHost(0).getVM(0); -VM vm1 = Host.getHost(0).getVM(1); +VM vm0 = getVM(0); +VM vm1 = getVM(1); vm1.invoke("wait on gate not yet signalled", () -> { - assertFalse(getBlackboard().isGateSignaled(GATE)); - try { -getBlackboard().waitForGate(GATE, 1, TimeUnit.SECONDS); - } catch (TimeoutException e) { -// expected -return; - } catch (InterruptedException e) { -fail("unexpected interrupt"); - } - fail("unexpected success"); + assertThat(getBlackboard().isGateSignaled(GATE)).isFalse(); + + Throwable thrown = catchThrowable(() -> { +getBlackboard().waitForGate(GATE, 1, SECONDS); + }); + + assertThat(thrown).isInstanceOf(TimeoutException.class); }); vm0.invoke("signal gate", () -> getBlackboard().signalGate(GATE)); -vm1.invoke("wait on gate not yet signalled", () -> { - try { -getBlackboard().waitForGate(GATE, 1, TimeUnit.SECONDS); - } catch (TimeoutException e) { -fail("unexpected timeout"); - } catch (InterruptedException e) { -fail("unexpected interrupt"); - } - // success expected -}); +vm1.invoke("wait on gate not yet signalled", +() -> getBlackboard().waitForGate(GATE, 1, SECONDS)); } @Test - public void initBlackboardClearsEverything() throws Exception { + public void initBlackboardClearsEverything() { for (int i = 0; i < 100; i++) { getBlackboard().setMailbox("MBOX" + i, "value" + i); - assertEquals("value" + i, getBlackboard().getMailbox("MBOX" + i)); + assertThat((Object) getBlackboard().getMailbox("MBOX" + i)).isEqualTo("value" + i); + getBlackboard().signalGate("GATE" + i); - assertTrue(getBlackboard().isGateSignaled("GATE" + i)); + assertThat(getBlackboard().isGateSignaled("GATE" + i)).isTrue(); } -
[geode] 03/03: * GEODE-8652: NioSslEngine.close() Bypasses Locks (#5712)
This is an automated email from the ASF dual-hosted git repository. burcham pushed a commit to branch support/1.13 in repository https://gitbox.apache.org/repos/asf/geode.git commit 32a8a55df4c0a5b8b1e5cfb746070804cbce5e0a Author: Bill Burcham AuthorDate: Thu Nov 5 17:30:29 2020 -0800 * GEODE-8652: NioSslEngine.close() Bypasses Locks (#5712) - NioSslEngine.close() proceeds even if readers (or writers) are operating on its ByteBuffers, allowing Connection.close() to close its socket and proceed. - NioSslEngine.close() needed a lock only on the output buffer, so we split what was a single lock into two. Also instead of using synchronized we use a ReentrantLock so we can call tryLock() and time out if needed in NioSslEngine.close(). - Since readers/writers may hold locks on these input/output buffers when NioSslEngine.close() is called a reference count is maintained and the buffers are returned to the pool only when the last user is done. - To manage the locking and reference counting a new AutoCloseable ByteBufferSharing interface is introduced with a trivial implementation: ByteBufferSharingNoOp and a real implementation: ByteBufferSharingImpl. - Added a new unit test, and a new concurrency test for ByteBufferSharingImpl: both ensure that ByteBuffers are returned to the pool exactly once. Added a new DUnit test for the interaction between ByteBufferSharingImpl and NioSslEngine and Connection. Co-authored-by: Bill Burcham Co-authored-by: Darrel Schneider Co-authored-by: Ernie Burghardt Co-authored-by: Dan Smith (cherry picked from commit af267c005a63317cbb8528cdb38eccf6a8747818) --- .../tcp/ConnectionCloseSSLTLSDUnitTest.java| 238 .../org/apache/geode/internal/tcp/server.keystore | Bin 0 -> 1256 bytes ...LSocketHostNameVerificationIntegrationTest.java | 4 +- .../internal/net/SSLSocketIntegrationTest.java | 57 ++- .../apache/geode/codeAnalysis/excludedClasses.txt | 1 + .../geode/internal/net/ByteBufferSharing.java | 55 +++ .../geode/internal/net/ByteBufferSharingImpl.java | 168 .../geode/internal/net/ByteBufferSharingNoOp.java | 52 +++ .../org/apache/geode/internal/net/NioFilter.java | 69 ++-- .../apache/geode/internal/net/NioPlainEngine.java | 27 +- .../apache/geode/internal/net/NioSslEngine.java| 365 - .../org/apache/geode/internal/tcp/Connection.java | 34 +- .../org/apache/geode/internal/tcp/MsgReader.java | 15 +- .../internal/net/ByteBufferConcurrencyTest.java| 165 .../internal/net/ByteBufferSharingImplTest.java| 179 + .../geode/internal/net/NioPlainEngineTest.java | 47 ++- .../geode/internal/net/NioSslEngineTest.java | 432 +++-- 17 files changed, 1422 insertions(+), 486 deletions(-) diff --git a/geode-core/src/distributedTest/java/org/apache/geode/internal/tcp/ConnectionCloseSSLTLSDUnitTest.java b/geode-core/src/distributedTest/java/org/apache/geode/internal/tcp/ConnectionCloseSSLTLSDUnitTest.java new file mode 100644 index 000..77fe9bf --- /dev/null +++ b/geode-core/src/distributedTest/java/org/apache/geode/internal/tcp/ConnectionCloseSSLTLSDUnitTest.java @@ -0,0 +1,238 @@ +/* + * 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.geode.internal.tcp; + +import static org.apache.geode.distributed.ConfigurationProperties.CONSERVE_SOCKETS; +import static org.apache.geode.distributed.ConfigurationProperties.ENABLE_CLUSTER_CONFIGURATION; +import static org.apache.geode.distributed.ConfigurationProperties.LOCATORS; +import static org.apache.geode.distributed.ConfigurationProperties.NAME; +import static org.apache.geode.distributed.ConfigurationProperties.SOCKET_BUFFER_SIZE; +import static org.apache.geode.distributed.ConfigurationProperties.SOCKET_LEASE_TIME; +import static org.apache.geode.distributed.ConfigurationProperties.SSL_ENABLED_COMPONENTS; +import static org.apache.geode.distributed.ConfigurationProperties.SSL_KEYSTORE; +import static org.apache.geode.distributed.ConfigurationProperties.SSL_KEYSTORE_PASSWORD;
[geode] branch support/1.13 updated (4cedf9f -> 32a8a55)
This is an automated email from the ASF dual-hosted git repository. burcham pushed a change to branch support/1.13 in repository https://gitbox.apache.org/repos/asf/geode.git. from 4cedf9f [BACKPORT] GEODE-8681: peer-to-peer message loss due to sending connection closi… (#5713) new d70cd81 GEODE-8136: Move UncheckedUtils to geode-common (#5123) new 8fb7f6c GEODE-8540: Create new DistributedBlackboard Rule (#5557) new 32a8a55 * GEODE-8652: NioSslEngine.close() Bypasses Locks (#5712) The 3 revisions listed above as "new" are entirely new to this repository and will be described in separate emails. The revisions listed as "add" were already present in the repository and have only been added to this reference. Summary of changes: .../geode/util/internal}/UncheckedUtils.java | 19 +- .../geode/util/internal/UncheckedUtilsTest.java| 60 +++ .../cache/PartitionedRegionSingleHopDUnitTest.java | 14 +- ...istributedRegionFunctionExecutionDUnitTest.java | 59 +-- ...oningWithColocationAndPersistenceDUnitTest.java | 12 +- .../tcp/ConnectionCloseSSLTLSDUnitTest.java| 238 .../org/apache/geode/internal/tcp}/server.keystore | Bin .../FunctionExecutionOnLonerRegressionTest.java| 27 +- ...LSocketHostNameVerificationIntegrationTest.java | 4 +- .../internal/net/SSLSocketIntegrationTest.java | 57 ++- .../apache/geode/codeAnalysis/excludedClasses.txt | 1 + .../client/internal/ClientMetadataService.java | 4 +- .../geode/internal/cache/GemFireCacheImpl.java | 49 +-- .../cache/InternalCacheForClientAccess.java| 6 +- .../apache/geode/internal/cache/LocalRegion.java | 7 +- .../util/TypedFunctionService.java}| 20 +- .../tier/sockets/CacheClientProxyFactory.java | 4 +- .../geode/internal/net/ByteBufferSharing.java | 55 +++ .../geode/internal/net/ByteBufferSharingImpl.java | 168 .../geode/internal/net/ByteBufferSharingNoOp.java | 52 +++ .../org/apache/geode/internal/net/NioFilter.java | 69 ++-- .../apache/geode/internal/net/NioPlainEngine.java | 27 +- .../apache/geode/internal/net/NioSslEngine.java| 365 - .../org/apache/geode/internal/tcp/Connection.java | 34 +- .../org/apache/geode/internal/tcp/MsgReader.java | 15 +- .../internal/ClusterAlertMessagingTest.java| 6 +- .../internal/net/ByteBufferConcurrencyTest.java| 165 .../internal/net/ByteBufferSharingImplTest.java| 179 + .../geode/internal/net/NioPlainEngineTest.java | 47 ++- .../geode/internal/net/NioSslEngineTest.java | 432 +++-- .../apache/geode/internal/tcp/TCPConduitTest.java | 4 +- .../dunit/internal/DUnitBlackboardDUnitTest.java | 75 ++-- .../DistributedBlackboardDistributedTest.java | 297 ++ .../InternalBlackboard.java => Blackboard.java}| 54 +-- .../apache/geode/test/dunit/DUnitBlackboard.java | 55 +-- .../test/dunit/internal/InternalBlackboard.java| 33 +- .../dunit/internal/InternalBlackboardImpl.java | 59 ++- .../test/dunit/rules/DistributedBlackboard.java| 138 +++ 38 files changed, 2157 insertions(+), 753 deletions(-) copy {geode-core/src/main/java/org/apache/geode/internal/cache/util => geode-common/src/main/java/org/apache/geode/util/internal}/UncheckedUtils.java (68%) create mode 100644 geode-common/src/test/java/org/apache/geode/util/internal/UncheckedUtilsTest.java create mode 100644 geode-core/src/distributedTest/java/org/apache/geode/internal/tcp/ConnectionCloseSSLTLSDUnitTest.java copy {geode-dunit/src/main/resources/org/apache/geode => geode-core/src/distributedTest/resources/org/apache/geode/internal/tcp}/server.keystore (100%) rename geode-core/src/main/java/org/apache/geode/internal/cache/{util/UncheckedUtils.java => execute/util/TypedFunctionService.java} (61%) create mode 100644 geode-core/src/main/java/org/apache/geode/internal/net/ByteBufferSharing.java create mode 100644 geode-core/src/main/java/org/apache/geode/internal/net/ByteBufferSharingImpl.java create mode 100644 geode-core/src/main/java/org/apache/geode/internal/net/ByteBufferSharingNoOp.java create mode 100644 geode-core/src/test/java/org/apache/geode/internal/net/ByteBufferConcurrencyTest.java create mode 100644 geode-core/src/test/java/org/apache/geode/internal/net/ByteBufferSharingImplTest.java create mode 100644 geode-dunit/src/distributedTest/java/org/apache/geode/test/dunit/rules/tests/DistributedBlackboardDistributedTest.java copy geode-dunit/src/main/java/org/apache/geode/test/dunit/{internal/InternalBlackboard.java => Blackboard.java} (51%) mode change 100755 => 100644 create mode 100644 geode-dunit/src/main/java/org/apache/geode/test/dunit/rules/DistributedBlackboard.java
[geode] 03/03: * GEODE-8652: NioSslEngine.close() Bypasses Locks (#5712)
This is an automated email from the ASF dual-hosted git repository. burcham pushed a commit to branch support/1.13 in repository https://gitbox.apache.org/repos/asf/geode.git commit 32a8a55df4c0a5b8b1e5cfb746070804cbce5e0a Author: Bill Burcham AuthorDate: Thu Nov 5 17:30:29 2020 -0800 * GEODE-8652: NioSslEngine.close() Bypasses Locks (#5712) - NioSslEngine.close() proceeds even if readers (or writers) are operating on its ByteBuffers, allowing Connection.close() to close its socket and proceed. - NioSslEngine.close() needed a lock only on the output buffer, so we split what was a single lock into two. Also instead of using synchronized we use a ReentrantLock so we can call tryLock() and time out if needed in NioSslEngine.close(). - Since readers/writers may hold locks on these input/output buffers when NioSslEngine.close() is called a reference count is maintained and the buffers are returned to the pool only when the last user is done. - To manage the locking and reference counting a new AutoCloseable ByteBufferSharing interface is introduced with a trivial implementation: ByteBufferSharingNoOp and a real implementation: ByteBufferSharingImpl. - Added a new unit test, and a new concurrency test for ByteBufferSharingImpl: both ensure that ByteBuffers are returned to the pool exactly once. Added a new DUnit test for the interaction between ByteBufferSharingImpl and NioSslEngine and Connection. Co-authored-by: Bill Burcham Co-authored-by: Darrel Schneider Co-authored-by: Ernie Burghardt Co-authored-by: Dan Smith (cherry picked from commit af267c005a63317cbb8528cdb38eccf6a8747818) --- .../tcp/ConnectionCloseSSLTLSDUnitTest.java| 238 .../org/apache/geode/internal/tcp/server.keystore | Bin 0 -> 1256 bytes ...LSocketHostNameVerificationIntegrationTest.java | 4 +- .../internal/net/SSLSocketIntegrationTest.java | 57 ++- .../apache/geode/codeAnalysis/excludedClasses.txt | 1 + .../geode/internal/net/ByteBufferSharing.java | 55 +++ .../geode/internal/net/ByteBufferSharingImpl.java | 168 .../geode/internal/net/ByteBufferSharingNoOp.java | 52 +++ .../org/apache/geode/internal/net/NioFilter.java | 69 ++-- .../apache/geode/internal/net/NioPlainEngine.java | 27 +- .../apache/geode/internal/net/NioSslEngine.java| 365 - .../org/apache/geode/internal/tcp/Connection.java | 34 +- .../org/apache/geode/internal/tcp/MsgReader.java | 15 +- .../internal/net/ByteBufferConcurrencyTest.java| 165 .../internal/net/ByteBufferSharingImplTest.java| 179 + .../geode/internal/net/NioPlainEngineTest.java | 47 ++- .../geode/internal/net/NioSslEngineTest.java | 432 +++-- 17 files changed, 1422 insertions(+), 486 deletions(-) diff --git a/geode-core/src/distributedTest/java/org/apache/geode/internal/tcp/ConnectionCloseSSLTLSDUnitTest.java b/geode-core/src/distributedTest/java/org/apache/geode/internal/tcp/ConnectionCloseSSLTLSDUnitTest.java new file mode 100644 index 000..77fe9bf --- /dev/null +++ b/geode-core/src/distributedTest/java/org/apache/geode/internal/tcp/ConnectionCloseSSLTLSDUnitTest.java @@ -0,0 +1,238 @@ +/* + * 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.geode.internal.tcp; + +import static org.apache.geode.distributed.ConfigurationProperties.CONSERVE_SOCKETS; +import static org.apache.geode.distributed.ConfigurationProperties.ENABLE_CLUSTER_CONFIGURATION; +import static org.apache.geode.distributed.ConfigurationProperties.LOCATORS; +import static org.apache.geode.distributed.ConfigurationProperties.NAME; +import static org.apache.geode.distributed.ConfigurationProperties.SOCKET_BUFFER_SIZE; +import static org.apache.geode.distributed.ConfigurationProperties.SOCKET_LEASE_TIME; +import static org.apache.geode.distributed.ConfigurationProperties.SSL_ENABLED_COMPONENTS; +import static org.apache.geode.distributed.ConfigurationProperties.SSL_KEYSTORE; +import static org.apache.geode.distributed.ConfigurationProperties.SSL_KEYSTORE_PASSWORD;
[geode] 01/03: GEODE-8136: Move UncheckedUtils to geode-common (#5123)
This is an automated email from the ASF dual-hosted git repository. burcham pushed a commit to branch support/1.13 in repository https://gitbox.apache.org/repos/asf/geode.git commit d70cd816ff183033b059198c9db8302c76a7af65 Author: Kirk Lund AuthorDate: Tue May 26 10:24:44 2020 -0700 GEODE-8136: Move UncheckedUtils to geode-common (#5123) Create UncheckedUtilsTest to unit test UncheckedUtils. Extract FunctionExecution methods to new TypedFunctionService in geode-core. --- .../geode/util/internal}/UncheckedUtils.java | 19 --- .../geode/util/internal/UncheckedUtilsTest.java| 60 ++ .../cache/PartitionedRegionSingleHopDUnitTest.java | 14 ++--- ...istributedRegionFunctionExecutionDUnitTest.java | 59 +++-- ...oningWithColocationAndPersistenceDUnitTest.java | 12 ++--- .../FunctionExecutionOnLonerRegressionTest.java| 27 ++ .../client/internal/ClientMetadataService.java | 4 +- .../geode/internal/cache/GemFireCacheImpl.java | 49 -- .../cache/InternalCacheForClientAccess.java| 6 +-- .../apache/geode/internal/cache/LocalRegion.java | 7 ++- .../util/TypedFunctionService.java}| 20 +--- .../tier/sockets/CacheClientProxyFactory.java | 4 +- .../internal/ClusterAlertMessagingTest.java| 6 +-- .../apache/geode/internal/tcp/TCPConduitTest.java | 4 +- 14 files changed, 151 insertions(+), 140 deletions(-) diff --git a/geode-core/src/main/java/org/apache/geode/internal/cache/util/UncheckedUtils.java b/geode-common/src/main/java/org/apache/geode/util/internal/UncheckedUtils.java similarity index 68% copy from geode-core/src/main/java/org/apache/geode/internal/cache/util/UncheckedUtils.java copy to geode-common/src/main/java/org/apache/geode/util/internal/UncheckedUtils.java index c03e990..61dbd8d 100644 --- a/geode-core/src/main/java/org/apache/geode/internal/cache/util/UncheckedUtils.java +++ b/geode-common/src/main/java/org/apache/geode/util/internal/UncheckedUtils.java @@ -12,18 +12,23 @@ * or implied. See the License for the specific language governing permissions and limitations under * the License. */ -package org.apache.geode.internal.cache.util; - -import org.apache.geode.cache.execute.Execution; +package org.apache.geode.util.internal; +/** + * Utilities for casting and working with unchecked raw types. + */ @SuppressWarnings({"unchecked", "unused"}) public class UncheckedUtils { - public static T cast(Object object) { -return (T) object; + protected UncheckedUtils() { +// do not instantiate } - public static Execution cast(Execution execution) { -return execution; + /** + * Casts an instance of a raw type to a parameterized type. Preference should be given to + * converting all code from using raw types to using parameterized types when possible. + */ + public static T uncheckedCast(Object object) { +return (T) object; } } diff --git a/geode-common/src/test/java/org/apache/geode/util/internal/UncheckedUtilsTest.java b/geode-common/src/test/java/org/apache/geode/util/internal/UncheckedUtilsTest.java new file mode 100644 index 000..7c282b7 --- /dev/null +++ b/geode-common/src/test/java/org/apache/geode/util/internal/UncheckedUtilsTest.java @@ -0,0 +1,60 @@ +/* + * 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.geode.util.internal; + +import static org.apache.geode.util.internal.UncheckedUtils.uncheckedCast; +import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.catchThrowable; + +import java.util.ArrayList; +import java.util.List; + +import org.junit.Test; + +@SuppressWarnings("unchecked") +public class UncheckedUtilsTest { + + @Test + public void uncheckedCast_rawList_empty() { +List rawList = new ArrayList(); + +List value = uncheckedCast(rawList); + +assertThat(value).isSameAs(rawList); + } + + @Test + public void uncheckedCast_rawList_nonEmpty() { +List rawList = new ArrayList(); +rawList.add("1"); +rawList.add("2"); + +List value = uncheckedCast(rawList); + +assertThat(value).isSameAs(rawList); + } + + @Test + public void
[geode] branch support/1.13 updated (4cedf9f -> 32a8a55)
This is an automated email from the ASF dual-hosted git repository. burcham pushed a change to branch support/1.13 in repository https://gitbox.apache.org/repos/asf/geode.git. from 4cedf9f [BACKPORT] GEODE-8681: peer-to-peer message loss due to sending connection closi… (#5713) new d70cd81 GEODE-8136: Move UncheckedUtils to geode-common (#5123) new 8fb7f6c GEODE-8540: Create new DistributedBlackboard Rule (#5557) new 32a8a55 * GEODE-8652: NioSslEngine.close() Bypasses Locks (#5712) The 3 revisions listed above as "new" are entirely new to this repository and will be described in separate emails. The revisions listed as "add" were already present in the repository and have only been added to this reference. Summary of changes: .../geode/util/internal}/UncheckedUtils.java | 19 +- .../geode/util/internal/UncheckedUtilsTest.java| 60 +++ .../cache/PartitionedRegionSingleHopDUnitTest.java | 14 +- ...istributedRegionFunctionExecutionDUnitTest.java | 59 +-- ...oningWithColocationAndPersistenceDUnitTest.java | 12 +- .../tcp/ConnectionCloseSSLTLSDUnitTest.java| 238 .../org/apache/geode/internal/tcp}/server.keystore | Bin .../FunctionExecutionOnLonerRegressionTest.java| 27 +- ...LSocketHostNameVerificationIntegrationTest.java | 4 +- .../internal/net/SSLSocketIntegrationTest.java | 57 ++- .../apache/geode/codeAnalysis/excludedClasses.txt | 1 + .../client/internal/ClientMetadataService.java | 4 +- .../geode/internal/cache/GemFireCacheImpl.java | 49 +-- .../cache/InternalCacheForClientAccess.java| 6 +- .../apache/geode/internal/cache/LocalRegion.java | 7 +- .../util/TypedFunctionService.java}| 20 +- .../tier/sockets/CacheClientProxyFactory.java | 4 +- .../geode/internal/net/ByteBufferSharing.java | 55 +++ .../geode/internal/net/ByteBufferSharingImpl.java | 168 .../geode/internal/net/ByteBufferSharingNoOp.java | 52 +++ .../org/apache/geode/internal/net/NioFilter.java | 69 ++-- .../apache/geode/internal/net/NioPlainEngine.java | 27 +- .../apache/geode/internal/net/NioSslEngine.java| 365 - .../org/apache/geode/internal/tcp/Connection.java | 34 +- .../org/apache/geode/internal/tcp/MsgReader.java | 15 +- .../internal/ClusterAlertMessagingTest.java| 6 +- .../internal/net/ByteBufferConcurrencyTest.java| 165 .../internal/net/ByteBufferSharingImplTest.java| 179 + .../geode/internal/net/NioPlainEngineTest.java | 47 ++- .../geode/internal/net/NioSslEngineTest.java | 432 +++-- .../apache/geode/internal/tcp/TCPConduitTest.java | 4 +- .../dunit/internal/DUnitBlackboardDUnitTest.java | 75 ++-- .../DistributedBlackboardDistributedTest.java | 297 ++ .../InternalBlackboard.java => Blackboard.java}| 54 +-- .../apache/geode/test/dunit/DUnitBlackboard.java | 55 +-- .../test/dunit/internal/InternalBlackboard.java| 33 +- .../dunit/internal/InternalBlackboardImpl.java | 59 ++- .../test/dunit/rules/DistributedBlackboard.java| 138 +++ 38 files changed, 2157 insertions(+), 753 deletions(-) copy {geode-core/src/main/java/org/apache/geode/internal/cache/util => geode-common/src/main/java/org/apache/geode/util/internal}/UncheckedUtils.java (68%) create mode 100644 geode-common/src/test/java/org/apache/geode/util/internal/UncheckedUtilsTest.java create mode 100644 geode-core/src/distributedTest/java/org/apache/geode/internal/tcp/ConnectionCloseSSLTLSDUnitTest.java copy {geode-dunit/src/main/resources/org/apache/geode => geode-core/src/distributedTest/resources/org/apache/geode/internal/tcp}/server.keystore (100%) rename geode-core/src/main/java/org/apache/geode/internal/cache/{util/UncheckedUtils.java => execute/util/TypedFunctionService.java} (61%) create mode 100644 geode-core/src/main/java/org/apache/geode/internal/net/ByteBufferSharing.java create mode 100644 geode-core/src/main/java/org/apache/geode/internal/net/ByteBufferSharingImpl.java create mode 100644 geode-core/src/main/java/org/apache/geode/internal/net/ByteBufferSharingNoOp.java create mode 100644 geode-core/src/test/java/org/apache/geode/internal/net/ByteBufferConcurrencyTest.java create mode 100644 geode-core/src/test/java/org/apache/geode/internal/net/ByteBufferSharingImplTest.java create mode 100644 geode-dunit/src/distributedTest/java/org/apache/geode/test/dunit/rules/tests/DistributedBlackboardDistributedTest.java copy geode-dunit/src/main/java/org/apache/geode/test/dunit/{internal/InternalBlackboard.java => Blackboard.java} (51%) mode change 100755 => 100644 create mode 100644 geode-dunit/src/main/java/org/apache/geode/test/dunit/rules/DistributedBlackboard.java
[geode] 02/03: GEODE-8540: Create new DistributedBlackboard Rule (#5557)
This is an automated email from the ASF dual-hosted git repository. burcham pushed a commit to branch support/1.13 in repository https://gitbox.apache.org/repos/asf/geode.git commit 8fb7f6c7db9ef2ec0ff8b618a578738e1426d801 Author: Kirk Lund AuthorDate: Wed Sep 30 09:39:30 2020 -0700 GEODE-8540: Create new DistributedBlackboard Rule (#5557) Package up DUnitBlackboard as a JUnit Rule named DistributedBlackboard. --- .../dunit/internal/DUnitBlackboardDUnitTest.java | 75 +++--- .../DistributedBlackboardDistributedTest.java | 297 + .../InternalBlackboard.java => Blackboard.java}| 54 ++-- .../apache/geode/test/dunit/DUnitBlackboard.java | 55 ++-- .../test/dunit/internal/InternalBlackboard.java| 33 ++- .../dunit/internal/InternalBlackboardImpl.java | 59 ++-- .../test/dunit/rules/DistributedBlackboard.java| 138 ++ 7 files changed, 584 insertions(+), 127 deletions(-) diff --git a/geode-dunit/src/distributedTest/java/org/apache/geode/test/dunit/internal/DUnitBlackboardDUnitTest.java b/geode-dunit/src/distributedTest/java/org/apache/geode/test/dunit/internal/DUnitBlackboardDUnitTest.java index ae78247..5e151d7 100755 --- a/geode-dunit/src/distributedTest/java/org/apache/geode/test/dunit/internal/DUnitBlackboardDUnitTest.java +++ b/geode-dunit/src/distributedTest/java/org/apache/geode/test/dunit/internal/DUnitBlackboardDUnitTest.java @@ -14,83 +14,70 @@ */ package org.apache.geode.test.dunit.internal; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNull; -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; +import static java.util.concurrent.TimeUnit.SECONDS; +import static org.apache.geode.test.dunit.VM.getVM; +import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.catchThrowable; -import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeoutException; import org.junit.Test; -import org.apache.geode.test.dunit.Host; import org.apache.geode.test.dunit.VM; - +@SuppressWarnings("serial") public class DUnitBlackboardDUnitTest extends JUnit4DistributedTestCase { + @Test - public void canPassDataBetweenVMs() throws Exception { + public void canPassDataBetweenVMs() { final String MBOX = "myMailbox"; -VM vm0 = Host.getHost(0).getVM(0); -VM vm1 = Host.getHost(0).getVM(1); +VM vm0 = getVM(0); +VM vm1 = getVM(1); vm0.invoke("put data in mailbox", () -> getBlackboard().setMailbox(MBOX, "testing")); -String result = (String) vm1.invoke("get data from mailbox", () -> { - return getBlackboard().getMailbox(MBOX); -}); +String result = vm1.invoke("get data from mailbox", () -> getBlackboard().getMailbox(MBOX)); -assertEquals("testing", result); +assertThat(result).isEqualTo("testing"); } @Test - public void canSignalAnotherVM() throws Exception { + public void canSignalAnotherVM() { final String GATE = "myGate"; -VM vm0 = Host.getHost(0).getVM(0); -VM vm1 = Host.getHost(0).getVM(1); +VM vm0 = getVM(0); +VM vm1 = getVM(1); vm1.invoke("wait on gate not yet signalled", () -> { - assertFalse(getBlackboard().isGateSignaled(GATE)); - try { -getBlackboard().waitForGate(GATE, 1, TimeUnit.SECONDS); - } catch (TimeoutException e) { -// expected -return; - } catch (InterruptedException e) { -fail("unexpected interrupt"); - } - fail("unexpected success"); + assertThat(getBlackboard().isGateSignaled(GATE)).isFalse(); + + Throwable thrown = catchThrowable(() -> { +getBlackboard().waitForGate(GATE, 1, SECONDS); + }); + + assertThat(thrown).isInstanceOf(TimeoutException.class); }); vm0.invoke("signal gate", () -> getBlackboard().signalGate(GATE)); -vm1.invoke("wait on gate not yet signalled", () -> { - try { -getBlackboard().waitForGate(GATE, 1, TimeUnit.SECONDS); - } catch (TimeoutException e) { -fail("unexpected timeout"); - } catch (InterruptedException e) { -fail("unexpected interrupt"); - } - // success expected -}); +vm1.invoke("wait on gate not yet signalled", +() -> getBlackboard().waitForGate(GATE, 1, SECONDS)); } @Test - public void initBlackboardClearsEverything() throws Exception { + public void initBlackboardClearsEverything() { for (int i = 0; i < 100; i++) { getBlackboard().setMailbox("MBOX" + i, "value" + i); - assertEquals("value" + i, getBlackboard().getMailbox("MBOX" + i)); + assertThat((Object) getBlackboard().getMailbox("MBOX" + i)).isEqualTo("value" + i); + getBlackboard().signalGate("GATE" + i); - assertTrue(getBlackboard().isGateSignaled("GATE" + i)); + assertThat(getBlackboard().isGateSignaled("GATE" + i)).isTrue(); } -
[geode] branch support/1.12 updated: GEODE-6008: CI Failure: ClientServerHostNameVerificationDistributedTe… (#4839)
This is an automated email from the ASF dual-hosted git repository. bschuchardt pushed a commit to branch support/1.12 in repository https://gitbox.apache.org/repos/asf/geode.git The following commit(s) were added to refs/heads/support/1.12 by this push: new 3a89ae5 GEODE-6008: CI Failure: ClientServerHostNameVerificationDistributedTe… (#4839) 3a89ae5 is described below commit 3a89ae5448df7b534c82fa594b195057a974d85c Author: Bruce Schuchardt AuthorDate: Tue Mar 24 11:07:27 2020 -0700 GEODE-6008: CI Failure: ClientServerHostNameVerificationDistributedTe… (#4839) * GEODE-6008: CI Failure: ClientServerHostNameVerificationDistributedTest.expectConnectionFailureWhenNoHostNameInServerKey failed The "Message distribution has terminated" failure is caused by an unreported NullPointerException in a residual reader thread introduced in the fix for GEODE-7727. That fix caused a thread to say alive in a peer-to-peer tcp/ip Connection in order to clean up the receiving side of a socket. The Connection shutdown method close() method, however, releases the Connection's input buffer and nulls out the field. The reader thread then threw an NPE that was caught and caused the "Message distribution has terminated" message, which is picked up as a suspect string by the testing infrastructure. This problem is also seen in GEODE-7894, GEODE-7871, GEODE-7873 and GEODE-7806. The fix is to record the fact that a residual reader thread exists and avoid releasing the Connection's input buffer when the connection is closed. This lets the reader thread do the cleanup. While testing the fix I found that the NioSslEngine was throwing an IllegalStateException when the reader thread tried to use it in this same situation. This exception wasn't being caught and caused more suspect strings to be logged. I've changed this to a checked exception that is already handled by the reader thread. ClientServerHostNameVerificationDistributedTest also wasn't working on my Mac due to its /etc/hosts configuration. I changed the test to allow the IP address selected by LocalHostUtil to be a valid client/server address for the SSL certificates it generates. * fixed failing test due to change in exceptions in NioSslEngine (cherry picked from commit 1dfc496da34916297258b881c5606944d26bfb8b) --- ...tServerHostNameVerificationDistributedTest.java | 4 +++ .../geode/internal/tcp/CloseConnectionTest.java| 13 .../org/apache/geode/internal/tcp/Connection.java | 38 ++ 3 files changed, 48 insertions(+), 7 deletions(-) diff --git a/geode-core/src/distributedTest/java/org/apache/geode/cache/client/internal/ClientServerHostNameVerificationDistributedTest.java b/geode-core/src/distributedTest/java/org/apache/geode/cache/client/internal/ClientServerHostNameVerificationDistributedTest.java index 8f1db5f..3ef5ac0 100644 --- a/geode-core/src/distributedTest/java/org/apache/geode/cache/client/internal/ClientServerHostNameVerificationDistributedTest.java +++ b/geode-core/src/distributedTest/java/org/apache/geode/cache/client/internal/ClientServerHostNameVerificationDistributedTest.java @@ -39,6 +39,7 @@ import org.apache.geode.cache.client.NoAvailableServersException; import org.apache.geode.cache.ssl.CertStores; import org.apache.geode.cache.ssl.CertificateBuilder; import org.apache.geode.cache.ssl.CertificateMaterial; +import org.apache.geode.internal.inet.LocalHostUtil; import org.apache.geode.internal.net.SocketCreatorFactory; import org.apache.geode.test.dunit.IgnoredException; import org.apache.geode.test.dunit.rules.ClusterStartupRule; @@ -82,6 +83,7 @@ public class ClientServerHostNameVerificationDistributedTest { .sanDnsName(InetAddress.getLoopbackAddress().getHostName()) .sanDnsName(InetAddress.getLocalHost().getHostName()) .sanDnsName(InetAddress.getLocalHost().getCanonicalHostName()) +.sanIpAddress(LocalHostUtil.getLocalHost()) .sanIpAddress(InetAddress.getLocalHost()) .sanIpAddress(InetAddress.getByName("0.0.0.0")) // to pass on windows .generate(); @@ -91,6 +93,7 @@ public class ClientServerHostNameVerificationDistributedTest { .issuedBy(ca) .sanDnsName(InetAddress.getLocalHost().getHostName()) .sanDnsName(InetAddress.getLocalHost().getCanonicalHostName()) +.sanIpAddress(LocalHostUtil.getLocalHost()) .sanIpAddress(InetAddress.getLocalHost()) .generate(); @@ -162,6 +165,7 @@ public class ClientServerHostNameVerificationDistributedTest { .sanDnsName(InetAddress.getLoopbackAddress().getHostName()) .sanDnsName(InetAddress.getLocalHost().getHostName()) .sanDnsName(InetAddress.getLocalHost().getCanonicalHostName()) +.sanIpAddress(LocalHostUtil.getLocalHost())
[geode] branch support/1.12 updated: GEODE-6008: CI Failure: ClientServerHostNameVerificationDistributedTe… (#4839)
This is an automated email from the ASF dual-hosted git repository. bschuchardt pushed a commit to branch support/1.12 in repository https://gitbox.apache.org/repos/asf/geode.git The following commit(s) were added to refs/heads/support/1.12 by this push: new 3a89ae5 GEODE-6008: CI Failure: ClientServerHostNameVerificationDistributedTe… (#4839) 3a89ae5 is described below commit 3a89ae5448df7b534c82fa594b195057a974d85c Author: Bruce Schuchardt AuthorDate: Tue Mar 24 11:07:27 2020 -0700 GEODE-6008: CI Failure: ClientServerHostNameVerificationDistributedTe… (#4839) * GEODE-6008: CI Failure: ClientServerHostNameVerificationDistributedTest.expectConnectionFailureWhenNoHostNameInServerKey failed The "Message distribution has terminated" failure is caused by an unreported NullPointerException in a residual reader thread introduced in the fix for GEODE-7727. That fix caused a thread to say alive in a peer-to-peer tcp/ip Connection in order to clean up the receiving side of a socket. The Connection shutdown method close() method, however, releases the Connection's input buffer and nulls out the field. The reader thread then threw an NPE that was caught and caused the "Message distribution has terminated" message, which is picked up as a suspect string by the testing infrastructure. This problem is also seen in GEODE-7894, GEODE-7871, GEODE-7873 and GEODE-7806. The fix is to record the fact that a residual reader thread exists and avoid releasing the Connection's input buffer when the connection is closed. This lets the reader thread do the cleanup. While testing the fix I found that the NioSslEngine was throwing an IllegalStateException when the reader thread tried to use it in this same situation. This exception wasn't being caught and caused more suspect strings to be logged. I've changed this to a checked exception that is already handled by the reader thread. ClientServerHostNameVerificationDistributedTest also wasn't working on my Mac due to its /etc/hosts configuration. I changed the test to allow the IP address selected by LocalHostUtil to be a valid client/server address for the SSL certificates it generates. * fixed failing test due to change in exceptions in NioSslEngine (cherry picked from commit 1dfc496da34916297258b881c5606944d26bfb8b) --- ...tServerHostNameVerificationDistributedTest.java | 4 +++ .../geode/internal/tcp/CloseConnectionTest.java| 13 .../org/apache/geode/internal/tcp/Connection.java | 38 ++ 3 files changed, 48 insertions(+), 7 deletions(-) diff --git a/geode-core/src/distributedTest/java/org/apache/geode/cache/client/internal/ClientServerHostNameVerificationDistributedTest.java b/geode-core/src/distributedTest/java/org/apache/geode/cache/client/internal/ClientServerHostNameVerificationDistributedTest.java index 8f1db5f..3ef5ac0 100644 --- a/geode-core/src/distributedTest/java/org/apache/geode/cache/client/internal/ClientServerHostNameVerificationDistributedTest.java +++ b/geode-core/src/distributedTest/java/org/apache/geode/cache/client/internal/ClientServerHostNameVerificationDistributedTest.java @@ -39,6 +39,7 @@ import org.apache.geode.cache.client.NoAvailableServersException; import org.apache.geode.cache.ssl.CertStores; import org.apache.geode.cache.ssl.CertificateBuilder; import org.apache.geode.cache.ssl.CertificateMaterial; +import org.apache.geode.internal.inet.LocalHostUtil; import org.apache.geode.internal.net.SocketCreatorFactory; import org.apache.geode.test.dunit.IgnoredException; import org.apache.geode.test.dunit.rules.ClusterStartupRule; @@ -82,6 +83,7 @@ public class ClientServerHostNameVerificationDistributedTest { .sanDnsName(InetAddress.getLoopbackAddress().getHostName()) .sanDnsName(InetAddress.getLocalHost().getHostName()) .sanDnsName(InetAddress.getLocalHost().getCanonicalHostName()) +.sanIpAddress(LocalHostUtil.getLocalHost()) .sanIpAddress(InetAddress.getLocalHost()) .sanIpAddress(InetAddress.getByName("0.0.0.0")) // to pass on windows .generate(); @@ -91,6 +93,7 @@ public class ClientServerHostNameVerificationDistributedTest { .issuedBy(ca) .sanDnsName(InetAddress.getLocalHost().getHostName()) .sanDnsName(InetAddress.getLocalHost().getCanonicalHostName()) +.sanIpAddress(LocalHostUtil.getLocalHost()) .sanIpAddress(InetAddress.getLocalHost()) .generate(); @@ -162,6 +165,7 @@ public class ClientServerHostNameVerificationDistributedTest { .sanDnsName(InetAddress.getLoopbackAddress().getHostName()) .sanDnsName(InetAddress.getLocalHost().getHostName()) .sanDnsName(InetAddress.getLocalHost().getCanonicalHostName()) +.sanIpAddress(LocalHostUtil.getLocalHost())
[geode] 01/01: GEODE-8681: peer-to-peer message loss due to sending connection closing with TLS enabled (#5699) (#5714)
This is an automated email from the ASF dual-hosted git repository. echobravo pushed a commit to branch support/1.12 in repository https://gitbox.apache.org/repos/asf/geode.git commit f80d41ae4cefdc22f5b4fe2830fd38e34b44765b Merge: 9b2aea9 3660bb5 Author: Ernie Burghardt AuthorDate: Fri Nov 6 08:23:19 2020 -0800 GEODE-8681: peer-to-peer message loss due to sending connection closing with TLS enabled (#5699) (#5714) A socket-read could pick up more than one message and a single unwrap() could decrypt multiple messages. Normally the engine isn't closed and it reports normal status from an unwrap() operation, and Connection.processInputBuffer picks up each message, one by one, from the buffer and dispatches them. But if the SSLEngine is closed we were ignoring any already-decrypted data sitting in the unwrapped buffer and instead we were throwing an SSLException. (cherry picked from commit 7da8f9b516ac1e2525a1dfc922af7bfb8995f2c6) Co-authored-by: Bruce Schuchardt .../geode/ClusterCommunicationsDUnitTest.java | 85 -- .../apache/geode/internal/net/NioSslEngine.java| 12 ++- .../geode/internal/net/NioSslEngineTest.java | 29 +++- 3 files changed, 113 insertions(+), 13 deletions(-)
[geode] branch support/1.12 updated (9b2aea9 -> f80d41a)
This is an automated email from the ASF dual-hosted git repository. echobravo pushed a change to branch support/1.12 in repository https://gitbox.apache.org/repos/asf/geode.git. from 9b2aea9 GEODE-8603: Potentially expand classes identified for CI stressing to include subclasses (#5601) (#5674) add 7f8f882 GEODE-8681: peer-to-peer message loss due to sending connection closing with TLS enabled (#5699) add 3660bb5 Update NioSslEngineTest.java new f80d41a GEODE-8681: peer-to-peer message loss due to sending connection closing with TLS enabled (#5699) (#5714) The 1 revisions listed above as "new" are entirely new to this repository and will be described in separate emails. The revisions listed as "add" were already present in the repository and have only been added to this reference. Summary of changes: .../geode/ClusterCommunicationsDUnitTest.java | 85 -- .../apache/geode/internal/net/NioSslEngine.java| 12 ++- .../geode/internal/net/NioSslEngineTest.java | 29 +++- 3 files changed, 113 insertions(+), 13 deletions(-)
[geode] branch support/1.13 updated: [BACKPORT] GEODE-8681: peer-to-peer message loss due to sending connection closi… (#5713)
This is an automated email from the ASF dual-hosted git repository. echobravo pushed a commit to branch support/1.13 in repository https://gitbox.apache.org/repos/asf/geode.git The following commit(s) were added to refs/heads/support/1.13 by this push: new 4cedf9f [BACKPORT] GEODE-8681: peer-to-peer message loss due to sending connection closi… (#5713) 4cedf9f is described below commit 4cedf9ff63952bb2a200ba0f218216a4e2ec272a Author: Ernie Burghardt AuthorDate: Fri Nov 6 08:22:36 2020 -0800 [BACKPORT] GEODE-8681: peer-to-peer message loss due to sending connection closi… (#5713) * GEODE-8681: peer-to-peer message loss due to sending connection closing with TLS enabled (#5699) A socket-read could pick up more than one message and a single unwrap() could decrypt multiple messages. Normally the engine isn't closed and it reports normal status from an unwrap() operation, and Connection.processInputBuffer picks up each message, one by one, from the buffer and dispatches them. But if the SSLEngine is closed we were ignoring any already-decrypted data sitting in the unwrapped buffer and instead we were throwing an SSLException. (cherry picked from commit 7da8f9b516ac1e2525a1dfc922af7bfb8995f2c6) Authored-by: Bruce Schuchardt --- .../geode/ClusterCommunicationsDUnitTest.java | 87 -- .../apache/geode/internal/net/NioSslEngine.java| 12 ++- .../geode/internal/net/NioSslEngineTest.java | 29 +++- 3 files changed, 114 insertions(+), 14 deletions(-) diff --git a/geode-core/src/distributedTest/java/org/apache/geode/ClusterCommunicationsDUnitTest.java b/geode-core/src/distributedTest/java/org/apache/geode/ClusterCommunicationsDUnitTest.java index 3ae79fd..fc72cd2 100644 --- a/geode-core/src/distributedTest/java/org/apache/geode/ClusterCommunicationsDUnitTest.java +++ b/geode-core/src/distributedTest/java/org/apache/geode/ClusterCommunicationsDUnitTest.java @@ -29,6 +29,7 @@ import static org.apache.geode.distributed.ConfigurationProperties.SSL_REQUIRE_A import static org.apache.geode.distributed.ConfigurationProperties.SSL_TRUSTSTORE; import static org.apache.geode.distributed.ConfigurationProperties.SSL_TRUSTSTORE_PASSWORD; import static org.apache.geode.distributed.ConfigurationProperties.USE_CLUSTER_CONFIGURATION; +import static org.apache.geode.distributed.internal.OperationExecutors.SERIAL_EXECUTOR; import static org.apache.geode.internal.serialization.DataSerializableFixedID.SERIAL_ACKED_MESSAGE; import static org.apache.geode.test.awaitility.GeodeAwaitility.await; import static org.apache.geode.test.awaitility.GeodeAwaitility.getTimeout; @@ -51,6 +52,7 @@ import java.util.Properties; import java.util.Set; import java.util.concurrent.TimeUnit; +import org.jetbrains.annotations.NotNull; import org.junit.Assert; import org.junit.Before; import org.junit.Rule; @@ -64,7 +66,10 @@ import org.junit.runners.Parameterized.UseParametersRunnerFactory; import org.apache.geode.cache.Cache; import org.apache.geode.cache.CacheFactory; import org.apache.geode.cache.RegionShortcut; +import org.apache.geode.cache.Scope; +import org.apache.geode.distributed.DistributedLockService; import org.apache.geode.distributed.DistributedMember; +import org.apache.geode.distributed.DistributedSystem; import org.apache.geode.distributed.Locator; import org.apache.geode.distributed.internal.ClusterDistributionManager; import org.apache.geode.distributed.internal.DMStats; @@ -72,7 +77,6 @@ import org.apache.geode.distributed.internal.DirectReplyProcessor; import org.apache.geode.distributed.internal.DistributionMessage; import org.apache.geode.distributed.internal.InternalDistributedSystem; import org.apache.geode.distributed.internal.MessageWithReply; -import org.apache.geode.distributed.internal.OperationExecutors; import org.apache.geode.distributed.internal.ReplyException; import org.apache.geode.distributed.internal.ReplyMessage; import org.apache.geode.distributed.internal.SerialAckedMessage; @@ -82,6 +86,8 @@ import org.apache.geode.internal.InternalDataSerializer; import org.apache.geode.internal.cache.DirectReplyMessage; import org.apache.geode.internal.serialization.DeserializationContext; import org.apache.geode.internal.serialization.SerializationContext; +import org.apache.geode.test.dunit.AsyncInvocation; +import org.apache.geode.test.dunit.DUnitBlackboard; import org.apache.geode.test.dunit.DistributedTestUtils; import org.apache.geode.test.dunit.Host; import org.apache.geode.test.dunit.VM; @@ -111,6 +117,7 @@ public class ClusterCommunicationsDUnitTest implements Serializable { private final String regionName = "clusterTestRegion"; private final boolean disableTcp; + private boolean useDAck; private boolean conserveSockets; private boolean useSSL; @@ -134,6 +141,7 @@ public class ClusterCommunicationsDUnitTest implements Serializable {