From 4dbcdfaa1bd5ebe80f8f9f787696ec5b8423b086 Mon Sep 17 00:00:00 2001 From: Bertrand Renuart Date: Sun, 25 Sep 2022 11:23:43 +0200 Subject: [PATCH] Let LogstashAccessEncoder/Layout throw an exception when trying to setProviders() on them Related to issue #859 --- .../net/logstash/logback/encoder/LogstashAccessEncoder.java | 5 +++++ .../net/logstash/logback/layout/LogstashAccessLayout.java | 5 +++++ 2 files changed, 10 insertions(+) diff --git a/src/main/java/net/logstash/logback/encoder/LogstashAccessEncoder.java b/src/main/java/net/logstash/logback/encoder/LogstashAccessEncoder.java index 53603418..c670a0cc 100644 --- a/src/main/java/net/logstash/logback/encoder/LogstashAccessEncoder.java +++ b/src/main/java/net/logstash/logback/encoder/LogstashAccessEncoder.java @@ -18,6 +18,7 @@ import net.logstash.logback.LogstashAccessFormatter; import net.logstash.logback.composite.AbstractCompositeJsonFormatter; import net.logstash.logback.composite.JsonProvider; +import net.logstash.logback.composite.JsonProviders; import net.logstash.logback.composite.accessevent.HeaderFilter; import net.logstash.logback.composite.accessevent.IncludeExcludeHeaderFilter; import net.logstash.logback.fieldnames.LogstashAccessFieldNames; @@ -134,4 +135,8 @@ public void setWriteVersionAsInteger(boolean writeVersionAsInteger) { getFormatter().setWriteVersionAsInteger(writeVersionAsInteger); } + @Override + public void setProviders(JsonProviders jsonProviders) { + throw new IllegalArgumentException("Using the configuration property is not allowed. Use instead to registerd additional " + JsonProvider.class.getSimpleName() + "."); + } } diff --git a/src/main/java/net/logstash/logback/layout/LogstashAccessLayout.java b/src/main/java/net/logstash/logback/layout/LogstashAccessLayout.java index c569c53b..7ce5c73c 100644 --- a/src/main/java/net/logstash/logback/layout/LogstashAccessLayout.java +++ b/src/main/java/net/logstash/logback/layout/LogstashAccessLayout.java @@ -18,6 +18,7 @@ import net.logstash.logback.LogstashAccessFormatter; import net.logstash.logback.composite.AbstractCompositeJsonFormatter; import net.logstash.logback.composite.JsonProvider; +import net.logstash.logback.composite.JsonProviders; import net.logstash.logback.composite.accessevent.HeaderFilter; import net.logstash.logback.composite.accessevent.IncludeExcludeHeaderFilter; import net.logstash.logback.fieldnames.LogstashAccessFieldNames; @@ -134,4 +135,8 @@ public void setWriteVersionAsInteger(boolean writeVersionAsInteger) { getFormatter().setWriteVersionAsInteger(writeVersionAsInteger); } + @Override + public void setProviders(JsonProviders jsonProviders) { + throw new IllegalArgumentException("Using the configuration property is not allowed. Use instead to registerd additional " + JsonProvider.class.getSimpleName() + "."); + } }