mirror of
https://github.com/moparisthebest/davmail
synced 2025-01-06 03:08: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 {
|
||||
ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
||||
ByteArrayOutputStream baos = null;
|
||||
int b;
|
||||
while ((b = read()) > -1) {
|
||||
if (b == '\r') {
|
||||
@ -64,13 +64,21 @@ public class AbstractConnection extends Thread {
|
||||
} else if (b == '\n') {
|
||||
break;
|
||||
}
|
||||
if (baos == null) {
|
||||
baos = new ByteArrayOutputStream();
|
||||
}
|
||||
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.
|
||||
*
|
||||
* @param byteSize content size
|
||||
* @return content
|
||||
* @throws IOException on error
|
||||
@ -81,6 +89,7 @@ public class AbstractConnection extends Thread {
|
||||
|
||||
/**
|
||||
* Read byteSize bytes from inputStream, return content as byte array.
|
||||
*
|
||||
* @param byteSize content size
|
||||
* @return content
|
||||
* @throws IOException on error
|
||||
|
Loading…
Reference in New Issue
Block a user