diff --git a/CHANGELOG.md b/CHANGELOG.md index 9de98f5f..f1649934 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,11 @@ # Splunk Enterprise SDK for Java Changelog +## Version 1.9.3 + +### Minor Changes +* Re-fetch logic for instancetype and version fields if not set within Service instance to avoid NPE (GitHub PR [#202](https://github.com/splunk/splunk-sdk-java/pull/202)) +* Check for local IP as alternative to _localhost_ within HostnameVerifier, addressing issue with certain local workflows + ## Version 1.9.2 ### New Features and APIs diff --git a/README.md b/README.md index f237d7ea..06883597 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ [![Java SDK Test](https://github.com/splunk/splunk-sdk-java/actions/workflows/test.yml/badge.svg?branch=master)](https://github.com/splunk/splunk-sdk-java/actions/workflows/test.yml) # The Splunk Software Development Kit for Java -#### Version 1.9.2 +#### Version 1.9.3 The Splunk Software Development Kit (SDK) for Java contains library code and examples designed to enable developers to build applications using Splunk. @@ -75,7 +75,7 @@ To add the Splunk SDK for Java `.JAR` file as a dependency: com.splunk splunk - 1.9.2 + 1.9.3 ``` diff --git a/deploy b/deploy index f30b59ad..3e42a2fd 100755 --- a/deploy +++ b/deploy @@ -2,7 +2,7 @@ declare -r scriptDirectory="$(dirname $(readlink -e $0))" declare -r scriptName="$(basename $0)" -declare -r version="1.9.2" +declare -r version="1.9.3" if [[ $# -ne 1 ]]; then echo 1>&2 "Usage: ${scriptName} {local|staging||production}" diff --git a/deploy.md b/deploy.md index 1fb9e68d..c43e6e41 100644 --- a/deploy.md +++ b/deploy.md @@ -9,8 +9,8 @@ deploy \ ##DESCRIPTION -Deploy transmits **target/splunk-1.9.2.jar**, **target/splunk-1.9.2-javadoc.jar**, and -**target/splunk-1.9.2-sources.jar** to the **local**, **staging**, or **production** +Deploy transmits **target/splunk-1.9.3.jar**, **target/splunk-1.9.3-javadoc.jar**, and +**target/splunk-1.9.3-sources.jar** to the **local**, **staging**, or **production** maven repository. Repository names are mapped to locations as follows. | repository-name | location | @@ -21,18 +21,18 @@ maven repository. Repository names are mapped to locations as follows. After deployment you should find this tree structure at the location of your repository - com/splunk/splunk/1.9.2/ - ├── splunk-1.9.2-javadoc.jar - ├── splunk-1.9.2-javadoc.jar.md5 - ├── splunk-1.9.2-javadoc.jar.sha1 - ├── splunk-1.9.2-sources.jar - ├── splunk-1.9.2-sources.jar.md5 - ├── splunk-1.9.2-sources.jar.sha1 - ├── splunk-1.9.2.jar - ├── splunk-1.9.2.jar.md5 - ├── splunk-1.9.2.jar.sha1 - ├── splunk-1.9.2.pom - ├── splunk-1.9.2.pom.md5 - └── splunk-1.9.2.pom.sha1 + com/splunk/splunk/1.9.3/ + ├── splunk-1.9.3-javadoc.jar + ├── splunk-1.9.3-javadoc.jar.md5 + ├── splunk-1.9.3-javadoc.jar.sha1 + ├── splunk-1.9.3-sources.jar + ├── splunk-1.9.3-sources.jar.md5 + ├── splunk-1.9.3-sources.jar.sha1 + ├── splunk-1.9.3.jar + ├── splunk-1.9.3.jar.md5 + ├── splunk-1.9.3.jar.sha1 + ├── splunk-1.9.3.pom + ├── splunk-1.9.3.pom.md5 + └── splunk-1.9.3.pom.sha1 Verify this structure prior to release. diff --git a/examples/pom.xml b/examples/pom.xml index 0a103858..03e16d1c 100644 --- a/examples/pom.xml +++ b/examples/pom.xml @@ -37,7 +37,7 @@ com.splunk splunk - 1.9.2 + 1.9.3 provided diff --git a/pom.xml b/pom.xml index 7518555a..9f1ac2f3 100644 --- a/pom.xml +++ b/pom.xml @@ -6,7 +6,7 @@ 4.0.0 - 1.9.2 + 1.9.3 true UTF-8 8 diff --git a/splunk/pom.xml b/splunk/pom.xml index 922cdab9..62823326 100644 --- a/splunk/pom.xml +++ b/splunk/pom.xml @@ -5,7 +5,7 @@ 4.0.0 splunk - 1.9.2 + 1.9.3 splunk-sdk-java com.splunk diff --git a/splunk/src/main/java/com/splunk/HttpService.java b/splunk/src/main/java/com/splunk/HttpService.java index d95f3d6e..696495fb 100644 --- a/splunk/src/main/java/com/splunk/HttpService.java +++ b/splunk/src/main/java/com/splunk/HttpService.java @@ -51,10 +51,11 @@ public class HttpService { private static String HTTPS_SCHEME = "https"; private static String HTTP_SCHEME = "http"; private static String HOSTNAME = "localhost"; + private static String HOSTIP = "127.0.0.1"; private static final HostnameVerifier HOSTNAME_VERIFIER = new HostnameVerifier() { public boolean verify(String s, SSLSession sslSession) { - if (s.equals(HOSTNAME)) { + if (s.equals(HOSTNAME) || s.equals(HOSTIP)) { return true; } else { HostnameVerifier hv = HttpsURLConnection.getDefaultHostnameVerifier(); @@ -89,7 +90,7 @@ public boolean verify(String s, SSLSession sslSession) { private String prefix = null; static Map defaultHeader = new HashMap() {{ - put("User-Agent", "splunk-sdk-java/1.9.2"); + put("User-Agent", "splunk-sdk-java/1.9.3"); put("Accept", "*/*"); }}; diff --git a/splunk/src/main/java/com/splunk/Service.java b/splunk/src/main/java/com/splunk/Service.java index d6d15b8f..05a5ae6d 100644 --- a/splunk/src/main/java/com/splunk/Service.java +++ b/splunk/src/main/java/com/splunk/Service.java @@ -1356,6 +1356,9 @@ public void setBearerToken(String value) { public boolean enableV2SearchApi(){ + if(null == this.instanceType){ + this.instanceType = this.getInfo().getInstanceType(); + } if(this.instanceType.equalsIgnoreCase("cloud")) { return versionIsAtLeast("9.0.2209"); }else{ @@ -1411,6 +1414,9 @@ boolean versionIsEarlierThan(String version) { * or 1 if this version is greater than the given version. */ public int versionCompare(String otherVersion) { + if(null == this.version){ + this.version = this.getInfo().getVersion(); + } String[] components1 = this.version.split("\\."); String[] components2 = otherVersion.split("\\."); int numComponents = Math.max(components1.length, components2.length); diff --git a/splunk/src/test/java/com/splunk/ServiceTest.java b/splunk/src/test/java/com/splunk/ServiceTest.java index ce9aafdf..a8960842 100644 --- a/splunk/src/test/java/com/splunk/ServiceTest.java +++ b/splunk/src/test/java/com/splunk/ServiceTest.java @@ -735,4 +735,19 @@ public void testEnableV2Api(){ } } + /* + Test when Service instance is created using token, it doesn't result in Null Pointer while accessing instanceType and version + */ + @Test + public void testServiceWithTokenAuth(){ + Service newService = new Service(service.getHost()); + newService.setToken(service.getToken()); + try{ + newService.enableV2SearchApi(); + newService.versionCompare("9.0.2"); + }catch (Exception ex){ + Assert.assertNull(ex); + } + } + }