Fixed null pointer exception in case of IOException before uploading file to http host
This commit is contained in:
parent
aeda55ba7c
commit
c854f659db
1 changed files with 7 additions and 2 deletions
|
@ -97,6 +97,7 @@ public class HttpUploadConnection implements Transferable {
|
|||
|
||||
public void init(Message message, boolean delay) {
|
||||
this.message = message;
|
||||
this.message.setHttpUploaded(true);
|
||||
this.account = message.getConversation().getAccount();
|
||||
this.file = FileBackend.getFile(message, false);
|
||||
this.mime = this.file.getMimeType();
|
||||
|
@ -220,8 +221,12 @@ public class HttpUploadConnection implements Transferable {
|
|||
fail();
|
||||
}
|
||||
} catch (IOException e) {
|
||||
errorStream = connection.getErrorStream();
|
||||
Logging.e("httpupload", "http response: " + new Scanner(errorStream).useDelimiter("\\A").next() + ", exception message: " + e.getMessage());
|
||||
errorStream = (null != connection) ? connection.getErrorStream() : null;
|
||||
String httpResponseMessage = null;
|
||||
if (null != errorStream) {
|
||||
httpResponseMessage = new Scanner(errorStream).useDelimiter("\\A").next();
|
||||
}
|
||||
Logging.e("httpupload", ((null != httpResponseMessage) ? ("http response: " + httpResponseMessage + ", ") : "") + "exception message: " + e.getMessage());
|
||||
fail();
|
||||
} finally {
|
||||
StreamUtil.close(os);
|
||||
|
|
Loading…
Add table
Reference in a new issue