diff --git a/core/src/main/java/org/solovyev/acraanalyzer/AcraAnalyzer.java b/core/src/main/java/org/solovyev/acraanalyzer/AcraAnalyzer.java index d4bcbd6f..6ac3f1fb 100644 --- a/core/src/main/java/org/solovyev/acraanalyzer/AcraAnalyzer.java +++ b/core/src/main/java/org/solovyev/acraanalyzer/AcraAnalyzer.java @@ -1,7 +1,5 @@ package org.solovyev.acraanalyzer; -import com.google.common.collect.ArrayListMultimap; -import com.google.common.collect.Multimap; import org.apache.commons.cli.*; import org.solovyev.common.text.Strings; @@ -30,12 +28,14 @@ public final class AcraAnalyzer { if (Strings.isEmpty(path)) { throw new IllegalArgumentException("Path should be specified"); } else { - final Multimap reports = ArrayListMultimap.create(100, 20); + final Map> reports = new HashMap>(); + scanFiles(path, reports); - final List> sortedReports = new ArrayList>(reports.size()); - for (String stackTrace : reports.keys()) { - sortedReports.add(reports.get(stackTrace)); + final List> sortedReports = new ArrayList>(reports.size()); + for (Map.Entry> entry : reports.entrySet()) { + sortedReports.add(entry.getValue()); } + Collections.sort(sortedReports, new Comparator>() { @Override public int compare(Collection lhs, Collection rhs) { @@ -58,14 +58,14 @@ public final class AcraAnalyzer { } } - private static void scanFiles(String path, Multimap reports) { + private static void scanFiles(String path, Map> reports) { final File directory = new File(path); if (directory.isDirectory()) { scanFiles(directory, reports); } } - private static void scanFiles(File directory, Multimap reports) { + private static void scanFiles(File directory, Map> reports) { final File[] files = directory.listFiles(); if (files != null) { for (File file : files) { @@ -78,10 +78,15 @@ public final class AcraAnalyzer { } } - private static void analyzeFile(File file, Multimap reports) { + private static void analyzeFile(File file, Map> reports) { final AcraReport report = readReport(file); if (!Strings.isEmpty(report.stackTrace)) { - reports.put(report.stackTrace, report); + List acraReports = reports.get(report.stackTrace); + if (acraReports == null) { + acraReports = new ArrayList(); + reports.put(report.stackTrace, acraReports); + } + acraReports.add(report); } }