Skip to content

Commit

Permalink
Drop support for Java 6
Browse files Browse the repository at this point in the history
  • Loading branch information
Andrew Johnson committed Apr 10, 2015
1 parent f36cfb3 commit 1febd8d
Show file tree
Hide file tree
Showing 14 changed files with 27 additions and 34 deletions.
3 changes: 1 addition & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
language: java
jdk:
- oraclejdk8
- oraclejdk7
- openjdk6
- oraclejdk7
6 changes: 3 additions & 3 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

<groupId>com.etsy</groupId>
<artifactId>statsd-jvm-profiler</artifactId>
<version>0.7.1-SNAPSHOT</version>
<version>0.7.2-SNAPSHOT</version>
<packaging>jar</packaging>

<name>statsd-jvm-profiler</name>
Expand Down Expand Up @@ -144,8 +144,8 @@
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<configuration>
<source>1.6</source>
<target>1.6</target>
<source>1.7</source>
<target>1.7</target>
</configuration>
</plugin>
<plugin>
Expand Down
10 changes: 2 additions & 8 deletions src/main/java/com/etsy/statsd/profiler/Agent.java
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public static void premain(final String args, final Instrumentation instrumentat

Reporter reporter = instantiate(arguments.reporter, Reporter.CONSTRUCTOR_PARAM_TYPES, server, port, prefix, arguments);

Collection<Profiler> profilers = new ArrayList<Profiler>();
Collection<Profiler> profilers = new ArrayList<>();
for (Class<? extends Profiler> profiler : arguments.profilers) {
profilers.add(instantiate(profiler, Profiler.CONSTRUCTOR_PARAM_TYPES, reporter, arguments));
}
Expand Down Expand Up @@ -96,13 +96,7 @@ private static <T> T instantiate(final Class<T> clazz, Class<?>[] parameterTypes
try {
Constructor<T> constructor = clazz.getConstructor(parameterTypes);
return constructor.newInstance(initArgs);
} catch (NoSuchMethodException e) {
handleInitializationException(clazz, e);
} catch (InvocationTargetException e) {
handleInitializationException(clazz, e);
} catch (InstantiationException e) {
handleInitializationException(clazz, e);
} catch (IllegalAccessException e) {
} catch (NoSuchMethodException | IllegalAccessException | InstantiationException | InvocationTargetException e) {
handleInitializationException(clazz, e);
}

Expand Down
4 changes: 2 additions & 2 deletions src/main/java/com/etsy/statsd/profiler/Arguments.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public class Arguments {
* @return An Arguments object representing the given arguments
*/
public static Arguments parseArgs(final String args) {
Map<String, String> parsed = new HashMap<String, String>();
Map<String, String> parsed = new HashMap<>();
for (String argPair : args.split(",")) {
String[] tokens = argPair.split("=");
if (tokens.length != 2) {
Expand Down Expand Up @@ -89,7 +89,7 @@ private Class<? extends Reporter<?>> parserReporterArg(String reporterArg) {

@SuppressWarnings("unchecked")
private Set<Class<? extends Profiler>> parseProfilerArg(String profilerArg) {
Set<Class<? extends Profiler>> profilers = new HashSet<Class<? extends Profiler>>();
Set<Class<? extends Profiler>> profilers = new HashSet<>();
if (profilerArg == null) {
profilers.add(CPUProfiler.class);
profilers.add(MemoryProfiler.class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ protected void handleArguments(Arguments arguments) {
*/
private List<String> parsePackageList(String packages) {
if (packages == null) {
return new ArrayList<String>();
return new ArrayList<>();
} else {
return Arrays.asList(packages.split(":"));
}
Expand Down
6 changes: 3 additions & 3 deletions src/main/java/com/etsy/statsd/profiler/util/CPUTraces.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ public class CPUTraces {
private Set<String> dirtyTraces;

public CPUTraces() {
traces = new HashMap<String, Long>();
dirtyTraces = new HashSet<String>();
traces = new HashMap<>();
dirtyTraces = new HashSet<>();
}

/**
Expand All @@ -38,7 +38,7 @@ public void increment(String traceKey, long inc) {
* @param flushAll Indicate if all data, not just deltas, should be flushed
*/
public Map<String, Long> getDataToFlush(boolean flushAll) {
Map<String, Long> result = new HashMap<String, Long>();
Map<String, Long> result = new HashMap<>();
if (flushAll) {
result = traces;
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public static String formatStackTraceElement(StackTraceElement element) {
* @return A String representing the given stack trace
*/
public static String formatStackTrace(StackTraceElement[] stack) {
List<String> lines = new ArrayList<String>();
List<String> lines = new ArrayList<>();
for (StackTraceElement element : stack) {
lines.add(formatStackTraceElement(element));
}
Expand Down
8 changes: 4 additions & 4 deletions src/test/java/com/etsy/statsd/profiler/ArgumentsTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ public void testDefaultProfilers() {
String args = "server=localhost,port=8125";
Arguments arguments = Arguments.parseArgs(args);

Set<Class<? extends Profiler>> expected = new HashSet<Class<? extends Profiler>>();
Set<Class<? extends Profiler>> expected = new HashSet<>();
expected.add(CPUProfiler.class);
expected.add(MemoryProfiler.class);

Expand All @@ -78,7 +78,7 @@ public void testProfilerWithPackage() {
String args = "server=localhost,port=8125,profilers=com.etsy.statsd.profiler.profilers.CPUProfiler";
Arguments arguments = Arguments.parseArgs(args);

Set<Class<? extends Profiler>> expected = new HashSet<Class<? extends Profiler>>();
Set<Class<? extends Profiler>> expected = new HashSet<>();
expected.add(CPUProfiler.class);

assertEquals(expected, arguments.profilers);
Expand All @@ -89,7 +89,7 @@ public void testProfilerWithoutPackage() {
String args = "server=localhost,port=8125,profilers=MemoryProfiler";
Arguments arguments = Arguments.parseArgs(args);

Set<Class<? extends Profiler>> expected = new HashSet<Class<? extends Profiler>>();
Set<Class<? extends Profiler>> expected = new HashSet<>();
expected.add(MemoryProfiler.class);

assertEquals(expected, arguments.profilers);
Expand All @@ -100,7 +100,7 @@ public void testMultipleProfilers() {
String args = "server=localhost,port=8125,profilers=CPUProfiler:MemoryProfiler";
Arguments arguments = Arguments.parseArgs(args);

Set<Class<? extends Profiler>> expected = new HashSet<Class<? extends Profiler>>();
Set<Class<? extends Profiler>> expected = new HashSet<>();
expected.add(CPUProfiler.class);
expected.add(MemoryProfiler.class);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public class MockReporter extends Reporter<String> {

public MockReporter() {
super("", 1, "", null);
output = new HashMap<String, Long>();
output = new HashMap<>();
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public void testReporter() {
profiler.profile();
profiler.flushData();

Map<String, Long> expected = new HashMap<String, Long>();
Map<String, Long> expected = new HashMap<>();
expected.put("profile", 1L);
expected.put("flushData", 1L);
assertEquals(expected, mockReporter.getOutput());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public void testGetDataToFlush() {
traces.increment("key", 1);
traces.increment("key2", 3);

Map<String, Long> expectedMap = new HashMap<String, Long>();
Map<String, Long> expectedMap = new HashMap<>();
expectedMap.put("key", 1L);
expectedMap.put("key2", 3L);

Expand All @@ -30,7 +30,7 @@ public void testGetDataToFlush() {
traces.increment("key", 1);
traces.increment("key2", 3);

expectedMap = new HashMap<String, Long>();
expectedMap = new HashMap<>();
expectedMap.put("key", 2L);
expectedMap.put("key2", 6L);

Expand All @@ -39,7 +39,7 @@ public void testGetDataToFlush() {
traces.increment("key3", 100);
traces.increment("key2", 3);

expectedMap = new HashMap<String, Long>();
expectedMap = new HashMap<>();
expectedMap.put("key", 2L);
expectedMap.put("key2", 9L);
expectedMap.put("key3", 100L);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ public class MapUtilTest {

@Test
public void testSetOrIncrementMap() {
Map<String, Long> map = new HashMap<String, Long>();
Map<String, Long> map = new HashMap<>();
MapUtil.setOrIncrementMap(map, "key", 1);
assertEquals(new Long(1L), map.get("key"));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
public class ProfilerShutdownHookWorkerTest {
@Test
public void testRunnable() throws InterruptedException {
Set<String> output = new HashSet<String>();
Set<String> output = new HashSet<>();
Profiler mockProfiler1 = new MockProfiler1(output);
Profiler mockProfiler2 = new MockProfiler2(output);
Collection<Profiler> profilers = Arrays.asList(mockProfiler1, mockProfiler2);
Expand All @@ -24,7 +24,7 @@ public void testRunnable() throws InterruptedException {
t.run();
t.join();

Set<String> expectedOutput = new HashSet<String>();
Set<String> expectedOutput = new HashSet<>();
expectedOutput.add(MockProfiler1.class.getSimpleName() + "-flushData");
expectedOutput.add(MockProfiler2.class.getSimpleName() + "-flushData");
assertEquals(expectedOutput, output);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,14 @@
public class ProfilerWorkerThreadTest {
@Test
public void testRunnable() throws InterruptedException {
Set<String> output = new HashSet<String>();
Set<String> output = new HashSet<>();
Profiler mockProfiler1 = new MockProfiler1(output);

Thread t = new Thread(new ProfilerWorkerThread(mockProfiler1));
t.run();
t.join();

Set<String> expectedOutput = new HashSet<String>();
Set<String> expectedOutput = new HashSet<>();
expectedOutput.add(MockProfiler1.class.getSimpleName() + "-profile");
assertEquals(expectedOutput, output);
}
Expand Down

0 comments on commit 1febd8d

Please sign in to comment.