Make pandas thread safe (#3865)

Signed-off-by: Fabio Di Fabio <fabio.difabio@consensys.net>
pull/3871/head
Fabio Di Fabio 3 years ago committed by GitHub
parent bdb00b299e
commit 7565d623bd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 6
      consensus/merge/src/main/java/org/hyperledger/besu/consensus/merge/PandaPrinter.java

@ -23,6 +23,7 @@ import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.nio.charset.StandardCharsets;
import java.util.concurrent.atomic.AtomicBoolean;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@ -31,7 +32,7 @@ public class PandaPrinter implements TTDReachedListener {
private static final Logger LOG = LoggerFactory.getLogger(PandaPrinter.class);
private static final String pandaBanner = PandaPrinter.loadBanner();
private boolean beenDisplayed = false;
private final AtomicBoolean beenDisplayed = new AtomicBoolean();
private static String loadBanner() {
Class<PandaPrinter> c = PandaPrinter.class;
@ -51,9 +52,8 @@ public class PandaPrinter implements TTDReachedListener {
@Override
public void onTTDReached(final boolean reached) {
if (reached && !beenDisplayed) {
if (reached && beenDisplayed.compareAndSet(false, true)) {
LOG.info("\n" + pandaBanner);
this.beenDisplayed = true;
}
}
}

Loading…
Cancel
Save