From 3db74be4cbc5d92ccc2b9ede781bc866e4a0cf78 Mon Sep 17 00:00:00 2001 From: Denis Vergnes Date: Tue, 3 Apr 2018 10:33:52 -0700 Subject: [PATCH 001/229] [DVPL-7313] Buffer storing the data before the first result xml tag is only limited by available memory in the JVM. --- .../InsertRootElementFilterInputStream.java | 74 ++++--- ...nsertRootElementFilterInputStreamTest.java | 184 +++++++++++++++++- 2 files changed, 231 insertions(+), 27 deletions(-) diff --git a/splunk/com/splunk/InsertRootElementFilterInputStream.java b/splunk/com/splunk/InsertRootElementFilterInputStream.java index 3d4da339..b668f850 100644 --- a/splunk/com/splunk/InsertRootElementFilterInputStream.java +++ b/splunk/com/splunk/InsertRootElementFilterInputStream.java @@ -16,9 +16,6 @@ package com.splunk; import java.io.*; -import java.nio.ByteBuffer; -import java.util.Arrays; -import java.util.concurrent.Callable; /** * Takes an InputStream containing a UTF-8 encoded XML document containing one or more @@ -31,22 +28,35 @@ * it is filtering. */ class InsertRootElementFilterInputStream extends FilterInputStream { + private static final int REREAD_BUFFER_SIZE = 512; + private static byte[] resultsTagBytes; private final ByteArrayInputStream suffix = new ByteArrayInputStream("".getBytes("UTF-8")); + private ByteArrayInputStream beforeResultsBuffer; private boolean wrotePrefix; private byte[] oneByte = new byte[1]; + static { + try { + resultsTagBytes = "results".getBytes("UTF-8"); + } catch (UnsupportedEncodingException e) { + //should not be thrown because UTF-8 is supported + throw new RuntimeException(e); + } + } + InsertRootElementFilterInputStream(InputStream in) throws IOException { // Wrap in with a pushback stream so we can write our modified version back // onto the beginning of it. - super(new PushbackInputStream(in, 512)); + super(new PushbackInputStream(in, REREAD_BUFFER_SIZE)); + PushbackInputStream pin = (PushbackInputStream)this.in; // Read bytes until we reach '>', then push everything we read, followed by "", // back onto the stream. If we run out of input before we reach '>', then don't // modify the stream. ByteArrayOutputStream beforeResultsChars = new ByteArrayOutputStream(); - ByteArrayOutputStream atResultsChars = new ByteArrayOutputStream(); + beforeResultsBuffer = new ByteArrayInputStream(new byte[0]); int ch; while (true) { @@ -57,32 +67,19 @@ class InsertRootElementFilterInputStream extends FilterInputStream { pin.unread(beforeResultsChars.toByteArray()); return; } else if (ch == (int)'<') { - // Try extending - atResultsChars.reset(); - int ech; - boolean matched = true; - for (byte b : "results".getBytes("UTF-8")) { - ech = this.in.read(); - atResultsChars.write(ech); - if (ech != b) { - // Extension failed. Put the bytes back on and search again. - pin.unread(atResultsChars.toByteArray()); - matched = false; - break; - } - } + boolean resultsTag = isResultsTag(pin); - if (matched) { + if (resultsTag) { // If we reach here, the extension succeeded, so we insert , unread everything, // and return. // Unread the match. - pin.unread(atResultsChars.toByteArray()); + pin.unread(InsertRootElementFilterInputStream.resultsTagBytes); // Unread the opening '<' that led to our extension pin.unread(ch); - // Add a '' element to our read charactes and unread them. + // Add a '' element to our read characters beforeResultsChars.write("".getBytes("UTF-8")); - pin.unread(beforeResultsChars.toByteArray()); + beforeResultsBuffer = new ByteArrayInputStream(beforeResultsChars.toByteArray()); wrotePrefix = true; return; } else { @@ -96,9 +93,38 @@ class InsertRootElementFilterInputStream extends FilterInputStream { } } + private boolean isResultsTag(PushbackInputStream pin) throws IOException { + // Try extending + ByteArrayOutputStream atResultsChars = new ByteArrayOutputStream(); + int ech; + boolean resultsTag = true; + for (byte b : resultsTagBytes) { + ech = this.in.read(); + atResultsChars.write(ech); + if (ech != b) { + // Extension failed. Put the bytes back on and search again. + pin.unread(atResultsChars.toByteArray()); + resultsTag = false; + break; + } + } + return resultsTag; + } + @Override public int read(byte[] buffer, int offset, int length) throws IOException { - int result = in.read(buffer, offset, length); + // first we read from the buffer before the first results xml tag + int result = 0; + int availableFromBuffer = beforeResultsBuffer.available(); + if (offset < availableFromBuffer) { + result = beforeResultsBuffer.read(buffer, offset, length); + if (length <= result) { + return result; + } + } + + // then we read from the original input stream + result += in.read(buffer, offset+result, length-result); if (result == -1 && wrotePrefix) { // No more bytes to read from in, and we have written '' earlier in the stream return suffix.read(buffer, offset, length); diff --git a/tests/com/splunk/InsertRootElementFilterInputStreamTest.java b/tests/com/splunk/InsertRootElementFilterInputStreamTest.java index 868a911d..b6bc37ab 100644 --- a/tests/com/splunk/InsertRootElementFilterInputStreamTest.java +++ b/tests/com/splunk/InsertRootElementFilterInputStreamTest.java @@ -48,12 +48,190 @@ public void testNoDtd() throws IOException { } @Test - public void testNoResultsElement() throws IOException { - InputStream stream = new ByteArrayInputStream("boris the mad baboon".getBytes("UTF-8")); + public void testNoXml() throws IOException { + String input = "boris the mad baboon"; + InputStream stream = new ByteArrayInputStream(input.getBytes("UTF-8")); InputStream filteredStream = new InsertRootElementFilterInputStream(stream); String found = SDKTestCase.streamToString(filteredStream); - String expected = "boris the mad baboon"; + + Assert.assertEquals(input, found); + } + + @Test + public void testNoResults() throws IOException { + String input = ""; + InputStream stream = new ByteArrayInputStream(input.getBytes("UTF-8")); + InputStream filteredStream = new InsertRootElementFilterInputStream(stream); + + String found = SDKTestCase.streamToString(filteredStream); + + Assert.assertEquals(input, found); + } + + @Test + public void testBigPreambleBeforeResults() throws IOException { + InputStream stream = new ByteArrayInputStream(("" + + "" + + " " + + " " + + " " + + " " + + " " + + " " + + " " + + " " + + " " + + " " + + " " + + " " + + " " + + " " + + " " + + " " + + " " + + " " + + " " + + " " + + " " + + " " + + " " + + " " + + " " + + " " + + " " + + " " + + " " + + " " + + " " + + " " + + " " + + " " + + " " + + " " + + " " + + " " + + " " + + " " + + " " + + " " + + " " + + " " + + " " + + " " + + " " + + " " + + " " + + " " + + " " + + " " + + " " + + " " + + " " + + " " + + " " + + " " + + " " + + " " + + " " + + " " + + " " + + " " + + " " + + " " + + " " + + " " + + " " + + " " + + " " + + " " + + " " + + " " + + " " + + " " + + "").getBytes("UTF-8")); + InputStream filteredStream = new InsertRootElementFilterInputStream(stream); + + String found = SDKTestCase.streamToString(filteredStream); + String expected = "" + + "" + + " " + + " " + + " " + + " " + + " " + + " " + + " " + + " " + + " " + + " " + + " " + + " " + + " " + + " " + + " " + + " " + + " " + + " " + + " " + + " " + + " " + + " " + + " " + + " " + + " " + + " " + + " " + + " " + + " " + + " " + + " " + + " " + + " " + + " " + + " " + + " " + + " " + + " " + + " " + + " " + + " " + + " " + + " " + + " " + + " " + + " " + + " " + + " " + + " " + + " " + + " " + + " " + + " " + + " " + + " " + + " " + + " " + + " " + + " " + + " " + + " " + + " " + + " " + + " " + + " " + + " " + + " " + + " " + + " " + + " " + + " " + + " " + + " " + + " " + + " " + + " " + + ""; Assert.assertEquals(expected, found); } From e5a2e53ede3a93d76710a5ce852b40284e2dbd9a Mon Sep 17 00:00:00 2001 From: apruneda Date: Thu, 7 Jun 2018 12:49:32 -0700 Subject: [PATCH 002/229] Updated the readme.md Updated the Support policy. --- README.md | 28 ++++++++-------------------- 1 file changed, 8 insertions(+), 20 deletions(-) diff --git a/README.md b/README.md index 19f64794..38d7a68a 100644 --- a/README.md +++ b/README.md @@ -383,28 +383,16 @@ If you would like to contribute to the SDK, go here for more information: ### Support -1. You will be granted support if you or your company are already covered - under an existing maintenance/support agreement. Send an email to - _support@splunk.com_ and include "Splunk SDK for Java" in the subject line. - -2. If you are not covered under an existing maintenance/support agreement, you - can find help through the broader community at: - - -3. Splunk will NOT provide support for SDKs if the core library (the - code in the splunk directory) has been modified. If you modify an SDK - and want support, you can find help through the broader community and Splunk - answers (see above). We would also like to know why you modified the core - library—please send feedback to _devinfo@splunk.com_. -4. File any issues on [GitHub](https://github.com/splunk/splunk-sdk-java/issues). +Beginning September 2018, the Splunk SDKs for C#, Java, JavaScript, and Python will no longer be supported through Splunk Support. +You can still request assistance using the following options: +* Post questions to [Splunk Answers](http://splunk-base.splunk.com/answers/). Be sure to use tags to identify the SDK or tool you are having an issue with. + +* File an issue on [GitHub](https://github.com/splunk/). + +* Send feedback to _devinfo@splunk.com_. + ### Contact Us You can reach the Developer Platform team at _devinfo@splunk.com_. From a6d7e9c002352f2291cd46740266376ef1e8ed7b Mon Sep 17 00:00:00 2001 From: Sharad Kylasam Date: Thu, 13 Sep 2018 11:27:44 -0700 Subject: [PATCH 003/229] Modify the support statement in README as requested. --- README.md | 26 +++++++++++++++++--------- 1 file changed, 17 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index 38d7a68a..2a25ca24 100644 --- a/README.md +++ b/README.md @@ -383,15 +383,23 @@ If you would like to contribute to the SDK, go here for more information: ### Support -Beginning September 2018, the Splunk SDKs for C#, Java, JavaScript, and Python will no longer be supported through Splunk Support. - -You can still request assistance using the following options: - -* Post questions to [Splunk Answers](http://splunk-base.splunk.com/answers/). Be sure to use tags to identify the SDK or tool you are having an issue with. - -* File an issue on [GitHub](https://github.com/splunk/). - -* Send feedback to _devinfo@splunk.com_. +1. You will be granted support if you or your company are already covered under an existing maintenance/support agreement. + Send an email to support@splunk.com and include "Splunk SDK for Java" in the subject line. +2. If you are not covered under an existing maintenance/support agreement, you + can find help through the broader community at: + +3. Splunk will NOT provide support for SDKs if the core library (the + code in the splunk directory) has been modified. If you modify an SDK + and want support, you can find help through the broader community and Splunk + answers (see above). We would also like to know why you modified the core + library—please send feedback to devinfo@splunk.com. +4. File any issues on [GitHub](https://github.com/splunk/splunk-sdk-java/issues). ### Contact Us From b10f671808c99aaaba31531bf3ad8bd0676b58cf Mon Sep 17 00:00:00 2001 From: Shakeel Mohamed Date: Tue, 30 Oct 2018 15:52:35 -0700 Subject: [PATCH 004/229] Run CI against Splunk 7.2 --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index c819cc0d..1c60f1fa 100644 --- a/.travis.yml +++ b/.travis.yml @@ -28,8 +28,8 @@ before_install: - sleep 30 env: - - SPLUNK_VERSION=6.6-sdk - SPLUNK_VERSION=7.0-sdk + - SPLUNK_VERSION=7.2-sdk language: java From 02274ba97ac25a95bc1403483dd853757153581c Mon Sep 17 00:00:00 2001 From: Shakeel Mohamed Date: Tue, 30 Oct 2018 16:50:26 -0700 Subject: [PATCH 005/229] fix invalid crontab in test --- tests/com/splunk/DataModelTest.java | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/tests/com/splunk/DataModelTest.java b/tests/com/splunk/DataModelTest.java index 5d1a8bc6..0054bb36 100644 --- a/tests/com/splunk/DataModelTest.java +++ b/tests/com/splunk/DataModelTest.java @@ -173,14 +173,17 @@ public void testAccelerationSettings() { args.setRawJsonDescription(streamToString(openResource("data/datamodels/data_model_with_test_objects.json"))); DataModel model = dataModels.create(createTemporaryName(), args); + final String crontabA = "*/5 * * * *"; + final String crontabB = "* * * * *"; + model.setAcceleration(true); model.setEarliestAcceleratedTime("-2mon"); - model.setAccelerationCronSchedule("5/* * * * *"); + model.setAccelerationCronSchedule(crontabA); model.update(); Assert.assertTrue(model.isAccelerated()); Assert.assertEquals("-2mon", model.getEarliestAcceleratedTime()); - Assert.assertEquals("5/* * * * *", model.getAccelerationCronSchedule()); + Assert.assertEquals(crontabA, model.getAccelerationCronSchedule()); Assert.assertFalse(model.isManualRebuilds()); model.update(); // An empty update should also work @@ -188,17 +191,17 @@ public void testAccelerationSettings() { Assert.assertTrue(model.isAccelerated()); Assert.assertEquals("-2mon", model.getEarliestAcceleratedTime()); - Assert.assertEquals("5/* * * * *", model.getAccelerationCronSchedule()); + Assert.assertEquals(crontabA, model.getAccelerationCronSchedule()); Assert.assertFalse(model.isManualRebuilds()); model.setAcceleration(false); model.setEarliestAcceleratedTime("-1mon"); - model.setAccelerationCronSchedule("* * * * *"); + model.setAccelerationCronSchedule(crontabB); model.update(); Assert.assertFalse(model.isAccelerated()); Assert.assertEquals("-1mon", model.getEarliestAcceleratedTime()); - Assert.assertEquals("* * * * *", model.getAccelerationCronSchedule()); + Assert.assertEquals(crontabB, model.getAccelerationCronSchedule()); Assert.assertFalse(model.isManualRebuilds()); model.setManualRebuilds(true); @@ -206,7 +209,7 @@ public void testAccelerationSettings() { Assert.assertFalse(model.isAccelerated()); Assert.assertEquals("-1mon", model.getEarliestAcceleratedTime()); - Assert.assertEquals("* * * * *", model.getAccelerationCronSchedule()); + Assert.assertEquals(crontabB, model.getAccelerationCronSchedule()); Assert.assertTrue(model.isManualRebuilds()); } From 835ad6d29507ecb5529474460d6b58439f3010b4 Mon Sep 17 00:00:00 2001 From: Shakeel Mohamed Date: Tue, 30 Oct 2018 17:13:25 -0700 Subject: [PATCH 006/229] fix javadoc error --- splunk/com/splunk/Args.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/splunk/com/splunk/Args.java b/splunk/com/splunk/Args.java index d682a685..4e93f36a 100644 --- a/splunk/com/splunk/Args.java +++ b/splunk/com/splunk/Args.java @@ -28,7 +28,7 @@ * * This extension is used mainly for encoding arguments for UTF8 transmission * to a Splunk instance in a key=value pairing for a string, or - * key=value1&key=value2 (and so on) for an array of strings. + * {@code key=value1&key=value2 } (and so on) for an array of strings. */ public class Args extends LinkedHashMap { From 38a7696df56629911d64e3f710935634c3470e53 Mon Sep 17 00:00:00 2001 From: Liying Jiang Date: Mon, 26 Nov 2018 15:08:06 -0800 Subject: [PATCH 007/229] update version to 1.6.5 --- CHANGELOG.md | 6 ++++++ README.md | 2 +- build.xml | 2 +- deploy | 2 +- deploy.md | 30 +++++++++++++++--------------- splunk/com/splunk/HttpService.java | 2 +- 6 files changed, 25 insertions(+), 19 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5df81271..57ee2ec1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,11 @@ # Splunk SDK for Java Changelog +## Version 1.6.5 + +### Bug Fixes + +* Fixed bug for push back buffer is full when exporting data in XML (GitHub PR [#125](https://github.com/splunk/splunk-sdk-java/pull/125)). + ## Version 1.6.4 ### Bug Fixes diff --git a/README.md b/README.md index 19f64794..914502b4 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ [![Build Status](https://travis-ci.org/splunk/splunk-sdk-java.svg?branch=master)](https://travis-ci.org/splunk/splunk-sdk-java) # The Splunk Software Development Kit for Java -#### Version 1.6.4 +#### Version 1.6.5 The Splunk Software Development Kit (SDK) for Java contains library code and examples designed to enable developers to build applications using Splunk. diff --git a/build.xml b/build.xml index 401628bf..5a96829d 100644 --- a/build.xml +++ b/build.xml @@ -18,7 +18,7 @@ - + diff --git a/deploy b/deploy index 51348fe1..bf56c132 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.6.4" +declare -r version="1.6.5" if [[ $# -ne 1 ]]; then echo 1>&2 "Usage: ${scriptName} {local|staging||production}" diff --git a/deploy.md b/deploy.md index 3ca67547..253bf780 100644 --- a/deploy.md +++ b/deploy.md @@ -9,8 +9,8 @@ deploy \ ##DESCRIPTION -Deploy transmits **dist/splunk-1.6.4.jar**, **dist/splunk-1.6.4-javadoc.jar**, and -**dist/splunk-1.6.4-sources.jar** to the **local**, **staging**, or **production** +Deploy transmits **dist/splunk-1.6.5.jar**, **dist/splunk-1.6.5-javadoc.jar**, and +**dist/splunk-1.6.5-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.6.4/ - ├── splunk-1.6.4-javadoc.jar - ├── splunk-1.6.4-javadoc.jar.md5 - ├── splunk-1.6.4-javadoc.jar.sha1 - ├── splunk-1.6.4-sources.jar - ├── splunk-1.6.4-sources.jar.md5 - ├── splunk-1.6.4-sources.jar.sha1 - ├── splunk-1.6.4.jar - ├── splunk-1.6.4.jar.md5 - ├── splunk-1.6.4.jar.sha1 - ├── splunk-1.6.4.pom - ├── splunk-1.6.4.pom.md5 - └── splunk-1.6.4.pom.sha1 + com/splunk/splunk/1.6.5/ + ├── splunk-1.6.5-javadoc.jar + ├── splunk-1.6.5-javadoc.jar.md5 + ├── splunk-1.6.5-javadoc.jar.sha1 + ├── splunk-1.6.5-sources.jar + ├── splunk-1.6.5-sources.jar.md5 + ├── splunk-1.6.5-sources.jar.sha1 + ├── splunk-1.6.5.jar + ├── splunk-1.6.5.jar.md5 + ├── splunk-1.6.5.jar.sha1 + ├── splunk-1.6.5.pom + ├── splunk-1.6.5.pom.md5 + └── splunk-1.6.5.pom.sha1 Verify this structure prior to release. diff --git a/splunk/com/splunk/HttpService.java b/splunk/com/splunk/HttpService.java index 1e66485b..a66cb5f2 100644 --- a/splunk/com/splunk/HttpService.java +++ b/splunk/com/splunk/HttpService.java @@ -73,7 +73,7 @@ public boolean verify(String s, SSLSession sslSession) { private String prefix = null; static Map defaultHeader = new HashMap() {{ - put("User-Agent", "splunk-sdk-java/1.6.4"); + put("User-Agent", "splunk-sdk-java/1.6.5"); put("Accept", "*/*"); }}; From 175ccfeb18a40bb388af6dc00c38c8e11c866a8b Mon Sep 17 00:00:00 2001 From: Shakeel Mohamed Date: Wed, 5 Dec 2018 15:26:19 -0800 Subject: [PATCH 008/229] Fix datamodel test causing crash --- tests/com/splunk/DataModelTest.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tests/com/splunk/DataModelTest.java b/tests/com/splunk/DataModelTest.java index 0054bb36..2aad204e 100644 --- a/tests/com/splunk/DataModelTest.java +++ b/tests/com/splunk/DataModelTest.java @@ -205,6 +205,8 @@ public void testAccelerationSettings() { Assert.assertFalse(model.isManualRebuilds()); model.setManualRebuilds(true); + // Acceleration must be set, or splunkd will crash + model.setAcceleration(false); model.update(); Assert.assertFalse(model.isAccelerated()); From 6916b4edd90f301eec8256b8b522c5ba13aafb15 Mon Sep 17 00:00:00 2001 From: Shakeel Mohamed Date: Thu, 6 Dec 2018 10:18:49 -0800 Subject: [PATCH 009/229] add sleep to uploadtest so splunkd.log will exist in CI --- tests/com/splunk/UploadTest.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/tests/com/splunk/UploadTest.java b/tests/com/splunk/UploadTest.java index 2f728722..30db1c3c 100644 --- a/tests/com/splunk/UploadTest.java +++ b/tests/com/splunk/UploadTest.java @@ -20,7 +20,10 @@ public class UploadTest extends SDKTestCase { @Test - public void testOneshot() { + public void testOneshot() throws InterruptedException { + // Slow down for CI to wait for splunkd.log to exist + Thread.sleep(3000); + String filename = locateSystemLog(); if (System.getenv("SPLUNK_HOME") != null) { filename = System.getenv("SPLUNK_HOME") + "/var/log/splunk/splunkd.log"; From 3d6d7d55811e21026c38e75927ab2481fe1dcca8 Mon Sep 17 00:00:00 2001 From: Shakeel Mohamed Date: Thu, 6 Dec 2018 10:31:52 -0800 Subject: [PATCH 010/229] Increase UploadTest timeout to 8s --- tests/com/splunk/UploadTest.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/com/splunk/UploadTest.java b/tests/com/splunk/UploadTest.java index 30db1c3c..bf5026bd 100644 --- a/tests/com/splunk/UploadTest.java +++ b/tests/com/splunk/UploadTest.java @@ -22,7 +22,7 @@ public class UploadTest extends SDKTestCase { @Test public void testOneshot() throws InterruptedException { // Slow down for CI to wait for splunkd.log to exist - Thread.sleep(3000); + Thread.sleep(8000); String filename = locateSystemLog(); if (System.getenv("SPLUNK_HOME") != null) { From ea33de25a99e022e70ece60371e23aeee7f4e627 Mon Sep 17 00:00:00 2001 From: PKing70 <39703314+PKing70@users.noreply.github.com> Date: Wed, 13 Feb 2019 12:12:44 -0800 Subject: [PATCH 011/229] Remove specification of Java SE To resolve DVPL-7494 --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index d6009eb7..406181be 100644 --- a/README.md +++ b/README.md @@ -51,8 +51,8 @@ If you want to contribute to the SDK, clone the repository from [GitHub](https:/ #### Java and Ant -You'll need Java SE version 6 or higher, which you can download from the -[Oracle web site](http://www.oracle.com/technetwork/java/javase/downloads/index.html). +You'll need Java version 6 or higher, which you can download from the +[Oracle web site](https://www.oracle.com/technetwork/java/index.html). You'll also need Ant, which you can install from the [Apache website](http://ant.apache.org/bindownload.cgi). From 330ff19a6a8dad2d814d2bf173ca44447d293d8a Mon Sep 17 00:00:00 2001 From: PKing70 <39703314+PKing70@users.noreply.github.com> Date: Thu, 28 Mar 2019 11:27:00 -0700 Subject: [PATCH 012/229] Feedback re Java https://jira.splunk.com/browse/DVPL-7494 No links to specific Java platforms --- README.md | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/README.md b/README.md index 406181be..7ad12d7c 100644 --- a/README.md +++ b/README.md @@ -51,8 +51,7 @@ If you want to contribute to the SDK, clone the repository from [GitHub](https:/ #### Java and Ant -You'll need Java version 6 or higher, which you can download from the -[Oracle web site](https://www.oracle.com/technetwork/java/index.html). +You'll need Java version 6 or higher, from OpenJDK or Oracle. You'll also need Ant, which you can install from the [Apache website](http://ant.apache.org/bindownload.cgi). From 4e472f1812501359bf5e0777e62ecacdeda7f5b1 Mon Sep 17 00:00:00 2001 From: PKing70 <39703314+PKing70@users.noreply.github.com> Date: Thu, 28 Mar 2019 11:31:57 -0700 Subject: [PATCH 013/229] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 7ad12d7c..72d94293 100644 --- a/README.md +++ b/README.md @@ -51,7 +51,7 @@ If you want to contribute to the SDK, clone the repository from [GitHub](https:/ #### Java and Ant -You'll need Java version 6 or higher, from OpenJDK or Oracle. +You'll need Java version 6 or higher, from [OpenJDK](https://openjdk.java.net) or [Oracle](https://www.oracle.com/technetwork/java). You'll also need Ant, which you can install from the [Apache website](http://ant.apache.org/bindownload.cgi). From 85b9fd6be285e034753792bde12f094dbd2d1c32 Mon Sep 17 00:00:00 2001 From: PKing70 <39703314+PKing70@users.noreply.github.com> Date: Thu, 11 Apr 2019 10:41:12 -0700 Subject: [PATCH 014/229] Revise README Add Java and Splunk versions tested for compatibility https://jira.splunk.com/browse/DVPL-7485 --- README.md | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 19f64794..32c89c72 100644 --- a/README.md +++ b/README.md @@ -40,7 +40,7 @@ Here's what you need to get going with the Splunk SDK for Java. If you haven't already installed Splunk, download it [here](http://www.splunk.com/download). For more about installing and running Splunk and system requirements, see -[Installing & Running Splunk](http://dev.splunk.com/view/SP-CAAADRV). +[Installing & Running Splunk](http://dev.splunk.com/view/SP-CAAADRV). The Splunk SDK for Java has been tested with Splunk Enterprise 6.6 and 7.0. #### Splunk SDK for Java @@ -51,8 +51,7 @@ If you want to contribute to the SDK, clone the repository from [GitHub](https:/ #### Java and Ant -You'll need Java SE version 6 or higher, which you can download from the -[Oracle web site](http://www.oracle.com/technetwork/java/javase/downloads/index.html). +You'll need Java version 7 or higher, from [OpenJDK](https://openjdk.java.net) or [Oracle](https://www.oracle.com/technetwork/java). The Splunk SDK for Java has been tested with OpenJDK v7 and v8, and Oracle JDK v7 and v8. You'll also need Ant, which you can install from the [Apache website](http://ant.apache.org/bindownload.cgi). From cbe37770e0b38ca5d2bc4ee969fb1d2859930206 Mon Sep 17 00:00:00 2001 From: PKing70 <39703314+PKing70@users.noreply.github.com> Date: Mon, 22 Apr 2019 15:58:03 -0700 Subject: [PATCH 015/229] Remove Splunkdev Google group link Per https://jira.splunk.com/browse/APPLAT-5544 --- README.md | 2 -- 1 file changed, 2 deletions(-) diff --git a/README.md b/README.md index d6009eb7..75c567bf 100644 --- a/README.md +++ b/README.md @@ -391,8 +391,6 @@ If you would like to contribute to the SDK, go here for more information:
  • Splunk Answers (use the sdk, java, python, and javascript tags to identify your questions)
  • -
  • Splunkdev Google - Group
  • 3. Splunk will NOT provide support for SDKs if the core library (the code in the splunk directory) has been modified. If you modify an SDK From 6f543e5ba1f42b4340c064e8e9b37181956cf965 Mon Sep 17 00:00:00 2001 From: Shakeel Mohamed Date: Mon, 13 May 2019 13:24:50 -0700 Subject: [PATCH 016/229] fix uploadtest --- tests/com/splunk/UploadTest.java | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/tests/com/splunk/UploadTest.java b/tests/com/splunk/UploadTest.java index bf5026bd..2ce4d965 100644 --- a/tests/com/splunk/UploadTest.java +++ b/tests/com/splunk/UploadTest.java @@ -18,17 +18,27 @@ import org.junit.Test; +import java.io.File; +import java.io.FileWriter; +import java.io.IOException; +import java.util.Date; + public class UploadTest extends SDKTestCase { @Test - public void testOneshot() throws InterruptedException { - // Slow down for CI to wait for splunkd.log to exist - Thread.sleep(8000); - + public void testOneshot() throws IOException { String filename = locateSystemLog(); - if (System.getenv("SPLUNK_HOME") != null) { + if (System.getenv("TRAVIS_CI") != null) { + File tempfile = File.createTempFile((new Date()).toString(), ""); + tempfile.deleteOnExit(); + + FileWriter f = new FileWriter(tempfile, true); + f.append("some data here"); + + filename = tempfile.getAbsolutePath(); + } + else if (System.getenv("SPLUNK_HOME") != null) { filename = System.getenv("SPLUNK_HOME") + "/var/log/splunk/splunkd.log"; } - service.getUploads().create(filename); for (Upload oneshot : service.getUploads().values()) { From e4a7c31a4a489a8fd447c80f86c1a483f8b3bb51 Mon Sep 17 00:00:00 2001 From: Shakeel Mohamed Date: Mon, 13 May 2019 13:47:22 -0700 Subject: [PATCH 017/229] Ensure index tests restart before exiting --- tests/com/splunk/IndexTest.java | 3 +++ tests/com/splunk/UploadTest.java | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/tests/com/splunk/IndexTest.java b/tests/com/splunk/IndexTest.java index 5655a44b..5491a7af 100644 --- a/tests/com/splunk/IndexTest.java +++ b/tests/com/splunk/IndexTest.java @@ -59,6 +59,9 @@ public void tearDown() throws Exception { // Can't delete indexes via the REST API. Just let them build up. } + // At least in CI the test exists with a required restart + super.splunkRestart(); + super.tearDown(); } diff --git a/tests/com/splunk/UploadTest.java b/tests/com/splunk/UploadTest.java index 2ce4d965..ed29e29c 100644 --- a/tests/com/splunk/UploadTest.java +++ b/tests/com/splunk/UploadTest.java @@ -27,7 +27,7 @@ public class UploadTest extends SDKTestCase { @Test public void testOneshot() throws IOException { String filename = locateSystemLog(); - if (System.getenv("TRAVIS_CI") != null) { + if (System.getenv("TRAVIS") != null) { File tempfile = File.createTempFile((new Date()).toString(), ""); tempfile.deleteOnExit(); From 5c82c565f4c2f08052a42e5afc7b0411b7cb1d55 Mon Sep 17 00:00:00 2001 From: Shakeel Mohamed Date: Mon, 13 May 2019 14:08:33 -0700 Subject: [PATCH 018/229] index tests should restart regardlesss of requirement to --- tests/com/splunk/IndexTest.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/com/splunk/IndexTest.java b/tests/com/splunk/IndexTest.java index 5491a7af..632fd879 100644 --- a/tests/com/splunk/IndexTest.java +++ b/tests/com/splunk/IndexTest.java @@ -60,7 +60,7 @@ public void tearDown() throws Exception { } // At least in CI the test exists with a required restart - super.splunkRestart(); + uncheckedSplunkRestart(); super.tearDown(); } From 48cf1a822df938d7c4b37d16a6d4d0ea82b6013c Mon Sep 17 00:00:00 2001 From: Shakeel Mohamed Date: Mon, 13 May 2019 14:26:50 -0700 Subject: [PATCH 019/229] use better format for temp files in UploadTest --- tests/com/splunk/UploadTest.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/com/splunk/UploadTest.java b/tests/com/splunk/UploadTest.java index ed29e29c..d30856d3 100644 --- a/tests/com/splunk/UploadTest.java +++ b/tests/com/splunk/UploadTest.java @@ -28,7 +28,7 @@ public class UploadTest extends SDKTestCase { public void testOneshot() throws IOException { String filename = locateSystemLog(); if (System.getenv("TRAVIS") != null) { - File tempfile = File.createTempFile((new Date()).toString(), ""); + File tempfile = File.createTempFile(String.format("%d", (new Date()).getTime()), ""); tempfile.deleteOnExit(); FileWriter f = new FileWriter(tempfile, true); From 46c0f157590be68363f674cdfcdf724659251432 Mon Sep 17 00:00:00 2001 From: Shakeel Mohamed Date: Mon, 13 May 2019 16:29:26 -0700 Subject: [PATCH 020/229] restart when needed for delete index tests --- tests/com/splunk/IndexTest.java | 34 ++++++++++++++++++++++++++++++--- 1 file changed, 31 insertions(+), 3 deletions(-) diff --git a/tests/com/splunk/IndexTest.java b/tests/com/splunk/IndexTest.java index 632fd879..7530ec79 100644 --- a/tests/com/splunk/IndexTest.java +++ b/tests/com/splunk/IndexTest.java @@ -53,7 +53,16 @@ public boolean predicate() { public void tearDown() throws Exception { if (service.versionIsAtLeast("5.0.0")) { if (service.getIndexes().containsKey(indexName) && System.getenv("TRAVIS") == null) { - index.remove(); + try { + index.remove(); + } catch(HttpException he) { + if (he.getStatus() == 400) { + uncheckedSplunkRestart(); + index.remove(); + } else { + throw he; + } + } } } else { // Can't delete indexes via the REST API. Just let them build up. @@ -135,7 +144,16 @@ public void testDeletion() { Assert.assertTrue(service.getIndexes().containsKey(indexName)); - index.remove(); + try { + index.remove(); + } catch(HttpException he) { + if (he.getStatus() == 400) { + uncheckedSplunkRestart(); + index.remove(); + } else { + throw he; + } + } assertEventuallyTrue(new EventuallyTrueBehavior() { @Override public boolean predicate() { @@ -152,7 +170,17 @@ public void testDeletionFromCollection() { } Assert.assertTrue(service.getIndexes().containsKey(indexName)); - service.getIndexes().remove(indexName); + + try { + service.getIndexes().remove(indexName); + } catch(HttpException he) { + if (he.getStatus() == 400) { + uncheckedSplunkRestart(); + service.getIndexes().remove(indexName); + } else { + throw he; + } + } assertEventuallyTrue(new EventuallyTrueBehavior() { @Override From 28c45b0b76dee1d62a6dddade801fc57812d3a22 Mon Sep 17 00:00:00 2001 From: Shakeel Mohamed Date: Mon, 13 May 2019 17:17:34 -0700 Subject: [PATCH 021/229] Update upload test --- tests/com/splunk/UploadTest.java | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/tests/com/splunk/UploadTest.java b/tests/com/splunk/UploadTest.java index d30856d3..f1549bcd 100644 --- a/tests/com/splunk/UploadTest.java +++ b/tests/com/splunk/UploadTest.java @@ -25,20 +25,12 @@ public class UploadTest extends SDKTestCase { @Test - public void testOneshot() throws IOException { + public void testOneshot() { String filename = locateSystemLog(); - if (System.getenv("TRAVIS") != null) { - File tempfile = File.createTempFile(String.format("%d", (new Date()).getTime()), ""); - tempfile.deleteOnExit(); - - FileWriter f = new FileWriter(tempfile, true); - f.append("some data here"); - - filename = tempfile.getAbsolutePath(); - } - else if (System.getenv("SPLUNK_HOME") != null) { - filename = System.getenv("SPLUNK_HOME") + "/var/log/splunk/splunkd.log"; + if (System.getenv("SPLUNK_HOME") != null) { + filename = System.getenv("SPLUNK_HOME") + "/copyright.txt"; } + service.getUploads().create(filename); for (Upload oneshot : service.getUploads().values()) { From 5cdeb1ec0c336cbed120a3867166e11ea5d4c136 Mon Sep 17 00:00:00 2001 From: Shakeel Mohamed Date: Tue, 14 May 2019 10:46:55 -0700 Subject: [PATCH 022/229] Update CI configuration & README for new test environment --- .travis.yml | 5 +++-- README.md | 6 +++--- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/.travis.yml b/.travis.yml index 1c60f1fa..17d620f4 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,3 +1,4 @@ + notifications: email: false @@ -39,8 +40,8 @@ addons: - ant-optional jdk: - - oraclejdk8 - - openjdk7 + - openjdk8 + - openjdk11 before_script: - ant diff --git a/README.md b/README.md index 32c89c72..883767a5 100644 --- a/README.md +++ b/README.md @@ -40,7 +40,7 @@ Here's what you need to get going with the Splunk SDK for Java. If you haven't already installed Splunk, download it [here](http://www.splunk.com/download). For more about installing and running Splunk and system requirements, see -[Installing & Running Splunk](http://dev.splunk.com/view/SP-CAAADRV). The Splunk SDK for Java has been tested with Splunk Enterprise 6.6 and 7.0. +[Installing & Running Splunk](http://dev.splunk.com/view/SP-CAAADRV). The Splunk SDK for Java has been tested with Splunk Enterprise 7.0 and 7.2. #### Splunk SDK for Java @@ -51,7 +51,7 @@ If you want to contribute to the SDK, clone the repository from [GitHub](https:/ #### Java and Ant -You'll need Java version 7 or higher, from [OpenJDK](https://openjdk.java.net) or [Oracle](https://www.oracle.com/technetwork/java). The Splunk SDK for Java has been tested with OpenJDK v7 and v8, and Oracle JDK v7 and v8. +You'll need Java version 8 or higher, from [OpenJDK](https://openjdk.java.net) or [Oracle](https://www.oracle.com/technetwork/java). The Splunk SDK for Java has been tested with OpenJDK v8 and v1. You'll also need Ant, which you can install from the [Apache website](http://ant.apache.org/bindownload.cgi). @@ -100,7 +100,7 @@ To add the Splunk SDK for Java `.JAR` file as a dependency: com.splunk splunk - 1.6.3.0 + 1.6.4.0 ``` From cbe23975a4df75498d3c7e43e792a1c792fe45aa Mon Sep 17 00:00:00 2001 From: Shakeel Mohamed Date: Tue, 14 May 2019 11:42:43 -0700 Subject: [PATCH 023/229] Update Java version parsing method See https://stackoverflow.com/a/2591122/2785681 --- tests/com/splunk/SDKTestCase.java | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/tests/com/splunk/SDKTestCase.java b/tests/com/splunk/SDKTestCase.java index ccf2b9d8..77fb1530 100644 --- a/tests/com/splunk/SDKTestCase.java +++ b/tests/com/splunk/SDKTestCase.java @@ -79,8 +79,16 @@ public void connect() { } public static Integer getJavaVersion() { - String ver = System.getProperty("java.version"); - return Integer.parseInt(ver.substring(2, 3)); + String version = System.getProperty("java.version"); + if (version.startsWith("1.")) { + version = version.substring(2, 3); + } else { + int dot = version.indexOf("."); + if (dot != -1) { + version = version.substring(0, dot); + } + } + return Integer.parseInt(version); } @Before From ca52da361bb3364b2f50003f941e71ca1f36e403 Mon Sep 17 00:00:00 2001 From: Shakeel Mohamed Date: Tue, 14 May 2019 11:51:15 -0700 Subject: [PATCH 024/229] update CI password --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 17d620f4..f37a1e22 100644 --- a/.travis.yml +++ b/.travis.yml @@ -11,7 +11,7 @@ before_install: # Create .splunkrc file with default credentials - echo host=localhost >> $HOME/.splunkrc - echo username=admin >> $HOME/.splunkrc - - echo password=changeme >> $HOME/.splunkrc + - echo password=changed! >> $HOME/.splunkrc # Set env vars for TCP/UDP tests (we've punched these through Docker) - export TEST_TCP_PORT=10667 - export TEST_UDP_PORT=10668 From a2479cee9733a99b463ae6509e800532985f58d3 Mon Sep 17 00:00:00 2001 From: Shakeel Mohamed Date: Wed, 15 May 2019 09:32:26 -0700 Subject: [PATCH 025/229] fix version typo in readme --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 883767a5..977aa7d2 100644 --- a/README.md +++ b/README.md @@ -51,7 +51,7 @@ If you want to contribute to the SDK, clone the repository from [GitHub](https:/ #### Java and Ant -You'll need Java version 8 or higher, from [OpenJDK](https://openjdk.java.net) or [Oracle](https://www.oracle.com/technetwork/java). The Splunk SDK for Java has been tested with OpenJDK v8 and v1. +You'll need Java version 8 or higher, from [OpenJDK](https://openjdk.java.net) or [Oracle](https://www.oracle.com/technetwork/java). The Splunk SDK for Java has been tested with OpenJDK v8 and v11. You'll also need Ant, which you can install from the [Apache website](http://ant.apache.org/bindownload.cgi). From a8cbe6aad7348934661cc09d8e662a9987decb33 Mon Sep 17 00:00:00 2001 From: PKing70 <39703314+PKing70@users.noreply.github.com> Date: Mon, 23 Mar 2020 22:27:29 -0700 Subject: [PATCH 026/229] Update CONTRIBUTING.md Revise link to contact us (no more support@splunk.com). Also, numbered list formatting. --- CONTRIBUTING.md | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 0a7a830d..40d6cbe9 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -12,11 +12,11 @@ If you would like to contribute to this project, go here for more information: If you're seeing some unexpected behavior with this project, please create an [issue on GitHub][issues] with the following information: -0. Version of this project you're using (ex: 1.4.0) -0. Platform version (ex: Windows Server 2012) -0. Framework version (ex: Java 8) -0. Splunk version (ex: 6.2.2) -0. Other relevant information (ex: local/remote environment, Splunk network configuration) +1. Version of this project you're using (ex: 1.4.0) +1. Platform version (ex: Windows Server 2012) +1. Framework version (ex: Java 8) +1. Splunk version (ex: 6.2.2) +1. Other relevant information (ex: local/remote environment, Splunk network configuration) Alternatively, if you have a Splunk question please ask on [Splunk Answers][answers] @@ -26,14 +26,14 @@ We love to see pull requests! To create a pull request: -0. Fill out the [Individual Contributor Agreement][indivcontrib]. -0. Fork [the repository][repo]. -0. Make changes to the **`develop`** branch, preferably with tests. -0. Create a [pull request][pulls] against the **`develop`** branch. +1. Fill out the [Individual Contributor Agreement][indivcontrib]. +1. Fork [the repository][repo]. +1. Make changes to the **`develop`** branch, preferably with tests. +1. Create a [pull request][pulls] against the **`develop`** branch. ## Contact us -You can reach Splunk support at _support@splunk.com_ if you have Splunk related questions. +You can [contact support][contact] if you have Splunk related questions. You can reach the Developer Platform team at _devinfo@splunk.com_. @@ -43,4 +43,5 @@ You can reach the Developer Platform team at _devinfo@splunk.com_. [answers]: http://answers.splunk.com/ [repo]: https://github.com/splunk/splunk-sdk-java [issues]: https://github.com/splunk/splunk-sdk-java/issues -[pulls]: https://github.com/splunk/splunk-sdk-java/pulls \ No newline at end of file +[pulls]: https://github.com/splunk/splunk-sdk-java/pulls +[contact]: https://www.splunk.com/en_us/support-and-services.html From 0d04e0d323bf35e2271e6fab76dbd0e32e55471e Mon Sep 17 00:00:00 2001 From: PKing70 <39703314+PKing70@users.noreply.github.com> Date: Mon, 23 Mar 2020 22:34:26 -0700 Subject: [PATCH 027/229] Update README.md Revise link to contact us (no more support@splunk.com). --- README.md | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 09f36d8a..424b7c01 100644 --- a/README.md +++ b/README.md @@ -383,7 +383,7 @@ If you would like to contribute to the SDK, go here for more information: ### Support 1. You will be granted support if you or your company are already covered under an existing maintenance/support agreement. - Send an email to support@splunk.com and include "Splunk SDK for Java" in the subject line. + Submit a new case in the [Support Portal][contact] and include "Splunk SDK for Java" in the subject line. 2. If you are not covered under an existing maintenance/support agreement, you can find help through the broader community at: