1 23 24 package org.continuent.sequoia.common.stream; 25 26 import java.io.BufferedInputStream ; 27 import java.io.IOException ; 28 import java.io.StreamCorruptedException ; 29 import java.net.Socket ; 30 31 import org.continuent.sequoia.driver.SequoiaUrl; 32 33 52 public class DriverBufferedInputStream 53 extends LongUTFDataInputStream 54 { 55 private Socket socket; 56 private long dateCreated; 57 private final int debugLevel; 58 59 62 protected void finalize() throws Throwable  63 { 64 try 65 { 66 70 if (!socket.isClosed()) 71 { 72 if (debugLevel >= SequoiaUrl.DEBUG_LEVEL_DEBUG) 73 { 74 System.err 75 .println("Socket was not closed, either someone forgot to" 76 + " call Connection.close() on " + socket); 77 System.err.println("or a finally { close(); } block is missing"); 78 } 79 80 socket.close(); 81 } 82 83 } 84 finally 85 { 86 super.finalize(); 87 } 88 } 89 90 95 public DriverBufferedInputStream(Socket clientSocket) throws IOException , 96 StreamCorruptedException  97 { 98 this(clientSocket, SequoiaUrl.DEBUG_LEVEL_OFF); 99 } 100 101 110 public DriverBufferedInputStream(Socket socket, int debugLevel) 111 throws IOException , StreamCorruptedException  112 { 113 super(new BufferedInputStream (socket.getInputStream())); 114 this.socket = socket; 115 this.debugLevel = debugLevel; 116 dateCreated = System.currentTimeMillis(); 117 } 118 119 122 public Socket getSocket() 123 { 124 return socket; 125 } 126 127 130 public long getDateCreated() 131 { 132 return dateCreated; 133 } 134 }
| Popular Tags
|