From 760a7b73657334e6b6af2ff553c055416f2df7c2 Mon Sep 17 00:00:00 2001 From: Stu Arnett Date: Fri, 23 Feb 2018 21:52:28 -0600 Subject: [PATCH] Release 2.2.0 (#6) * fix LB issues when hosts are created with no name * added automatic JSON marshalling via JAXB or POJO (using Jackson 1.9.13) --- build.gradle | 9 +++++++-- src/main/java/com/emc/rest/smart/Host.java | 1 + src/main/java/com/emc/rest/smart/SmartClientFactory.java | 9 ++++++--- 3 files changed, 14 insertions(+), 5 deletions(-) diff --git a/build.gradle b/build.gradle index b9b2c96..1b90644 100644 --- a/build.gradle +++ b/build.gradle @@ -37,10 +37,15 @@ buildscript { apply from: "$commonBuildDir/ecs-publish.gradle" dependencies { - compile 'com.sun.jersey:jersey-client:1.19.3', - 'com.sun.jersey.contribs:jersey-apache-client4:1.19.3', + compile 'com.sun.jersey:jersey-client:1.19.4', + 'com.sun.jersey.contribs:jersey-apache-client4:1.19.4', + 'org.codehaus.jackson:jackson-jaxrs:1.9.13', + 'org.codehaus.jackson:jackson-xc:1.9.13', 'org.apache.httpcomponents:httpclient:4.2.6', 'org.slf4j:slf4j-api:1.7.5' + compile('com.sun.jersey:jersey-json:1.19.4') { + exclude group: 'org.codehaus.jackson' + } runtime 'org.slf4j:slf4j-log4j12:1.7.5' testCompile 'junit:junit:4.12', 'log4j:log4j:1.2.17' diff --git a/src/main/java/com/emc/rest/smart/Host.java b/src/main/java/com/emc/rest/smart/Host.java index 4314929..45c5a74 100644 --- a/src/main/java/com/emc/rest/smart/Host.java +++ b/src/main/java/com/emc/rest/smart/Host.java @@ -64,6 +64,7 @@ public class Host implements HostStats { * @param name the host name or IP address of this host */ public Host(String name) { + if (name == null) throw new NullPointerException(); this.name = name; } diff --git a/src/main/java/com/emc/rest/smart/SmartClientFactory.java b/src/main/java/com/emc/rest/smart/SmartClientFactory.java index 2f5efac..14130c7 100644 --- a/src/main/java/com/emc/rest/smart/SmartClientFactory.java +++ b/src/main/java/com/emc/rest/smart/SmartClientFactory.java @@ -26,9 +26,6 @@ */ package com.emc.rest.smart; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - import com.sun.jersey.api.client.Client; import com.sun.jersey.api.client.ClientHandler; import com.sun.jersey.api.client.config.ClientConfig; @@ -39,6 +36,9 @@ import com.sun.jersey.core.impl.provider.entity.ByteArrayProvider; import com.sun.jersey.core.impl.provider.entity.FileProvider; import com.sun.jersey.core.impl.provider.entity.InputStreamProvider; +import org.codehaus.jackson.jaxrs.JacksonJaxbJsonProvider; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; public final class SmartClientFactory { @@ -105,6 +105,9 @@ public static Client createStandardClient(SmartConfig smartConfig, // add support for XML with no content-type clientConfig.getClasses().add(OctetStreamXmlProvider.class); + // add JSON support (using Jackson's ObjectMapper instead of JAXB marshalling) + clientConfig.getClasses().add(JacksonJaxbJsonProvider.class); + // build Jersey client return new Client(clientHandler, clientConfig); }