THRIFT-959. java: TSocket seems to do its own buffering inefficiently
authorBryan Duxbury <bryanduxbury@apache.org>
Wed, 20 Oct 2010 19:04:07 +0000 (19:04 +0000)
committerBryan Duxbury <bryanduxbury@apache.org>
Wed, 20 Oct 2010 19:04:07 +0000 (19:04 +0000)
This patch removes the buffering from TSocket. This seems to improve performance marginally on small reads and writes that are buffered elsewhere (like the Framed Transport).

git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@1025678 13f79535-47bb-0310-9956-ffa450edef68

lib/java/src/org/apache/thrift/transport/TSocket.java

index 606e8a9..6dd9efa 100644 (file)
 
 package org.apache.thrift.transport;
 
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.io.BufferedInputStream;
-import java.io.BufferedOutputStream;
 import java.io.IOException;
 import java.net.InetSocketAddress;
 import java.net.Socket;
 import java.net.SocketException;
 
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
 /**
  * Socket implementation of the TTransport interface. To be commented soon!
  *
@@ -74,8 +72,8 @@ public class TSocket extends TIOStreamTransport {
 
     if (isOpen()) {
       try {
-        inputStream_ = new BufferedInputStream(socket_.getInputStream(), 1024);
-        outputStream_ = new BufferedOutputStream(socket_.getOutputStream(), 1024);
+        inputStream_ = socket_.getInputStream();
+        outputStream_ = socket_.getOutputStream();
       } catch (IOException iox) {
         close();
         throw new TTransportException(TTransportException.NOT_OPEN, iox);
@@ -178,8 +176,8 @@ public class TSocket extends TIOStreamTransport {
 
     try {
       socket_.connect(new InetSocketAddress(host_, port_), timeout_);
-      inputStream_ = new BufferedInputStream(socket_.getInputStream(), 1024);
-      outputStream_ = new BufferedOutputStream(socket_.getOutputStream(), 1024);
+      inputStream_ = socket_.getInputStream();
+      outputStream_ = socket_.getOutputStream();
     } catch (IOException iox) {
       close();
       throw new TTransportException(TTransportException.NOT_OPEN, iox);