Commit 8c41442 1 parent 589cf00 commit 8c41442 Copy full SHA for 8c41442
File tree 3 files changed +22
-0
lines changed
main/java/net/logstash/logback
test/java/net/logstash/logback/encoder
3 files changed +22
-0
lines changed Original file line number Diff line number Diff line change 20
20
import net .logstash .logback .LogstashFormatter ;
21
21
import net .logstash .logback .composite .AbstractCompositeJsonFormatter ;
22
22
import net .logstash .logback .composite .JsonProvider ;
23
+ import net .logstash .logback .composite .JsonProviders ;
23
24
import net .logstash .logback .fieldnames .LogstashFieldNames ;
24
25
25
26
import ch .qos .logback .classic .pattern .ThrowableHandlingConverter ;
@@ -229,4 +230,10 @@ public String getMessageSplitRegex() {
229
230
public void setMessageSplitRegex (String messageSplitRegex ) {
230
231
getFormatter ().setMessageSplitRegex (messageSplitRegex );
231
232
}
233
+
234
+
235
+ @ Override
236
+ public void setProviders (JsonProviders <ILoggingEvent > jsonProviders ) {
237
+ throw new IllegalArgumentException ("Using the <providers> configuration property is not allowed. Use <provider> instead to registerd additional " + JsonProvider .class .getSimpleName () + "." );
238
+ }
232
239
}
Original file line number Diff line number Diff line change 20
20
import net .logstash .logback .LogstashFormatter ;
21
21
import net .logstash .logback .composite .AbstractCompositeJsonFormatter ;
22
22
import net .logstash .logback .composite .JsonProvider ;
23
+ import net .logstash .logback .composite .JsonProviders ;
23
24
import net .logstash .logback .fieldnames .LogstashFieldNames ;
24
25
25
26
import ch .qos .logback .classic .pattern .ThrowableHandlingConverter ;
@@ -228,4 +229,10 @@ public String getMessageSplitRegex() {
228
229
public void setMessageSplitRegex (String messageSplitRegex ) {
229
230
getFormatter ().setMessageSplitRegex (messageSplitRegex );
230
231
}
232
+
233
+
234
+ @ Override
235
+ public void setProviders (JsonProviders <ILoggingEvent > jsonProviders ) {
236
+ throw new IllegalArgumentException ("Using the <providers> configuration property is not allowed. Use <provider> instead to registerd additional " + JsonProvider .class .getSimpleName () + "." );
237
+ }
231
238
}
Original file line number Diff line number Diff line change 19
19
import static net .logstash .logback .marker .Markers .appendEntries ;
20
20
import static org .assertj .core .api .Assertions .assertThat ;
21
21
import static org .assertj .core .api .Assertions .assertThatCode ;
22
+ import static org .assertj .core .api .Assertions .assertThatExceptionOfType ;
22
23
import static org .mockito .Mockito .mock ;
23
24
import static org .mockito .Mockito .spy ;
24
25
import static org .mockito .Mockito .when ;
36
37
import java .util .TimeZone ;
37
38
38
39
import net .logstash .logback .composite .AbstractFormattedTimestampJsonProvider ;
40
+ import net .logstash .logback .composite .loggingevent .LoggingEventJsonProviders ;
39
41
import net .logstash .logback .decorate .JsonFactoryDecorator ;
40
42
import net .logstash .logback .decorate .JsonGeneratorDecorator ;
41
43
import net .logstash .logback .fieldnames .LogstashCommonFieldNames ;
@@ -691,6 +693,12 @@ public void testMessageSplitDisabledByDefault() throws Exception {
691
693
assertThat (node .path ("message" ).textValue ()).isEqualTo (message );
692
694
}
693
695
696
+ @ Test
697
+ public void testJsonProvidersCannotBeChanged () {
698
+ assertThatExceptionOfType (IllegalArgumentException .class )
699
+ .isThrownBy (() -> encoder .setProviders (new LoggingEventJsonProviders ()));
700
+ }
701
+
694
702
private void assertJsonArray (JsonNode jsonNode , String ... expected ) {
695
703
assertThat (jsonNode ).isNotNull ();
696
704
assertThat (jsonNode .isArray ()).isTrue ();
You can’t perform that action at this time.
0 commit comments