@Test public void testBuildHsErrPidList() throws IOException { final List<HsErrPid> hsErrPidList = HsErrPid.buildHsErrPidList(); final File file = new File("./hs_err_pid12345.log"); final File file2 = new File("./hs_err_pid67890.log"); final File file3 = new File("./hs_err_pid12345.notlog"); try { file.createNewFile(); file2.createNewFile(); file3.createNewFile(); final List<HsErrPid> hsErrPidList2 = HsErrPid.buildHsErrPidList(); assertEquals("buildHsErrPidList", hsErrPidList.size() + 2, hsErrPidList2.size()); for (final HsErrPid hsErrPid : hsErrPidList2) { assertNotNull("getDate", hsErrPid.getDate()); assertNotNull("getFile", hsErrPid.getFile()); } final JavaInformations javaInformations = new JavaInformations(null, true); final JavaInformations javaInformations2 = new JavaInformations(null, false); final List<HsErrPid> hsErrPidList3 = HsErrPid .getHsErrPidList(Arrays.asList(javaInformations, javaInformations2)); assertEquals("buildHsErrPidList", hsErrPidList.size() + 2, hsErrPidList3.size()); } finally { file.delete(); file2.delete(); file3.delete(); } }
public static List<HsErrPid> buildHsErrPidList() { final List<File> directories = new ArrayList<File>(); directories.add(new File("./")); directories.add(new File("/tmp")); final String tmp = System.getenv("TMP"); if (tmp != null) { directories.add(new File(tmp)); } final List<String> args = ManagementFactory.getRuntimeMXBean().getInputArguments(); for (final String arg : args) { if (arg.startsWith(XX_ERROR_FILE)) { final String errorFile = arg.substring(XX_ERROR_FILE.length()); final File dir = new File(errorFile).getParentFile(); if (dir != null) { directories.add(dir); } } } final List<HsErrPid> result = new ArrayList<HsErrPid>(); for (final File dir : directories) { final File[] files = dir.listFiles(FILENAME_FILTER); if (files != null) { for (final File file : files) { result.add(new HsErrPid(file.getAbsolutePath(), new Date(file.lastModified()))); } } } return result; }
HsErrPid implements Serializable { public static List<HsErrPid> buildHsErrPidList() { final List<File> directories = new ArrayList<File>(); directories.add(new File("./")); directories.add(new File("/tmp")); final String tmp = System.getenv("TMP"); if (tmp != null) { directories.add(new File(tmp)); } final List<String> args = ManagementFactory.getRuntimeMXBean().getInputArguments(); for (final String arg : args) { if (arg.startsWith(XX_ERROR_FILE)) { final String errorFile = arg.substring(XX_ERROR_FILE.length()); final File dir = new File(errorFile).getParentFile(); if (dir != null) { directories.add(dir); } } } final List<HsErrPid> result = new ArrayList<HsErrPid>(); for (final File dir : directories) { final File[] files = dir.listFiles(FILENAME_FILTER); if (files != null) { for (final File file : files) { result.add(new HsErrPid(file.getAbsolutePath(), new Date(file.lastModified()))); } } } return result; } }
HsErrPid implements Serializable { public static List<HsErrPid> buildHsErrPidList() { final List<File> directories = new ArrayList<File>(); directories.add(new File("./")); directories.add(new File("/tmp")); final String tmp = System.getenv("TMP"); if (tmp != null) { directories.add(new File(tmp)); } final List<String> args = ManagementFactory.getRuntimeMXBean().getInputArguments(); for (final String arg : args) { if (arg.startsWith(XX_ERROR_FILE)) { final String errorFile = arg.substring(XX_ERROR_FILE.length()); final File dir = new File(errorFile).getParentFile(); if (dir != null) { directories.add(dir); } } } final List<HsErrPid> result = new ArrayList<HsErrPid>(); for (final File dir : directories) { final File[] files = dir.listFiles(FILENAME_FILTER); if (files != null) { for (final File file : files) { result.add(new HsErrPid(file.getAbsolutePath(), new Date(file.lastModified()))); } } } return result; } private  HsErrPid(String file, Date date); }
HsErrPid implements Serializable { public static List<HsErrPid> buildHsErrPidList() { final List<File> directories = new ArrayList<File>(); directories.add(new File("./")); directories.add(new File("/tmp")); final String tmp = System.getenv("TMP"); if (tmp != null) { directories.add(new File(tmp)); } final List<String> args = ManagementFactory.getRuntimeMXBean().getInputArguments(); for (final String arg : args) { if (arg.startsWith(XX_ERROR_FILE)) { final String errorFile = arg.substring(XX_ERROR_FILE.length()); final File dir = new File(errorFile).getParentFile(); if (dir != null) { directories.add(dir); } } } final List<HsErrPid> result = new ArrayList<HsErrPid>(); for (final File dir : directories) { final File[] files = dir.listFiles(FILENAME_FILTER); if (files != null) { for (final File file : files) { result.add(new HsErrPid(file.getAbsolutePath(), new Date(file.lastModified()))); } } } return result; } private  HsErrPid(String file, Date date); static List<HsErrPid> buildHsErrPidList(); static List<HsErrPid> getHsErrPidList(List<JavaInformations> javaInformationsList); String getFile(); Date getDate(); }
HsErrPid implements Serializable { public static List<HsErrPid> buildHsErrPidList() { final List<File> directories = new ArrayList<File>(); directories.add(new File("./")); directories.add(new File("/tmp")); final String tmp = System.getenv("TMP"); if (tmp != null) { directories.add(new File(tmp)); } final List<String> args = ManagementFactory.getRuntimeMXBean().getInputArguments(); for (final String arg : args) { if (arg.startsWith(XX_ERROR_FILE)) { final String errorFile = arg.substring(XX_ERROR_FILE.length()); final File dir = new File(errorFile).getParentFile(); if (dir != null) { directories.add(dir); } } } final List<HsErrPid> result = new ArrayList<HsErrPid>(); for (final File dir : directories) { final File[] files = dir.listFiles(FILENAME_FILTER); if (files != null) { for (final File file : files) { result.add(new HsErrPid(file.getAbsolutePath(), new Date(file.lastModified()))); } } } return result; } private  HsErrPid(String file, Date date); static List<HsErrPid> buildHsErrPidList(); static List<HsErrPid> getHsErrPidList(List<JavaInformations> javaInformationsList); String getFile(); Date getDate();  }