Skip to content

Commit e61462e

Browse files
authored
Switch guava deps from compileOnly to implementation (#1530)
* Switch guava deps from compileOnly to implementation Signed-off-by: Craig Perkins <cwperx@amazon.com> * Use AccessController Signed-off-by: Craig Perkins <cwperx@amazon.com> * Use getResource Signed-off-by: Craig Perkins <cwperx@amazon.com> * Use getResourceAsStream Signed-off-by: Craig Perkins <cwperx@amazon.com> * Try removing lead forward slash Signed-off-by: Craig Perkins <cwperx@amazon.com> --------- Signed-off-by: Craig Perkins <cwperx@amazon.com>
1 parent c00cbef commit e61462e

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,7 @@ dependencies {
210210
implementation 'com.jayway.jsonpath:json-path:2.9.0'
211211
implementation 'net.minidev:json-smart:2.5.2'
212212
implementation 'net.minidev:accessors-smart:2.5.2'
213-
compileOnly "com.google.guava:guava:32.1.3-jre"
213+
implementation "com.google.guava:guava:32.1.3-jre"
214214

215215
// TODO uncomment once SA commons is published to maven central
216216
// api "org.opensearch:security-analytics-commons:${sa_commons_version}@jar"

src/main/java/org/opensearch/securityanalytics/util/RuleIndices.java

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,9 @@
4949
import org.opensearch.transport.client.Client;
5050

5151
import java.io.IOException;
52+
import java.io.InputStream;
5253
import java.net.URISyntaxException;
54+
import java.net.URL;
5355
import java.nio.charset.Charset;
5456
import java.nio.file.Files;
5557
import java.nio.file.Path;
@@ -248,7 +250,13 @@ private List<String> getRules(List<Path> listOfRules) {
248250
if (Files.isDirectory(path)) {
249251
rules.addAll(getRules(Files.list(path).collect(Collectors.toList())));
250252
} else {
251-
rules.add(Files.readString(path, Charset.defaultCharset()));
253+
try (InputStream inputStream = getClass().getClassLoader().getResourceAsStream(path.toString().substring(1))) {
254+
if (inputStream != null) {
255+
rules.add(new String(inputStream.readAllBytes(), Charset.defaultCharset()));
256+
} else {
257+
log.warn("Resource not found: {}", path.toString().substring(1));
258+
}
259+
}
252260
}
253261
} catch (IOException ex) {
254262
// suppress with log

0 commit comments

Comments
 (0)