accumulo-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From GitBox <...@apache.org>
Subject [GitHub] [accumulo] ctubbsii commented on a change in pull request #1034: Fix #933 RuntimeException while stopping Accumulo
Date Fri, 05 Apr 2019 23:52:09 GMT
ctubbsii commented on a change in pull request #1034: Fix #933 RuntimeException while stopping
Accumulo
URL: https://github.com/apache/accumulo/pull/1034#discussion_r272772424
 
 

 ##########
 File path: start/src/main/java/org/apache/accumulo/start/classloader/vfs/AccumuloReloadingVFSClassLoader.java
 ##########
 @@ -199,6 +211,12 @@ public AccumuloReloadingVFSClassLoader(String uris, FileSystemManager
vfs,
    * thread
    */
   public void close() {
+    try {
+      Stream.of(this.files).forEach(monitor::removeFile);
+    } catch (RuntimeException re) {
 
 Review comment:
   Since this is a common, reusable pattern, it might be possible to put it into a reusable
static method like:
   
   ```java
   public static <T> void forEachCatchRTEs(Stream<T> stream, Consumer<T>
consumer) {
     stream.flatMap(o -> {
          try {
            consume(o);
            return null;
          } catch (RuntimeException e) {
            return Stream.of(e);
          }
        }).reduce((e1, e2) -> {
              e1.addSuppressed(e2);
              return e1;
            }).ifPresent(e -> {
              throw e;
            });
   }
   ```
   
   Then, each time you need it:
   
   ```java
   forEachCatchRTEs(pathsToMonitor.stream(), o -> { addFileToMonitor(o); log.debug("monitoring
{}", o); });
   ```

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

Mime
View raw message