Skip to content

Commit 765ccd1

Browse files
committed
up
1 parent 68e07d5 commit 765ccd1

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

agent/runtime-attach/src/main/java/com/microsoft/applicationinsights/attach/ApplicationInsights.java

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
package com.microsoft.applicationinsights.attach;
55

66
import io.opentelemetry.contrib.attach.core.CoreRuntimeAttach;
7+
import javax.annotation.Nullable;
78
import java.io.BufferedReader;
89
import java.io.File;
910
import java.io.IOException;
@@ -81,23 +82,23 @@ private static Optional<String> findJsonConfigFromClasspath() {
8182
return Optional.empty();
8283
}
8384

84-
String json = findJson(configContentAsInputStream);
85+
String json = read(configContentAsInputStream);
8586
return Optional.of(json);
8687
}
8788

8889
private static Optional<String> findJsonConfigFromFileSystem() {
8990

90-
InputStream configContentAsInputStream = findDefaultFileInCurrentDirAsStream();
91+
InputStream configContentAsInputStream = findJsonConfigFromFileSystemAsStream();
9192

9293
if (configContentAsInputStream == null) {
9394
return Optional.empty();
9495
}
9596

96-
String json = findJson(configContentAsInputStream);
97+
String json = read(configContentAsInputStream);
9798
return Optional.of(json);
9899
}
99100

100-
private static String findJson(InputStream configContentAsInputStream) {
101+
private static String read(InputStream configContentAsInputStream) {
101102
try (InputStreamReader inputStreamReader =
102103
new InputStreamReader(configContentAsInputStream, StandardCharsets.UTF_8);
103104
BufferedReader bufferedReader = new BufferedReader(inputStreamReader)) {
@@ -108,6 +109,7 @@ private static String findJson(InputStream configContentAsInputStream) {
108109
}
109110
}
110111

112+
@Nullable
111113
private static InputStream findResourceAsStream(String fileName) {
112114
InputStream configContentAsInputStream =
113115
ApplicationInsights.class.getResourceAsStream("/" + fileName);
@@ -117,7 +119,8 @@ private static InputStream findResourceAsStream(String fileName) {
117119
return configContentAsInputStream;
118120
}
119121

120-
private static InputStream findDefaultFileInCurrentDirAsStream() {
122+
@Nullable
123+
private static InputStream findJsonConfigFromFileSystemAsStream() {
121124
File defaultFile = new File("config/applicationinsights.json");
122125
if (!defaultFile.exists()) {
123126
defaultFile = new File("applicationinsights.json");

0 commit comments

Comments
 (0)