Skip to content

Commit 6c89538

Browse files
committed
Fix memory leaks:
1. Make jCommander converters and validators non-static 2. De-reference strings, maps and lists of removed objects 3. Make all mutable static fields non-static and make classes modular 4. Properly close jmx connections 5. Property discard instances from instances and brokenInstances lists 6. Property close files 7. Upgrade log4j to latest 8. Use iterators only when necessary Other changes: 1. Change variable and method names to follow Java conventions 2. Encapsulate classes and make fields private unless necessary 3. Use library to join strings instead of writing a method to do it 4. Break long lines 5. Use "str".equals(var) instead of var.equals("str") to avoid NPEs 6. Remove unused code 7. Upgrade from junit 3.8 to 4.11 8. Add new tests to test parsing commandline 9. Use properties to track dependencies' versions 10. Upgrade dependencies 11. Limit access modifiers to required levels of access 12. Code clean up and formatting 12. Bump version to 0.4.0
1 parent ba2dbc4 commit 6c89538

30 files changed

+1975
-1723
lines changed

pom.xml

+108-91
Original file line numberDiff line numberDiff line change
@@ -1,100 +1,117 @@
1-
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
2-
xsi:schemaLocation="http://maven.apache.org/xsd/maven-4.0.0.xsd">
3-
<modelVersion>4.0.0</modelVersion>
1+
<project xmlns="http://maven.apache.org/POM/4.0.0"
2+
>
3+
<modelVersion>4.0.0</modelVersion>
44

5-
<groupId>datadog</groupId>
6-
<artifactId>jmxfetch</artifactId>
7-
<version>0.3.0</version>
8-
<packaging>jar</packaging>
5+
<groupId>datadog</groupId>
6+
<artifactId>jmxfetch</artifactId>
7+
<version>0.3.0</version>
8+
<packaging>jar</packaging>
99

10-
<name>jmxfetch</name>
11-
<url>http://maven.apache.org</url>
10+
<name>jmxfetch</name>
11+
<url>http://maven.apache.org</url>
1212

