[ 
https://issues.apache.org/jira/browse/GEODE-8349?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17160012#comment-17160012
 ] 

ASF GitHub Bot commented on GEODE-8349:
---------------------------------------

bschuchardt commented on a change in pull request #5363:
URL: https://github.com/apache/geode/pull/5363#discussion_r456522212



##########
File path: 
geode-core/src/test/java/org/apache/geode/internal/net/SocketUtilsJUnitTest.java
##########
@@ -88,4 +95,86 @@ public void testCloseServerSocketThrowsIOException() throws 
IOException {
   public void testCloseServerSocketWithNull() {
     assertThat(SocketUtils.close((ServerSocket) null)).isTrue();
   }
+
+  @Test
+  public void readFromSocketWithHeapBuffer() throws IOException {
+    Socket socket = mock(Socket.class);
+    SocketChannel channel = mock(SocketChannel.class);
+    when(socket.getChannel()).thenReturn(channel);
+    final ByteBuffer buffer = ByteBuffer.allocate(100); // heap buffer
+    byte[] bytes = new byte[100];
+    InputStream stream = new ByteArrayInputStream(bytes);
+    when(channel.read(buffer)).thenAnswer((answer) -> {
+      buffer.put(bytes);
+      return buffer.position();
+    });
+    assertThat(buffer.hasArray()).isTrue();
+    SocketUtils.readFromSocket(socket, buffer, stream);
+    // the channel was used to read the bytes
+    verify(channel, times(1)).read(buffer);
+    // the buffer was filled
+    assertThat(buffer.position()).isEqualTo(bytes.length);
+    // the stream was not used
+    assertThat(stream.available()).isEqualTo(bytes.length);
+  }
+
+
+  @Test
+  public void readFromSocketWithDirectBuffer() throws IOException {
+    Socket socket = mock(Socket.class);
+    SocketChannel channel = mock(SocketChannel.class);
+    when(socket.getChannel()).thenReturn(channel);
+    final ByteBuffer buffer = ByteBuffer.allocateDirect(100); // non-heap 
buffer

Review comment:
       I don't like to factor out code in tests too much.  It leads to tests 
that are difficult to understand.  Short tests like this should be easy to read 
and stand on their own.




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


> reinstate use of SSLSocket for cluster communication
> ----------------------------------------------------
>
>                 Key: GEODE-8349
>                 URL: https://issues.apache.org/jira/browse/GEODE-8349
>             Project: Geode
>          Issue Type: Bug
>          Components: membership, messaging
>            Reporter: Bruce J Schuchardt
>            Assignee: Bruce J Schuchardt
>            Priority: Major
>              Labels: pull-request-available
>
> We've found problems with "new IO"'s SSLEngine with respect to support for 
> TLSV1.  We've also seen anomalous performance using that secure 
> communications mechanism.  The introduction of the use of the "new IO" 
> SSLEngine was originally to 1) reduce code complexity in the 
> org.apache.geode.internal.tcp package and 2) to set the stage for its use in 
> client/server communications so that selectors could be used in c/s 
> communications.
> This ticket aims to reintroduce the use of SSLSocket in cluster 
> communications without restoring the old, poorly tested SSL code paths.  The 
> new implementation should have as good or better performance than the 
> previous"old IO" implementation and the more recent "new IO" SSLEngine 
> implementation as well.  This should be apparent in the CI benchmark jobs.
>  
>  



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to