# HG changeset patch # User egahlin # Date 1558472387 -7200 # Node ID 29635339ef621bb555c7356292c253d9e1134779 # Parent 53dccc90a5be3a890cb2ecd505d37e9ac80f9297 More greceful handling of shutdown diff -r 53dccc90a5be -r 29635339ef62 src/jdk.jfr/share/classes/jdk/jfr/consumer/EventSetLocation.java --- a/src/jdk.jfr/share/classes/jdk/jfr/consumer/EventSetLocation.java Fri May 17 18:03:14 2019 +0200 +++ b/src/jdk.jfr/share/classes/jdk/jfr/consumer/EventSetLocation.java Tue May 21 22:59:47 2019 +0200 @@ -105,9 +105,11 @@ return es; } try { - updateEventSets(previousEventSet); + if (updateEventSets(previousEventSet)) { + continue; + } } catch (IOException e) { - e.printStackTrace(); + Logger.log(LogTag.JFR_SYSTEM_STREAMING, LogLevel.DEBUG, "IOException during event set update " + e.getMessage()); // This can happen if a chunk is being removed // between the file was discovered and an instance // of an EventSet was constructed. Just ignore, @@ -123,9 +125,15 @@ return null; } - private void updateEventSets(EventSet previousEventSet) throws IOException { + private boolean updateEventSets(EventSet previousEventSet) throws IOException { + boolean foundNew = false; List added = new ArrayList<>(); Set current = new HashSet<>(); + if (!Files.exists(path)) { + // Repository removed, probably due to shutdown + closed = true; + return true; + } try (DirectoryStream dirStream = Files.newDirectoryStream(path, "*.jfr")) { for (Path p : dirStream) { if (!lastPaths.containsKey(p)) { @@ -157,19 +165,19 @@ long startTime = es.getStartTimeNanos(); if (startTime == 0) { String errorMsg = "Chunk header should always contain a valid start time"; - System.err.println(errorMsg); throw new InternalError(errorMsg); } EventSet previous = eventSets.get(startTime); if (previous != null) { String errorMsg = "Found chunk " + p + " with the same start time " + startTime + " as previous chunk " + previous.getPath(); - System.err.println(errorMsg); throw new InternalError(errorMsg); } eventSets.put(startTime, es); lastPaths.put(p, startTime); previousEventSet = es; + foundNew = true; } } + return foundNew; } }