Skip to content

Commit 3372cb3

Browse files
committed
code cleanup, removed obsolete JRockitParser
1 parent e0a0433 commit 3372cb3

File tree

9 files changed

+97
-1803
lines changed

9 files changed

+97
-1803
lines changed

tda/src/main/java/de/grimmfrost/tda/mcp/HeadlessAnalysisProvider.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@
1717
* Headless analysis provider for TDA.
1818
*/
1919
public class HeadlessAnalysisProvider {
20-
private Map<String, Map> threadStore = new HashMap<>();
21-
private List<DefaultMutableTreeNode> topNodes = new ArrayList<>();
20+
private final Map<String, Map<String, String>> threadStore = new HashMap<>();
21+
private final List<DefaultMutableTreeNode> topNodes = new ArrayList<>();
2222
private String currentLogFile;
2323

2424
public void parseLogFile(String filePath) throws IOException {

tda/src/main/java/de/grimmfrost/tda/parser/DumpParserFactory.java

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,8 @@ public static DumpParserFactory get() {
6464
* the current time stamp instead of a parsed one.
6565
* @return a proper dump parser for the given log file, null if no proper parser was found.
6666
*/
67-
public DumpParser getDumpParserForLogfile(InputStream dumpFileStream, Map threadStore, boolean withCurrentTimeStamp, int startCounter) {
67+
public DumpParser getDumpParserForLogfile(InputStream dumpFileStream, Map<String, Map<String, String>> threadStore,
68+
boolean withCurrentTimeStamp, int startCounter) {
6869
BufferedReader bis = null;
6970
int readAheadLimit = PrefManager.get().getStreamResetBuffer();
7071
int lineCounter = 0;
@@ -104,14 +105,11 @@ public DumpParser getDumpParserForLogfile(InputStream dumpFileStream, Map thread
104105
currentDumpParser = new WrappedSunJDKParser(bis, threadStore, lineCounter, withCurrentTimeStamp, startCounter, dm);
105106
} else if(SunJDKParser.checkForSupportedThreadDump(line)) {
106107
currentDumpParser = new SunJDKParser(bis, threadStore, lineCounter, withCurrentTimeStamp, startCounter, dm);
107-
} else if(BeaJDKParser.checkForSupportedThreadDump(line)) {
108-
currentDumpParser = new BeaJDKParser(bis, threadStore, lineCounter, dm);
109108
}
110109
}
111110
lineCounter++;
112111
}
113-
//System.out.println("Selected Dump Parser: " + currentDumpParser.getClass().getName());
114-
if ((currentDumpParser != null) && (bis != null)) {
112+
if (currentDumpParser != null) {
115113
bis.reset();
116114
}
117115
} catch (IOException ex) {

tda/src/main/java/de/grimmfrost/tda/parser/SunJDKParser.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@
5151
public class SunJDKParser extends AbstractDumpParser {
5252

5353
private MutableTreeNode nextDump = null;
54-
private Map threadStore = null;
54+
private Map<String, Map<String, String>> threadStore = null;
5555
private int counter = 1;
5656
private int lineCounter = 0;
5757
private boolean foundClassHistograms = false;
@@ -60,7 +60,7 @@ public class SunJDKParser extends AbstractDumpParser {
6060
/**
6161
* Creates a new instance of SunJDKParser
6262
*/
63-
public SunJDKParser(BufferedReader bis, Map threadStore, int lineCounter, boolean withCurrentTimeStamp, int startCounter, DateMatcher dm) {
63+
public SunJDKParser(BufferedReader bis, Map<String, Map<String, String>> threadStore, int lineCounter, boolean withCurrentTimeStamp, int startCounter, DateMatcher dm) {
6464
super(bis, dm);
6565
this.threadStore = threadStore;
6666
this.withCurrentTimeStamp = withCurrentTimeStamp;
@@ -120,7 +120,7 @@ public MutableTreeNode parseNext() {
120120
DefaultMutableTreeNode catVirtualThreads = null;
121121

122122
try {
123-
Map threads = new HashMap();
123+
Map<String, String> threads = new HashMap<>();
124124
overallTDI = new ThreadDumpInfo("Dump No. " + counter++, 0);
125125
if (withCurrentTimeStamp) {
126126
overallTDI.setStartTime((new Date(System.currentTimeMillis())).toString());

tda/src/test/java/de/grimmfrost/tda/parser/BeaJDKParserTest.java

Lines changed: 0 additions & 80 deletions
This file was deleted.

tda/src/test/java/de/grimmfrost/tda/parser/DumpParserFactoryTest.java

Lines changed: 14 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -27,29 +27,28 @@
2727
import org.junit.jupiter.api.*;
2828
import static org.junit.jupiter.api.Assertions.*;
2929
import java.io.InputStream;
30+
import java.util.HashMap;
3031
import java.util.Map;
3132

3233
/**
33-
*
34+
* test if the dump parser factory selects the right dump parser for the provided log files.
3435
* @author irockel
3536
*/
3637
public class DumpParserFactoryTest {
3738

3839
@BeforeEach
39-
protected void setUp() throws Exception {
40+
protected void setUp() {
4041
}
4142

4243
@AfterEach
43-
protected void tearDown() throws Exception {
44+
protected void tearDown() {
4445
}
4546

4647
/**
4748
* Test of get method, of class de.grimmfrost.tda.DumpParserFactory.
4849
*/
4950
@Test
5051
public void testGet() {
51-
System.out.println("get");
52-
5352
DumpParserFactory result = DumpParserFactory.get();
5453
assertNotNull(result);
5554
}
@@ -59,32 +58,28 @@ public void testGet() {
5958
*/
6059
@Test
6160
public void testGetDumpParserForSunLogfile() throws FileNotFoundException {
62-
System.out.println("getDumpParserForVersion");
63-
6461
InputStream dumpFileStream = new FileInputStream("src/test/resources/test.log");
65-
Map threadStore = null;
62+
Map<String, Map<String, String>> threadStore = new HashMap<>();
6663
DumpParserFactory instance = DumpParserFactory.get();
6764

6865
DumpParser result = instance.getDumpParserForLogfile(dumpFileStream, threadStore, false, 0);
6966
assertNotNull(result);
70-
71-
assertTrue(result instanceof SunJDKParser);
67+
68+
assertInstanceOf(SunJDKParser.class, result);
7269
}
7370

7471
/**
7572
* Test of getDumpParserForVersion method, of class de.grimmfrost.tda.DumpParserFactory.
7673
*/
7774
@Test
78-
public void testGetDumpParserForBeaLogfile() throws FileNotFoundException {
79-
System.out.println("getDumpParserForVersion");
80-
81-
InputStream dumpFileStream = new FileInputStream("src/test/resources/jrockit_15_dump.txt");
82-
Map threadStore = null;
75+
public void testGetDumpParserForJSONLogfile() throws FileNotFoundException {
76+
InputStream dumpFileStream = new FileInputStream("src/test/resources/intellij_dump.json");
77+
Map<String, Map<String, String>> threadStore = new HashMap<>();
8378
DumpParserFactory instance = DumpParserFactory.get();
84-
79+
8580
DumpParser result = instance.getDumpParserForLogfile(dumpFileStream, threadStore, false, 0);
8681
assertNotNull(result);
87-
88-
assertTrue(result instanceof BeaJDKParser);
89-
}
82+
83+
assertInstanceOf(JCmdJSONParser.class, result);
84+
}
9085
}

tda/src/test/java/de/grimmfrost/tda/parser/JCmdJSONParserTest.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,11 @@ public class JCmdJSONParserTest {
1515

1616
@Test
1717
public void testJSONDumpParsing() throws Exception {
18-
System.out.println("testJSONDumpParsing");
1918
InputStream dumpFileStream = new FileInputStream("src/test/resources/intellij_dump.json");
20-
Map threadStore = new HashMap();
19+
Map<String, Map<String, String>> threadStore = new HashMap<>();
2120
DumpParser instance = DumpParserFactory.get().getDumpParserForLogfile(dumpFileStream, threadStore, false, 0);
22-
23-
assertTrue(instance instanceof JCmdJSONParser);
21+
22+
assertInstanceOf(JCmdJSONParser.class, instance);
2423

2524
DefaultMutableTreeNode result = (DefaultMutableTreeNode) instance.parseNext();
2625
assertNotNull(result);

0 commit comments

Comments
 (0)