From e10e0e7aa3f094883a50856eee5d7b024b2a4d2f Mon Sep 17 00:00:00 2001 From: Craig Andrews Date: Tue, 8 Sep 2015 15:07:40 -0400 Subject: [PATCH 01/19] Add checkstyle as part of the Maven build to ensure coding standards compliance --- pom.xml | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/pom.xml b/pom.xml index 54c06edaa..e54c32396 100644 --- a/pom.xml +++ b/pom.xml @@ -61,6 +61,7 @@ + 2.16 1.6 2.10.3 3.3 @@ -99,6 +100,34 @@ -Xdoclint:none + + + java-7-or-later-profile + + [1.7,) + + + + + org.apache.maven.plugins + maven-checkstyle-plugin + ${maven-checkstyle-plugin.version} + + true + google_checks.xml + + + + verify + + checkstyle + + + + + + + release-sign-artifacts From a4ce02170e79f54a71d2cc4d0311af936eba5b00 Mon Sep 17 00:00:00 2001 From: Craig Andrews Date: Tue, 8 Sep 2015 16:00:42 -0400 Subject: [PATCH 02/19] Use IOUtils.closeQuietly instead of reimplementing that method in each location Add a dependency on commons-io and use it appropriately. --- pom.xml | 7 ++++++ .../data/core/ExchangeServiceBase.java | 16 +++----------- .../request/HangingServiceRequestBase.java | 22 ++++--------------- .../data/core/request/HttpWebRequest.java | 3 ++- .../data/core/request/ServiceRequestBase.java | 8 ++----- .../data/property/complex/FileAttachment.java | 8 +++---- 6 files changed, 21 insertions(+), 43 deletions(-) diff --git a/pom.xml b/pom.xml index 54c06edaa..784d0f192 100644 --- a/pom.xml +++ b/pom.xml @@ -80,6 +80,7 @@ 1.2 2.8 3.4 + 2.4 4.12 1.3 @@ -175,6 +176,12 @@ ${httpcore.version} + + commons-io + commons-io + ${commons-io.version} + + commons-logging commons-logging diff --git a/src/main/java/microsoft/exchange/webservices/data/core/ExchangeServiceBase.java b/src/main/java/microsoft/exchange/webservices/data/core/ExchangeServiceBase.java index befc421f9..bb01858b4 100644 --- a/src/main/java/microsoft/exchange/webservices/data/core/ExchangeServiceBase.java +++ b/src/main/java/microsoft/exchange/webservices/data/core/ExchangeServiceBase.java @@ -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; @@ -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 diff --git a/src/main/java/microsoft/exchange/webservices/data/core/request/HangingServiceRequestBase.java b/src/main/java/microsoft/exchange/webservices/data/core/request/HangingServiceRequestBase.java index 4ecc9a92f..04db10e43 100644 --- a/src/main/java/microsoft/exchange/webservices/data/core/request/HangingServiceRequestBase.java +++ b/src/main/java/microsoft/exchange/webservices/data/core/request/HangingServiceRequestBase.java @@ -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; @@ -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); } } @@ -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); } } @@ -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); } } diff --git a/src/main/java/microsoft/exchange/webservices/data/core/request/HttpWebRequest.java b/src/main/java/microsoft/exchange/webservices/data/core/request/HttpWebRequest.java index edc2aef10..f8abec964 100644 --- a/src/main/java/microsoft/exchange/webservices/data/core/request/HttpWebRequest.java +++ b/src/main/java/microsoft/exchange/webservices/data/core/request/HttpWebRequest.java @@ -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; @@ -36,7 +37,7 @@ /** * The Class HttpWebRequest. */ -public abstract class HttpWebRequest { +public abstract class HttpWebRequest implements Closeable { /** * The url. diff --git a/src/main/java/microsoft/exchange/webservices/data/core/request/ServiceRequestBase.java b/src/main/java/microsoft/exchange/webservices/data/core/request/ServiceRequestBase.java index 073c2c2a1..101d6b104 100644 --- a/src/main/java/microsoft/exchange/webservices/data/core/request/ServiceRequestBase.java +++ b/src/main/java/microsoft/exchange/webservices/data/core/request/ServiceRequestBase.java @@ -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; @@ -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; } } diff --git a/src/main/java/microsoft/exchange/webservices/data/property/complex/FileAttachment.java b/src/main/java/microsoft/exchange/webservices/data/property/complex/FileAttachment.java index 5b6555c50..de3567f36 100644 --- a/src/main/java/microsoft/exchange/webservices/data/property/complex/FileAttachment.java +++ b/src/main/java/microsoft/exchange/webservices/data/property/complex/FileAttachment.java @@ -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; @@ -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; } From 757bd4d3f1966811e876b4b36a9c5a89c7f01413 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Behrens?= Date: Sun, 8 Nov 2015 10:37:48 +0100 Subject: [PATCH 03/19] increment version to 2.1 Version needs to be incremented for development on next snapshot release. [ci skip] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index b150d8daf..39b7a60a8 100644 --- a/pom.xml +++ b/pom.xml @@ -31,7 +31,7 @@ com.microsoft.ews-java-api ews-java-api - 2.0-SNAPSHOT + 2.1-SNAPSHOT Exchange Web Services Java API Exchange Web Services (EWS) Java API From afc45d09136882bdd85ca9f189ce24a05548eb3a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Behrens?= Date: Sun, 8 Nov 2015 11:21:04 +0100 Subject: [PATCH 04/19] Update readme.md extract documentation for gradle from readme.md and put it in the wiki --- readme.md | 51 ++------------------------------------------------- 1 file changed, 2 insertions(+), 49 deletions(-) diff --git a/readme.md b/readme.md index dbc64dfe9..c8378a1d6 100644 --- a/readme.md +++ b/readme.md @@ -7,55 +7,8 @@ Please see the [Getting Started Guide](https://github.com/OfficeDev/ews-java-api ## Using the library Prebuilt JARs are available in the Maven Central repository, which are easy to use with your project. Note that currently, no stable version is available yet, only snapshots in the snapshots repository. -### Maven -If you want to use a snapshot build, add the Maven Central snapshots repository to your project's `pom.xml`. If you want to use a stable build (not available yet), you should skip this step. -```xml - - - - sonatype-snapshots - Sonatype OSS Snapshots - https://oss.sonatype.org/content/repositories/snapshots/ - - false - - - true - - - - -``` - -And finally, add the dependency to your project's `pom.xml`. -```xml - - - - com.microsoft.ews-java-api - ews-java-api - 2.0-SNAPSHOT - - - -``` - -### Gradle -If you want to use a snapshot build, add the Maven Central snapshots repository to your project's `build.gradle`. If you want to use a stable build (not available yet), you should skip this step. -```groovy -repositories { - maven { - url 'https://oss.sonatype.org/content/repositories/snapshots/' - } -} -``` - -And finally, add the dependency to your project's `build.gradle`. -```groovy -dependencies { - compile 'com.microsoft.ews-java-api:ews-java-api:2.0-SNAPSHOT' -} -``` +### Maven / Gradle +For Documentation on how to use _ews-java-api_ with maven or gradle please refer to [this section in our wiki](https://github.com/OfficeDev/ews-java-api/wiki#maven--gradle-integration). ### Building from source To build a JAR from the source yourself, please see [this page](https://github.com/OfficeDev/ews-java-api/wiki/Building-EWS-JAVA-API). From ae3dc3e4ccd9345db30bb8e595e51f016e97d24a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Behrens?= Date: Sun, 8 Nov 2015 17:07:57 +0100 Subject: [PATCH 05/19] enable codecov.io support this PR enables our ci-server to evaluate code coverage and submit the resulting data to codecov.io --- .travis.yml | 1 + pom.xml | 21 +++++++++++++++++++++ readme.md | 3 ++- 3 files changed, 24 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index f9a9cf069..8baa6e401 100644 --- a/.travis.yml +++ b/.travis.yml @@ -52,3 +52,4 @@ before_install: after_success: - ./deploy_snapshot.sh + - bash <(curl -s https://codecov.io/bash) || echo "Codecov did not collect coverage reports" diff --git a/pom.xml b/pom.xml index 9ec56a577..e303359bc 100644 --- a/pom.xml +++ b/pom.xml @@ -94,6 +94,7 @@ 2.2 2.5 2.18.1 + 0.7.5.201505241946 4.4.1 4.4.1 @@ -368,6 +369,26 @@ + + + org.jacoco + jacoco-maven-plugin + ${jacoco-maven-plugin.version} + + + + prepare-agent + + + + report + test + + report + + + +