44package com .microsoft .applicationinsights .attach ;
55
66import io .opentelemetry .contrib .attach .core .CoreRuntimeAttach ;
7+ import javax .annotation .Nullable ;
78import java .io .BufferedReader ;
89import java .io .File ;
910import 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