Remove usage of Streams.copyToBytesFromClasspath()
Original commit: elastic/x-pack-elasticsearch@8f813e9275
This commit is contained in:
parent
3713b3dfdd
commit
101ea6deab
|
@ -460,8 +460,8 @@ public class HttpESExporter extends AbstractExporter<HttpESExporter> implements
|
||||||
*/
|
*/
|
||||||
private boolean checkAndUploadIndexTemplate(final String host) {
|
private boolean checkAndUploadIndexTemplate(final String host) {
|
||||||
byte[] template;
|
byte[] template;
|
||||||
try {
|
try (InputStream is = getClass().getResourceAsStream("/marvel_index_template.json")) {
|
||||||
template = Streams.copyToBytesFromClasspath("/marvel_index_template.json");
|
template = ByteStreams.toByteArray(is);
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
// throwing an exception to stop exporting process - we don't want to send data unless
|
// throwing an exception to stop exporting process - we don't want to send data unless
|
||||||
// we put in the template for it.
|
// we put in the template for it.
|
||||||
|
|
|
@ -5,14 +5,13 @@
|
||||||
*/
|
*/
|
||||||
package org.elasticsearch.shield;
|
package org.elasticsearch.shield;
|
||||||
|
|
||||||
import org.elasticsearch.common.io.FastStringReader;
|
|
||||||
import org.elasticsearch.common.io.Streams;
|
|
||||||
import org.elasticsearch.common.io.stream.StreamInput;
|
import org.elasticsearch.common.io.stream.StreamInput;
|
||||||
import org.elasticsearch.common.io.stream.StreamOutput;
|
import org.elasticsearch.common.io.stream.StreamOutput;
|
||||||
import org.joda.time.DateTimeZone;
|
import org.joda.time.DateTimeZone;
|
||||||
import org.joda.time.format.ISODateTimeFormat;
|
import org.joda.time.format.ISODateTimeFormat;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.io.InputStream;
|
||||||
import java.util.Properties;
|
import java.util.Properties;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -27,10 +26,9 @@ public class ShieldBuild {
|
||||||
String hashShort = "NA";
|
String hashShort = "NA";
|
||||||
String timestamp = "NA";
|
String timestamp = "NA";
|
||||||
|
|
||||||
try {
|
try (InputStream is = ShieldBuild.class.getResourceAsStream("/shield-build.properties")) {
|
||||||
String properties = Streams.copyToStringFromClasspath("/shield-build.properties");
|
|
||||||
Properties props = new Properties();
|
Properties props = new Properties();
|
||||||
props.load(new FastStringReader(properties));
|
props.load(is);
|
||||||
hash = props.getProperty("hash", hash);
|
hash = props.getProperty("hash", hash);
|
||||||
if (!hash.equals("NA")) {
|
if (!hash.equals("NA")) {
|
||||||
hashShort = hash.substring(0, 7);
|
hashShort = hash.substring(0, 7);
|
||||||
|
|
|
@ -7,6 +7,7 @@ package org.elasticsearch.shield.audit.index;
|
||||||
|
|
||||||
import com.google.common.base.Splitter;
|
import com.google.common.base.Splitter;
|
||||||
import com.google.common.collect.ImmutableSet;
|
import com.google.common.collect.ImmutableSet;
|
||||||
|
import com.google.common.io.ByteStreams;
|
||||||
import org.elasticsearch.ElasticsearchException;
|
import org.elasticsearch.ElasticsearchException;
|
||||||
import org.elasticsearch.action.admin.cluster.state.ClusterStateResponse;
|
import org.elasticsearch.action.admin.cluster.state.ClusterStateResponse;
|
||||||
import org.elasticsearch.action.admin.indices.template.put.PutIndexTemplateRequest;
|
import org.elasticsearch.action.admin.indices.template.put.PutIndexTemplateRequest;
|
||||||
|
@ -53,6 +54,7 @@ import org.joda.time.DateTime;
|
||||||
import org.joda.time.DateTimeZone;
|
import org.joda.time.DateTimeZone;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.io.InputStream;
|
||||||
import java.net.InetAddress;
|
import java.net.InetAddress;
|
||||||
import java.net.InetSocketAddress;
|
import java.net.InetSocketAddress;
|
||||||
import java.net.SocketAddress;
|
import java.net.SocketAddress;
|
||||||
|
@ -641,8 +643,8 @@ public class IndexAuditTrail extends AbstractComponent implements AuditTrail {
|
||||||
}
|
}
|
||||||
|
|
||||||
void putTemplate(Settings customSettings) {
|
void putTemplate(Settings customSettings) {
|
||||||
try {
|
try (InputStream is = getClass().getResourceAsStream("/" + INDEX_TEMPLATE_NAME + ".json")) {
|
||||||
final byte[] template = Streams.copyToBytesFromClasspath("/" + INDEX_TEMPLATE_NAME + ".json");
|
final byte[] template = ByteStreams.toByteArray(is);
|
||||||
PutIndexTemplateRequest request = new PutIndexTemplateRequest(INDEX_TEMPLATE_NAME).source(template);
|
PutIndexTemplateRequest request = new PutIndexTemplateRequest(INDEX_TEMPLATE_NAME).source(template);
|
||||||
if (customSettings != null && customSettings.names().size() > 0) {
|
if (customSettings != null && customSettings.names().size() > 0) {
|
||||||
Settings updatedSettings = Settings.builder()
|
Settings updatedSettings = Settings.builder()
|
||||||
|
|
|
@ -5,14 +5,13 @@
|
||||||
*/
|
*/
|
||||||
package org.elasticsearch.watcher;
|
package org.elasticsearch.watcher;
|
||||||
|
|
||||||
import org.elasticsearch.common.io.FastStringReader;
|
|
||||||
import org.elasticsearch.common.io.Streams;
|
|
||||||
import org.elasticsearch.common.io.stream.StreamInput;
|
import org.elasticsearch.common.io.stream.StreamInput;
|
||||||
import org.elasticsearch.common.io.stream.StreamOutput;
|
import org.elasticsearch.common.io.stream.StreamOutput;
|
||||||
import org.joda.time.DateTimeZone;
|
import org.joda.time.DateTimeZone;
|
||||||
import org.joda.time.format.ISODateTimeFormat;
|
import org.joda.time.format.ISODateTimeFormat;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.io.InputStream;
|
||||||
import java.util.Properties;
|
import java.util.Properties;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -27,10 +26,9 @@ public class WatcherBuild {
|
||||||
String hashShort = "NA";
|
String hashShort = "NA";
|
||||||
String timestamp = "NA";
|
String timestamp = "NA";
|
||||||
|
|
||||||
try {
|
try (InputStream is = WatcherBuild.class.getResourceAsStream("/watcher-build.properties")) {
|
||||||
String properties = Streams.copyToStringFromClasspath("/watcher-build.properties");
|
|
||||||
Properties props = new Properties();
|
Properties props = new Properties();
|
||||||
props.load(new FastStringReader(properties));
|
props.load(is);
|
||||||
hash = props.getProperty("hash", hash);
|
hash = props.getProperty("hash", hash);
|
||||||
if (!hash.equals("NA")) {
|
if (!hash.equals("NA")) {
|
||||||
hashShort = hash.substring(0, 7);
|
hashShort = hash.substring(0, 7);
|
||||||
|
|
Loading…
Reference in New Issue