You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@geode.apache.org by bs...@apache.org on 2019/04/16 22:59:44 UTC

[geode] branch feature/GEODE-6664 created (now 74ba980)

This is an automated email from the ASF dual-hosted git repository.

bschuchardt pushed a change to branch feature/GEODE-6664
in repository https://gitbox.apache.org/repos/asf/geode.git.


      at 74ba980  GEODE-6664 CI failure: org.apache.geode.ClusterCommunicationsDUnitTest.receiveBigResponse

This branch includes the following new commits:

     new 74ba980  GEODE-6664 CI failure: org.apache.geode.ClusterCommunicationsDUnitTest.receiveBigResponse

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.



[geode] 01/01: GEODE-6664 CI failure: org.apache.geode.ClusterCommunicationsDUnitTest.receiveBigResponse

Posted by bs...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

bschuchardt pushed a commit to branch feature/GEODE-6664
in repository https://gitbox.apache.org/repos/asf/geode.git

commit 74ba98030f16420cc8c708e483a74f5e9f85ef0c
Author: Bruce Schuchardt <bs...@pivotal.io>
AuthorDate: Tue Apr 16 15:56:29 2019 -0700

    GEODE-6664 CI failure: org.apache.geode.ClusterCommunicationsDUnitTest.receiveBigResponse
    
    Ensure that the encrypted buffer is at least as big as the
    SSLSession's packet buffer size.  That's required for proper decryption
    of incoming packets.
---
 .../java/org/apache/geode/internal/net/NioSslEngine.java  | 15 +++++++--------
 .../org/apache/geode/internal/net/NioSslEngineTest.java   | 12 ++++++++++--
 2 files changed, 17 insertions(+), 10 deletions(-)

diff --git a/geode-core/src/main/java/org/apache/geode/internal/net/NioSslEngine.java b/geode-core/src/main/java/org/apache/geode/internal/net/NioSslEngine.java
index f2e0e36..dd71d75 100644
--- a/geode-core/src/main/java/org/apache/geode/internal/net/NioSslEngine.java
+++ b/geode-core/src/main/java/org/apache/geode/internal/net/NioSslEngine.java
@@ -308,18 +308,17 @@ public class NioSslEngine implements NioFilter {
     }
   }
 
-  /*
-   * NioSslEngine doesn't need to ensure capacity in network buffers because they
-   * are fixed in size by the SslContext. The size recommended by the context is
-   * big enough for the SslEngine to do its work.
-   */
   @Override
   public ByteBuffer ensureWrappedCapacity(int amount, ByteBuffer wrappedBuffer,
       Buffers.BufferType bufferType, DMStats stats) {
-    if (wrappedBuffer == null) {
-      wrappedBuffer = Buffers.acquireBuffer(bufferType, amount, stats);
+    ByteBuffer buffer = wrappedBuffer;
+    int requiredSize = engine.getSession().getPacketBufferSize();
+    if (buffer == null) {
+      buffer = Buffers.acquireBuffer(bufferType, requiredSize, stats);
+    } else if (buffer.capacity() < requiredSize) {
+      buffer = Buffers.expandWriteBufferIfNeeded(bufferType, buffer, requiredSize, stats);
     }
-    return wrappedBuffer;
+    return buffer;
   }
 
   @Override
diff --git a/geode-core/src/test/java/org/apache/geode/internal/net/NioSslEngineTest.java b/geode-core/src/test/java/org/apache/geode/internal/net/NioSslEngineTest.java
index 68d7936..b12df09 100644
--- a/geode-core/src/test/java/org/apache/geode/internal/net/NioSslEngineTest.java
+++ b/geode-core/src/test/java/org/apache/geode/internal/net/NioSslEngineTest.java
@@ -373,14 +373,22 @@ public class NioSslEngineTest {
   }
 
   @Test
-  public void ensureWrappedCapacity() {
-    ByteBuffer buffer = ByteBuffer.allocate(10);
+  public void ensureWrappedCapacityOfSmallMessage() {
+    ByteBuffer buffer = ByteBuffer.allocate(netBufferSize);
     assertThat(
         nioSslEngine.ensureWrappedCapacity(10, buffer, Buffers.BufferType.UNTRACKED, mockStats))
             .isEqualTo(buffer);
   }
 
   @Test
+  public void ensureWrappedCapacityWithNoBuffer() {
+    assertThat(
+        nioSslEngine.ensureWrappedCapacity(10, null, Buffers.BufferType.UNTRACKED, mockStats)
+            .capacity())
+                .isEqualTo(netBufferSize);
+  }
+
+  @Test
   public void readAtLeast() throws Exception {
     final int amountToRead = 150;
     final int individualRead = 60;