13-
<properties>
14-
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
15-
</properties>
16-
<repositories>
17-
<repository>
18-
<id>Sonatype-public</id>
19-
<name>SnakeYAML repository</name>
20-
<url>http://oss.sonatype.org/content/groups/public/</url>
21-
</repository>
22-
</repositories>
23-
<dependencies>
24-
<dependency>
25-
<groupId>com.beust</groupId>
26-
<artifactId>jcommander</artifactId>
27-
<version>1.30</version>
28-
</dependency>
29-
<dependency>
30-
<groupId>commons-io</groupId>
31-
<artifactId>commons-io</artifactId>
32-
<version>2.4</version>
33-
</dependency>
34-
<dependency>
35-
<groupId>com.indeed</groupId>
36-
<artifactId>java-dogstatsd-client</artifactId>
37-
<version>2.0.7</version>
38-
</dependency>
39-
<dependency>
40-
<groupId>log4j</groupId>
41-
<artifactId>log4j</artifactId>
42-
<version>1.2.15</version>
43-
<exclusions>
44-
<exclusion>
45-
<groupId>com.sun.jmx</groupId>
46-
<artifactId>jmxri</artifactId>
47-
</exclusion>
48-
<exclusion>
49-
<groupId>com.sun.jdmk</groupId>
50-
<artifactId>jmxtools</artifactId>
51-
</exclusion>
52-
<exclusion>
53-
<groupId>javax.jms</groupId>
54-
<artifactId>jms</artifactId>
55-
</exclusion>
56-
</exclusions>
57-
</dependency>
58-
<dependency>
59-
<groupId>junit</groupId>
60-
<artifactId>junit</artifactId>
61-
<version>3.8.1</version>
62-
<scope>test</scope>
63-
</dependency>
64-
<dependency>
65-
<groupId>org.yaml</groupId>
66-
<artifactId>snakeyaml</artifactId>
67-
<version>1.13</version>
68-
</dependency>
69-
</dependencies>
70-
<scm>
13+
<properties>
14+
<commons-io.version>2.4</commons-io.version>
15+
<guava.version>17.0</guava.version>
16+
<java-dogstatsd-client.version>2.0.8</java-dogstatsd-client.version>
17+
<jcommander.version>1.35</jcommander.version>
18+
<junit.version>4.11</junit.version>
19+
<log4j.version>1.2.17</log4j.version>
20+
<maven-surefire-plugin.version>2.9</maven-surefire-plugin.version>
21+
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
22+
<snakeyaml.version>1.13</snakeyaml.version>
23+
</properties>
24+
25+
<repositories>
26+
<repository>
27+
<id>Sonatype-public</id>
28+
<name>SnakeYAML repository</name>
29+
<url>http://oss.sonatype.org/content/groups/public/</url>
30+
</repository>
31+
</repositories>
32+
33+
<dependencies>
34+
<dependency>
35+
<groupId>com.beust</groupId>
36+
<artifactId>jcommander</artifactId>
37+
<version>${jcommander.version}</version>
38+
</dependency>
39+
<dependency>
40+
<groupId>com.google.guava</groupId>
41+
<artifactId>guava</artifactId>
42+
<version>${guava.version}</version>
43+
</dependency>
44+
<dependency>
45+
<groupId>commons-io</groupId>
46+
<artifactId>commons-io</artifactId>
47+
<version>${commons-io.version}</version>
48+
</dependency>
49+
<dependency>
50+
<groupId>com.indeed</groupId>
51+
<artifactId>java-dogstatsd-client</artifactId>
52+
<version>${java-dogstatsd-client.version}</version>
53+
</dependency>
54+
<dependency>
55+
<groupId>log4j</groupId>
56+
<artifactId>log4j</artifactId>
57+
<version>${log4j.version}</version>
58+
<exclusions>
59+
<exclusion>
60+
<groupId>com.sun.jmx</groupId>
61+
<artifactId>jmxri</artifactId>
62+
</exclusion>
63+
<exclusion>
64+
<groupId>com.sun.jdmk</groupId>
65+
<artifactId>jmxtools</artifactId>
66+
</exclusion>
67+
<exclusion>
68+
<groupId>javax.jms</groupId>
69+
<artifactId>jms</artifactId>
70+
</exclusion>
71+
</exclusions>
72+
</dependency>
73+
<dependency>
74+
<groupId>junit</groupId>
75+
<artifactId>junit</artifactId>
76+
<version>${junit.version}</version>
77+
<scope>test</scope>
78+
</dependency>
79+
<dependency>
80+
<groupId>org.yaml</groupId>
81+
<artifactId>snakeyaml</artifactId>
82+
<version>${snakeyaml.version}</version>
83+
</dependency>
84+
</dependencies>
85+
<scm>
7186
<connection>scm:git:git@github.com:Datadog/jmxfetch.git</connection>
7287
<developerConnection>scm:git:git@github.com:Datadog/jmxfetch.git</developerConnection>
7388
<url>git@github.com:Datadog/jmxfetch.git</url>
7489
</scm>
7590
<build>
76-
<plugins>
77-
<plugin>
78-
<groupId>org.apache.maven.plugins</groupId>
79-
<artifactId>maven-surefire-plugin</artifactId>
80-
<version>2.9</version>
81-
<configuration>
82-
<argLine>-Dcom.sun.management.jmxremote.port=3333 -Dcom.sun.management.jmxremote.ssl=false -Dcom.sun.management.jmxremote.authenticate=false</argLine>
83-
</configuration>
84-
</plugin>
85-
<plugin>
86-
<artifactId>maven-assembly-plugin</artifactId>
87-
<configuration>
88-
<archive>
89-
<manifest>
90-
<mainClass>org.datadog.jmxfetch.App</mainClass>
91-
</manifest>
92-
</archive>
93-
<descriptorRefs>
94-
<descriptorRef>jar-with-dependencies</descriptorRef>
95-
</descriptorRefs>
96-
</configuration>
97-
</plugin>
98-
</plugins>
99-
</build>
91+
<plugins>
92+
<plugin>
93+
<groupId>org.apache.maven.plugins</groupId>
94+
<artifactId>maven-surefire-plugin</artifactId>
95+
<version>${maven-surefire-plugin.version}</version>
96+
<configuration>
97+
<argLine>-Dcom.sun.management.jmxremote.port=3333 -Dcom.sun.management.jmxremote.ssl=false
98+
-Dcom.sun.management.jmxremote.authenticate=false
99+
</argLine>
100+
</configuration>
101+
</plugin>
102+
<plugin>
103+
<artifactId>maven-assembly-plugin</artifactId>
104+
<configuration>
105+
<archive>
106+
<manifest>
107+
<mainClass>org.datadog.jmxfetch.App</mainClass>
108+
</manifest>
109+
</archive>
110+
<descriptorRefs>
111+
<descriptorRef>jar-with-dependencies</descriptorRef>
112+
</descriptorRefs>
113+
</configuration>
114+
</plugin>
115+
</plugins>
116+
</build>
100117
</project>

0 commit comments

Comments
 (0)