mirror of
https://github.com/moparisthebest/davmail
synced 2025-01-07 11:48:02 -05:00
Fix regression in AbstractConnection: return null instead of empty string on closed connection
git-svn-id: http://svn.code.sf.net/p/davmail/code/trunk@1179 3d1905a2-6b24-0410-a738-b14d5a86fcbd
This commit is contained in:
parent
a702183d1a
commit
2cab4c6ded
@ -52,7 +52,7 @@ public class AbstractConnection extends Thread {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public String readLine() throws IOException {
|
public String readLine() throws IOException {
|
||||||
ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
ByteArrayOutputStream baos = null;
|
||||||
int b;
|
int b;
|
||||||
while ((b = read()) > -1) {
|
while ((b = read()) > -1) {
|
||||||
if (b == '\r') {
|
if (b == '\r') {
|
||||||
@ -64,13 +64,21 @@ public class AbstractConnection extends Thread {
|
|||||||
} else if (b == '\n') {
|
} else if (b == '\n') {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
if (baos == null) {
|
||||||
|
baos = new ByteArrayOutputStream();
|
||||||
|
}
|
||||||
baos.write(b);
|
baos.write(b);
|
||||||
}
|
}
|
||||||
return new String(baos.toByteArray(), encoding);
|
if (baos != null) {
|
||||||
|
return new String(baos.toByteArray(), encoding);
|
||||||
|
} else {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Read byteSize bytes from inputStream, return content as String.
|
* Read byteSize bytes from inputStream, return content as String.
|
||||||
|
*
|
||||||
* @param byteSize content size
|
* @param byteSize content size
|
||||||
* @return content
|
* @return content
|
||||||
* @throws IOException on error
|
* @throws IOException on error
|
||||||
@ -81,6 +89,7 @@ public class AbstractConnection extends Thread {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Read byteSize bytes from inputStream, return content as byte array.
|
* Read byteSize bytes from inputStream, return content as byte array.
|
||||||
|
*
|
||||||
* @param byteSize content size
|
* @param byteSize content size
|
||||||
* @return content
|
* @return content
|
||||||
* @throws IOException on error
|
* @throws IOException on error
|
||||||
|
Loading…
Reference in New Issue
Block a user