adjust classloader
This commit is contained in:
parent
719e9ee05f
commit
f311573c1e
3 changed files with 23 additions and 6 deletions
|
@ -39,7 +39,7 @@ public class ClientBuilder {
|
||||||
}
|
}
|
||||||
|
|
||||||
public ClientBuilder(ElasticsearchClient client) {
|
public ClientBuilder(ElasticsearchClient client) {
|
||||||
this(client, Thread.currentThread().getContextClassLoader());
|
this(client, ClassLoader.getSystemClassLoader());
|
||||||
}
|
}
|
||||||
|
|
||||||
public ClientBuilder(ElasticsearchClient client, ClassLoader classLoader) {
|
public ClientBuilder(ElasticsearchClient client, ClassLoader classLoader) {
|
||||||
|
|
|
@ -302,8 +302,7 @@ public class DefaultIndexDefinition implements IndexDefinition {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
URL url = new URL(string);
|
try (InputStream inputStream = findInputStream(string)) {
|
||||||
try (InputStream inputStream = url.openStream()) {
|
|
||||||
Settings settings = Settings.builder().loadFromStream(string, inputStream).build();
|
Settings settings = Settings.builder().loadFromStream(string, inputStream).build();
|
||||||
XContentBuilder builder = JsonXContent.contentBuilder();
|
XContentBuilder builder = JsonXContent.contentBuilder();
|
||||||
settings.toXContent(builder, ToXContent.EMPTY_PARAMS);
|
settings.toXContent(builder, ToXContent.EMPTY_PARAMS);
|
||||||
|
@ -311,6 +310,8 @@ public class DefaultIndexDefinition implements IndexDefinition {
|
||||||
}
|
}
|
||||||
} catch (MalformedURLException e) {
|
} catch (MalformedURLException e) {
|
||||||
return string;
|
return string;
|
||||||
|
} catch (IOException e) {
|
||||||
|
throw new IOException("unable to read JSON from " + string + ": " + e.getMessage(), e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -319,8 +320,7 @@ public class DefaultIndexDefinition implements IndexDefinition {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
URL url = new URL(string);
|
try (InputStream inputStream = findInputStream(string)) {
|
||||||
try (InputStream inputStream = url.openStream()) {
|
|
||||||
if (string.endsWith(".json")) {
|
if (string.endsWith(".json")) {
|
||||||
Map<String, ?> mappings = JsonXContent.jsonXContent.createParser(inputStream).mapOrdered();
|
Map<String, ?> mappings = JsonXContent.jsonXContent.createParser(inputStream).mapOrdered();
|
||||||
XContentBuilder builder = JsonXContent.contentBuilder();
|
XContentBuilder builder = JsonXContent.contentBuilder();
|
||||||
|
@ -337,6 +337,23 @@ public class DefaultIndexDefinition implements IndexDefinition {
|
||||||
return string;
|
return string;
|
||||||
} catch (MalformedInputException e) {
|
} catch (MalformedInputException e) {
|
||||||
return string;
|
return string;
|
||||||
|
} catch (IOException e) {
|
||||||
|
throw new IOException("unable to read JSON from " + string + ": " + e.getMessage(), e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static InputStream findInputStream(String string) {
|
||||||
|
if (string == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
URL url = ClassLoader.getSystemClassLoader().getResource(string);
|
||||||
|
if (url == null) {
|
||||||
|
url = new URL(string);
|
||||||
|
}
|
||||||
|
return url.openStream();
|
||||||
|
} catch (IOException e) {
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
group = org.xbib
|
group = org.xbib
|
||||||
name = elx
|
name = elx
|
||||||
version = 2.2.1.32
|
version = 2.2.1.33
|
||||||
|
|
||||||
gradle.wrapper.version = 6.6.1
|
gradle.wrapper.version = 6.6.1
|
||||||
xbib-metrics.version = 2.1.0
|
xbib-metrics.version = 2.1.0
|
||||||
|
|
Loading…
Reference in a new issue