Skip to content

Commit 9689d6d

Browse files
author
rezra3
committed
will not fail to read all peers if one has json issue
1 parent b6d60a8 commit 9689d6d

File tree

1 file changed

+10
-8
lines changed

1 file changed

+10
-8
lines changed

src/common/codeine/db/mysql/connectors/StatusMysqlConnector.java

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -75,18 +75,20 @@ public Map<String, PeerStatusJsonV2> getPeersStatus() {
7575
Function<ResultSet, Void> function = rs -> {
7676
try {
7777
String key = rs.getString(1);
78-
log.debug("Checking key " + key);
7978
String value = rs.getString(2);
80-
PeerStatusJsonV2 peerStatus = gson.fromJson(value, PeerStatusJsonV2.class);
81-
peerStatus.status(PeerStatusString.valueOf(rs.getString("status")));
82-
updateNodesWithPeer(peerStatus);
83-
$.put(key, peerStatus);
79+
try {
80+
PeerStatusJsonV2 peerStatus = gson.fromJson(value, PeerStatusJsonV2.class);
81+
peerStatus.status(PeerStatusString.valueOf(rs.getString("status")));
82+
updateNodesWithPeer(peerStatus);
83+
$.put(key, peerStatus);
84+
} catch (JsonSyntaxException e) {
85+
log.error("Got json exception while trying to parse line of key " + key + ", will skip this node",
86+
e);
87+
return null;
88+
}
8489
return null;
8590
} catch (SQLException e) {
8691
throw ExceptionUtils.asUnchecked(e);
87-
} catch (JsonSyntaxException e) {
88-
log.error("Got json exception while trying to parse line, will skip this node", e);
89-
return null;
9092
}
9193
};
9294
dbUtils.executeQueryCompressed("select * from " + TABLE_NAME, function);

0 commit comments

Comments
 (0)