File tree 3 files changed +17
-10
lines changed
src/main/java/org/datadog/jmxfetch
3 files changed +17
-10
lines changed Original file line number Diff line number Diff line change 83
83
<scope >system</scope >
84
84
<systemPath >${java.home} /../lib/tools.jar</systemPath >
85
85
</dependency >
86
- <dependency >
87
- <groupId >commons-io</groupId >
88
- <artifactId >commons-io</artifactId >
89
- <version >${commons-io.version} </version >
90
- </dependency >
91
86
<dependency >
92
87
<groupId >com.datadoghq</groupId >
93
88
<artifactId >java-dogstatsd-client</artifactId >
Original file line number Diff line number Diff line change 6
6
import com .beust .jcommander .ParameterException ;
7
7
import com .fasterxml .jackson .core .JsonProcessingException ;
8
8
import lombok .extern .slf4j .Slf4j ;
9
- import org .apache .commons .io .IOUtils ;
10
9
import org .apache .logging .log4j .Level ;
11
10
import org .apache .logging .log4j .LogManager ;
12
11
@@ -780,8 +779,8 @@ private boolean getJsonConfigs() {
780
779
log .debug ("No configuration changes..." );
781
780
return update ;
782
781
}
783
-
784
- InputStream jsonInputStream = IOUtils . toInputStream ( response . getResponseBody (), UTF_8 );
782
+ byte [] utf8 = response . getResponseBody (). getBytes ( UTF_8 );
783
+ InputStream jsonInputStream = new ByteArrayInputStream ( utf8 );
785
784
JsonParser parser = new JsonParser (jsonInputStream );
786
785
int timestamp = ((Integer ) parser .getJsonTimestamp ()).intValue ();
787
786
if (timestamp > lastJsonConfigTs ) {
Original file line number Diff line number Diff line change 2
2
3
3
import com .fasterxml .jackson .jr .ob .JSON ;
4
4
import lombok .extern .slf4j .Slf4j ;
5
- import org .apache .commons .io .FileUtils ;
6
5
import org .yaml .snakeyaml .Yaml ;
7
6
7
+ import java .io .BufferedOutputStream ;
8
8
import java .io .File ;
9
+ import java .io .FileOutputStream ;
9
10
import java .io .IOException ;
11
+ import java .nio .charset .Charset ;
10
12
import java .util .ArrayList ;
11
13
import java .util .HashMap ;
12
14
import java .util .List ;
@@ -147,7 +149,7 @@ public void flush() {
147
149
File statusFile = new File (this .statusFileLocation );
148
150
log .debug (
149
151
"Writing status to temp yaml file: " + statusFile .getAbsolutePath ());
150
- FileUtils . writeStringToFile (statusFile , yaml );
152
+ writeStringToFile (statusFile , yaml );
151
153
} catch (Exception e ) {
152
154
log .warn ("Cannot write status to temp file: " + e .getMessage ());
153
155
}
@@ -164,4 +166,15 @@ public String getStatusFileLocation() {
164
166
public boolean isEnabled () {
165
167
return isEnabled ;
166
168
}
169
+
170
+ private static void writeStringToFile (File file , String string ) throws IOException {
171
+ FileOutputStream out = new FileOutputStream (file );
172
+ BufferedOutputStream bos = new BufferedOutputStream (out );
173
+ try {
174
+ bos .write (string .getBytes (Charset .forName ("UTF-8" )));
175
+ } finally {
176
+ bos .close ();
177
+ out .close ();
178
+ }
179
+ }
167
180
}
You can’t perform that action at this time.
0 commit comments