File tree 4 files changed +15
-6
lines changed
graylog2-server/src/main/java/org
pipelineprocessor/functions/json
4 files changed +15
-6
lines changed Original file line number Diff line number Diff line change @@ -70,16 +70,14 @@ public Message decode(@Nonnull RawMessage rawMessage) {
70
70
final JsonNode event ;
71
71
try {
72
72
event = objectMapper .readTree (payload );
73
+ if (event == null ) {
74
+ throw new IOException ("null result" );
75
+ }
73
76
} catch (IOException e ) {
74
77
LOG .error ("Couldn't decode raw message {}" , rawMessage );
75
78
return null ;
76
79
}
77
80
78
- // Adhere to the legacy behaviour
79
- if (event == null ) {
80
- return null ;
81
- }
82
-
83
81
return parseEvent (event );
84
82
}
85
83
Original file line number Diff line number Diff line change @@ -50,7 +50,11 @@ public JsonParse(ObjectMapper objectMapper) {
50
50
public JsonNode evaluate (FunctionArgs args , EvaluationContext context ) {
51
51
final String value = valueParam .required (args , context );
52
52
try {
53
- return objectMapper .readTree (value );
53
+ final JsonNode node = objectMapper .readTree (value );
54
+ if (node == null ) {
55
+ throw new IOException ("null result" );
56
+ }
57
+ return node ;
54
58
} catch (IOException e ) {
55
59
log .warn ("Unable to parse JSON" , e );
56
60
}
Original file line number Diff line number Diff line change 45
45
import javax .annotation .Nonnull ;
46
46
import javax .annotation .Nullable ;
47
47
import javax .inject .Inject ;
48
+ import java .io .IOException ;
48
49
import java .util .Iterator ;
49
50
import java .util .Map ;
50
51
@@ -127,6 +128,9 @@ public Message decode(@Nonnull final RawMessage rawMessage) {
127
128
128
129
try {
129
130
node = objectMapper .readTree (json );
131
+ if (node == null ) {
132
+ throw new IOException ("null result" );
133
+ }
130
134
} catch (final Exception e ) {
131
135
log .error ("Could not parse JSON, first 400 characters: " +
132
136
StringUtils .abbreviate (json , 403 ), e );
Original file line number Diff line number Diff line change @@ -644,6 +644,9 @@ public static Optional<AbsoluteRange> extractHistogramBoundaries(final String qu
644
644
try {
645
645
final JsonParser jp = OBJECT_MAPPER .getFactory ().createParser (query );
646
646
final JsonNode rootNode = OBJECT_MAPPER .readTree (jp );
647
+ if (rootNode == null ) {
648
+ throw new IOException ("null result" );
649
+ }
647
650
final JsonNode timestampNode = rootNode .findValue ("range" ).findValue ("timestamp" );
648
651
final String from = elasticSearchTimeFormatToISO8601 (timestampNode .findValue ("from" ).asText ());
649
652
final String to = elasticSearchTimeFormatToISO8601 (timestampNode .findValue ("to" ).asText ());
You can’t perform that action at this time.
0 commit comments