From 488f8c716f061fca934d539fdc7cfa0e678d4356 Mon Sep 17 00:00:00 2001 From: Andreas Dangel Date: Thu, 17 Feb 2022 18:52:53 +0100 Subject: [PATCH] Avoid NPE if writer is not set in AbstractRenderer.flush --- .../java/net/sourceforge/pmd/renderers/AbstractRenderer.java | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/renderers/AbstractRenderer.java b/pmd-core/src/main/java/net/sourceforge/pmd/renderers/AbstractRenderer.java index 88b69d2202..ea12ba8630 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/renderers/AbstractRenderer.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/renderers/AbstractRenderer.java @@ -103,6 +103,11 @@ public abstract class AbstractRenderer extends AbstractPropertySource implements @Override public void flush() { + if (writer == null) { + // might happen, if no writer is set. E.g. in maven-pmd-plugin's PmdCollectingRenderer + return; + } + try { this.writer.flush(); } catch (IOException e) {