Skip to content
This repository was archived by the owner on Jun 18, 2024. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@
<commons-logging.version>1.2</commons-logging.version>
<joda-time.version>2.8</joda-time.version>
<commons-lang3.version>3.4</commons-lang3.version>
<commons-io.version>2.4</commons-io.version>
<!-- Dependencies [TEST]: -->
<junit.version>4.12</junit.version>
<hamcrest-all.version>1.3</hamcrest-all.version>
Expand Down Expand Up @@ -175,6 +176,12 @@
<version>${httpcore.version}</version>
</dependency>

<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>${commons-io.version}</version>
</dependency>

<dependency>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@
import microsoft.exchange.webservices.data.misc.EwsTraceListener;
import microsoft.exchange.webservices.data.misc.ITraceListener;

import org.apache.commons.io.IOUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.http.client.AuthenticationStrategy;
Expand Down Expand Up @@ -264,19 +265,8 @@ private void initializeHttpContext() {

@Override
public void close() {
try {
httpClient.close();
} catch (IOException e) {
LOG.debug(e);
}

if (httpPoolingClient != null) {
try {
httpPoolingClient.close();
} catch (IOException e) {
LOG.debug(e);
}
}
IOUtils.closeQuietly(httpClient);
IOUtils.closeQuietly(httpPoolingClient);
}

// Event handlers
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
import microsoft.exchange.webservices.data.core.exception.xml.XmlException;
import microsoft.exchange.webservices.data.misc.HangingTraceStream;
import microsoft.exchange.webservices.data.security.XmlNodeType;
import org.apache.commons.io.IOUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

Expand Down Expand Up @@ -241,14 +242,7 @@ private void parseResponses() {
// Stream is closed, so disconnect.
this.disconnect(HangingRequestDisconnectReason.Exception, ex);
} finally {
if (responseCopy != null) {
try {
responseCopy.close();
responseCopy = null;
} catch (Exception ex) {
LOG.error(ex);
}
}
IOUtils.closeQuietly(responseCopy);
}
}

Expand All @@ -272,11 +266,7 @@ private void setIsConnected(boolean value) {
*/
public void disconnect() {
synchronized (this) {
try {
this.response.close();
} catch (IOException e) {
// Ignore exception on disconnection
}
IOUtils.closeQuietly(this.response);
this.disconnect(HangingRequestDisconnectReason.UserInitiated, null);
}
}
Expand All @@ -289,11 +279,7 @@ public void disconnect() {
*/
public void disconnect(HangingRequestDisconnectReason reason, Exception exception) {
if (this.isConnected()) {
try {
this.response.close();
} catch (IOException e) {
// Ignore exception on disconnection
}
IOUtils.closeQuietly(this.response);
this.internalOnDisconnect(reason, exception);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import microsoft.exchange.webservices.data.core.WebProxy;
import microsoft.exchange.webservices.data.core.exception.http.EWSHttpException;

import java.io.Closeable;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
Expand All @@ -36,7 +37,7 @@
/**
* The Class HttpWebRequest.
*/
public abstract class HttpWebRequest {
public abstract class HttpWebRequest implements Closeable {

/**
* The url.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
import microsoft.exchange.webservices.data.core.exception.xml.XmlException;
import microsoft.exchange.webservices.data.misc.SoapFaultDetails;
import microsoft.exchange.webservices.data.security.XmlNodeType;
import org.apache.commons.io.IOUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

Expand Down Expand Up @@ -644,12 +645,7 @@ protected HttpWebRequest validateAndEmitRequest() throws Exception {
throw new ServiceRequestException(String.format("The request failed. %s", e.getMessage()), e);
}
} catch (Exception e) {
try {
request.close();
} catch (Exception e2) {
// Ignore exception while closing the request.
}

IOUtils.closeQuietly(request);
throw e;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@
import microsoft.exchange.webservices.data.core.exception.service.local.ServiceValidationException;
import microsoft.exchange.webservices.data.core.exception.service.local.ServiceVersionException;

import org.apache.commons.io.IOUtils;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
Expand Down Expand Up @@ -234,11 +236,7 @@ public void load(String fileName) throws Exception {
this.load();
this.loadToStream.flush();
} finally {
try {
this.loadToStream.close();
} catch(Exception e) {
//ignore exception on close
}
IOUtils.closeQuietly(this.loadToStream);
this.loadToStream = null;
}

Expand Down