Skip to content

Commit

Permalink
修复客户端OOM问题. Fixed alibaba#25
Browse files Browse the repository at this point in the history
  • Loading branch information
jlusdy committed May 12, 2014
1 parent c73c64e commit 4c59969
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 4 deletions.
5 changes: 3 additions & 2 deletions src/main/java/com/taobao/profile/client/TProfilerClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -142,8 +142,9 @@ private static String getStatus(String command, String server, int port) {
private static String read(InputStream in) throws IOException {
BufferedInputStream bin = new BufferedInputStream(in);
StringBuffer sb = new StringBuffer();
while (true) {
char c = (char) bin.read();
int i;
while ((i = bin.read()) != -1) {
char c = (char) i;
if (c == '\r') {
break;
} else {
Expand Down
16 changes: 14 additions & 2 deletions src/main/java/com/taobao/profile/thread/InnerSocketThread.java
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,9 @@ public void run() {
private String read(InputStream in) throws IOException {
BufferedInputStream bin = new BufferedInputStream(in);
StringBuffer sb = new StringBuffer();
while (true) {
char c = (char) bin.read();
int i;
while ((i = bin.read()) != -1) {
char c = (char) i;
if (c == '\r') {
break;
} else {
Expand All @@ -110,4 +111,15 @@ private void write(OutputStream os) throws IOException {
out.write('\r');
out.flush();
}

/**
* 调试使用
*
* @param args
*/
public static void main(String[] args){
InnerSocketThread socketThread = new InnerSocketThread();
socketThread.setName("TProfiler-InnerSocket-Debug");
socketThread.start();
}
}

0 comments on commit 4c59969

Please sign in to comment.