You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@accumulo.apache.org by br...@apache.org on 2021/01/13 16:36:59 UTC

[accumulo] branch main updated (9f549b2 -> bdcab44)

This is an automated email from the ASF dual-hosted git repository.

brianloss pushed a change to branch main
in repository https://gitbox.apache.org/repos/asf/accumulo.git.


    from 9f549b2  Merge remote-tracking branch 'upstream/1.10' into main
     add 0187567  Re-throw exception from LoggingRunnable (re #1808)
     new bdcab44  Merge branch '1.10' into main

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 .../apache/accumulo/fate/util/LoggingRunnable.java | 36 ++++++++++++++++------
 1 file changed, 26 insertions(+), 10 deletions(-)


[accumulo] 01/01: Merge branch '1.10' into main

Posted by br...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

brianloss pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/accumulo.git

commit bdcab448b5c4fb44118197615fe2e231816da01c
Merge: 9f549b2 0187567
Author: Brian Loss <br...@apache.org>
AuthorDate: Wed Jan 13 11:34:09 2021 -0500

    Merge branch '1.10' into main

 .../apache/accumulo/fate/util/LoggingRunnable.java | 36 ++++++++++++++++------
 1 file changed, 26 insertions(+), 10 deletions(-)

diff --cc core/src/main/java/org/apache/accumulo/fate/util/LoggingRunnable.java
index aafe45d,0000000..dfe1bf5
mode 100644,000000..100644
--- a/core/src/main/java/org/apache/accumulo/fate/util/LoggingRunnable.java
+++ b/core/src/main/java/org/apache/accumulo/fate/util/LoggingRunnable.java
@@@ -1,56 -1,0 +1,72 @@@
 +/*
 + * Licensed to the Apache Software Foundation (ASF) under one
 + * or more contributor license agreements.  See the NOTICE file
 + * distributed with this work for additional information
 + * regarding copyright ownership.  The ASF licenses this file
 + * to you under the Apache License, Version 2.0 (the
 + * "License"); you may not use this file except in compliance
 + * with the License.  You may obtain a copy of the License at
 + *
 + *   http://www.apache.org/licenses/LICENSE-2.0
 + *
 + * Unless required by applicable law or agreed to in writing,
 + * software distributed under the License is distributed on an
 + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 + * KIND, either express or implied.  See the License for the
 + * specific language governing permissions and limitations
 + * under the License.
 + */
 +package org.apache.accumulo.fate.util;
 +
 +import java.util.Date;
 +
 +import org.slf4j.Logger;
 +
 +public class LoggingRunnable implements Runnable {
 +  private Runnable runnable;
 +  private Logger log;
 +
 +  public LoggingRunnable(Logger log, Runnable r) {
 +    this.runnable = r;
 +    this.log = log;
 +  }
 +
 +  @Override
 +  public void run() {
 +    try {
 +      runnable.run();
 +    } catch (Throwable t) {
++      boolean errorOnRun = (t instanceof Error);
 +      try {
 +        log.error("Thread \"{}\" died {}", Thread.currentThread().getName(), t.getMessage(), t);
 +      } catch (Throwable t2) {
-         // maybe the logging system is screwed up OR there is a bug in the exception, like
-         // t.getMessage() throws a NPE
-         System.err.println(
-             "ERROR " + new Date() + " Failed to log message about thread death " + t2.getMessage());
-         t2.printStackTrace();
- 
-         // try to print original exception
-         System.err
-             .println("ERROR " + new Date() + " Exception that failed to log : " + t.getMessage());
-         t.printStackTrace();
++        boolean errorOnLog = (t2 instanceof Error);
++        try {
++          // maybe the logging system is screwed up OR there is a bug in the exception, like
++          // t.getMessage() throws a NPE
++          System.err.println("ERROR " + new Date() + " Failed to log message about thread death "
++              + t2.getMessage());
++          t2.printStackTrace();
++
++          // try to print original exception
++          System.err
++              .println("ERROR " + new Date() + " Exception that failed to log : " + t.getMessage());
++          t.printStackTrace();
++        } catch (Throwable t3) {
++          // If printing to System.err didn't work then don't try to log that exception but do
++          // re-throw it if it's the most serious failure we've seen so far.
++          boolean errorOnPrint = (t3 instanceof Error);
++          if (errorOnPrint && !errorOnLog && !errorOnRun)
++            throw t3;
++        }
++
++        // If we got a more serious failure when attempting to log the message,
++        // then throw that instead of the original exception.
++        if (errorOnLog && !errorOnRun)
++          throw t2;
 +      }
++      throw t;
 +    }
 +  }
 +
 +}