@@ -32,20 +32,24 @@ public static Map<String, String> parseTopics(List<byte[]> topicList, JSONObject
32
32
33
33
// in case indexed topics doesn't match
34
34
if (topicsMatched (topicList , entry )) {
35
- for (int i = 0 ; i < inputs .size (); ++i ) {
36
- JSONObject param = inputs .getJSONObject (i );
37
- Boolean indexed = param .getBoolean (INDEXED );
38
- if (indexed == null || !indexed ) {
39
- continue ;
40
- }
41
- if (index >= topicList .size ()) {
42
- break ;
43
- }
44
- String str = parseTopic (topicList .get (index ++), param .getString ("type" ));
45
- if (StringUtils .isNotNullOrEmpty (param .getString ("name" ))) {
46
- map .put (param .getString ("name" ), str );
35
+ if (inputs != null ) {
36
+ for (int i = 0 ; i < inputs .size (); ++i ) {
37
+ JSONObject param = inputs .getJSONObject (i );
38
+ if (param != null ) {
39
+ Boolean indexed = param .getBoolean (INDEXED );
40
+ if (indexed == null || !indexed ) {
41
+ continue ;
42
+ }
43
+ if (index >= topicList .size ()) {
44
+ break ;
45
+ }
46
+ String str = parseTopic (topicList .get (index ++), param .getString ("type" ));
47
+ if (StringUtils .isNotNullOrEmpty (param .getString ("name" ))) {
48
+ map .put (param .getString ("name" ), str );
49
+ }
50
+ map .put ("" + i , str );
51
+ }
47
52
}
48
- map .put ("" + i , str );
49
53
}
50
54
} else {
51
55
for (int i = 1 ; i < topicList .size (); ++i ) {
@@ -82,21 +86,22 @@ public static Map<String, String> parseEventData(byte[] data,
82
86
if (inputs != null ) {
83
87
for (Integer i = 0 ; i < inputs .size (); ++i ) {
84
88
JSONObject param = inputs .getJSONObject (i );
85
- Boolean indexed = param .getBoolean (INDEXED );
86
- if (indexed != null && indexed ) {
87
- continue ;
88
- }
89
+ if (param != null ) {
90
+ Boolean indexed = param .getBoolean (INDEXED );
91
+ if (indexed != null && indexed ) {
92
+ continue ;
93
+ }
89
94
90
- if (startIndex == 0 ) {
91
- startIndex = i ;
92
- }
95
+ if (startIndex == 0 ) {
96
+ startIndex = i ;
97
+ }
93
98
94
- String str = parseDataBytes (data , param .getString ("type" ), index ++);
95
- if (StringUtils .isNotNullOrEmpty (param .getString ("name" ))) {
96
- map .put (param .getString ("name" ), str );
99
+ String str = parseDataBytes (data , param .getString ("type" ), index ++);
100
+ if (StringUtils .isNotNullOrEmpty (param .getString ("name" ))) {
101
+ map .put (param .getString ("name" ), str );
102
+ }
103
+ map .put ("" + i , str );
97
104
}
98
- map .put ("" + i , str );
99
-
100
105
}
101
106
} else {
102
107
map .put ("0" , Hex .toHexString (data ));
@@ -115,14 +120,17 @@ private static boolean topicsMatched(List<byte[]> topicList, JSONObject entry) {
115
120
}
116
121
int inputSize = 1 ;
117
122
JSONArray inputs = entry .getJSONArray (INPUTS );
118
- for (int i = 0 ; i < inputs .size (); i ++) {
119
- JSONObject param = inputs .getJSONObject (i );
120
- Boolean indexed = param .getBoolean (INDEXED );
121
- if (indexed != null && indexed ) {
122
- inputSize ++;
123
+ if (inputs != null ) {
124
+ for (int i = 0 ; i < inputs .size (); i ++) {
125
+ JSONObject param = inputs .getJSONObject (i );
126
+ if (param != null ) {
127
+ Boolean indexed = param .getBoolean (INDEXED );
128
+ if (indexed != null && indexed ) {
129
+ inputSize ++;
130
+ }
131
+ }
123
132
}
124
133
}
125
134
return inputSize == topicList .size ();
126
135
}
127
-
128
136
}
0 commit comments