修复:极端情况下Gson().fromJson爆空指针错误 #207

pull/231/head
pppscn 2 years ago
parent 74cbddc192
commit 9d75554df0

@ -93,7 +93,7 @@ class BarkUtils {
Log.i(TAG, response)
val resp = Gson().fromJson(response, BarkResult::class.java)
if (resp.code == 200L) {
if (resp?.code == 200L) {
SendUtils.updateLogs(logId, 2, response)
} else {
SendUtils.updateLogs(logId, 0, response)

@ -104,7 +104,7 @@ class DingtalkGroupRobotUtils private constructor() {
Log.i(TAG, response)
val resp = Gson().fromJson(response, DingtalkResult::class.java)
if (resp.errcode == 0L) {
if (resp?.errcode == 0L) {
SendUtils.updateLogs(logId, 2, response)
} else {
SendUtils.updateLogs(logId, 0, response)

@ -112,7 +112,7 @@ class DingtalkInnerRobotUtils private constructor() {
Log.i(TAG, response)
val resp = Gson().fromJson(response, DingtalkInnerRobotResult::class.java)
if (!TextUtils.isEmpty(resp.accessToken)) {
if (!TextUtils.isEmpty(resp?.accessToken)) {
MMKVUtils.put("accessToken_" + setting.agentID, resp.accessToken)
MMKVUtils.put("expiresIn_" + setting.agentID, System.currentTimeMillis() + ((resp.expireIn ?: 7200) - 120) * 1000L) //提前2分钟过期
sendTextMsg(setting, msgInfo, rule, logId)
@ -224,7 +224,7 @@ class DingtalkInnerRobotUtils private constructor() {
Log.i(TAG, response)
val resp = Gson().fromJson(response, DingtalkInnerRobotResult::class.java)
if (!TextUtils.isEmpty(resp.processQueryKey)) {
if (!TextUtils.isEmpty(resp?.processQueryKey)) {
SendUtils.updateLogs(logId, 2, response)
} else {
SendUtils.updateLogs(logId, 0, response)

@ -64,7 +64,7 @@ class FeishuAppUtils private constructor() {
Log.i(TAG, response)
val resp = Gson().fromJson(response, FeishuAppResult::class.java)
if (!TextUtils.isEmpty(resp.tenant_access_token)) {
if (!TextUtils.isEmpty(resp?.tenant_access_token)) {
MMKVUtils.put("feishu_access_token_" + setting.appId, resp.tenant_access_token)
MMKVUtils.put("feishu_expires_in_" + setting.appId, System.currentTimeMillis() + ((resp.expire ?: 7010) - 120) * 1000L) //提前2分钟过期
sendTextMsg(setting, msgInfo, rule, logId)
@ -138,7 +138,7 @@ class FeishuAppUtils private constructor() {
//Log.d(TAG, "cipherSuite=" + response.handshake().cipherSuite().toString())
val resp = Gson().fromJson(response, FeishuAppResult::class.java)
if (resp.code == 0L) {
if (resp?.code == 0L) {
SendUtils.updateLogs(logId, 2, response)
} else {
SendUtils.updateLogs(logId, 0, response)

@ -151,7 +151,7 @@ class FeishuUtils private constructor() {
Log.i(TAG, response)
val resp = Gson().fromJson(response, FeishuResult::class.java)
if (resp.code == 0L) {
if (resp?.code == 0L) {
SendUtils.updateLogs(logId, 2, response)
} else {
SendUtils.updateLogs(logId, 0, response)

@ -87,7 +87,7 @@ class PushplusUtils private constructor() {
Log.i(TAG, response)
val resp = Gson().fromJson(response, PushplusResult::class.java)
if (resp.code == 200L) {
if (resp?.code == 200L) {
SendUtils.updateLogs(logId, 2, response)
} else {
SendUtils.updateLogs(logId, 0, response)

@ -123,7 +123,7 @@ class TelegramUtils private constructor() {
Log.i(TAG, response)
val resp = Gson().fromJson(response, TelegramResult::class.java)
if (resp.ok == true) {
if (resp?.ok == true) {
SendUtils.updateLogs(logId, 2, response)
} else {
SendUtils.updateLogs(logId, 0, response)

@ -107,7 +107,7 @@ class WeworkAgentUtils private constructor() {
Log.i(TAG, response)
val resp = Gson().fromJson(response, WeworkAgentResult::class.java)
if (resp.errcode == 0L) {
if (resp?.errcode == 0L) {
MMKVUtils.put("access_token_" + setting.agentID, resp.access_token)
MMKVUtils.put("expires_in_" + setting.agentID, System.currentTimeMillis() + ((resp.expires_in ?: 7200) - 120) * 1000L) //提前2分钟过期
sendTextMsg(setting, msgInfo, rule, logId)
@ -208,7 +208,7 @@ class WeworkAgentUtils private constructor() {
Log.i(TAG, response)
val resp = Gson().fromJson(response, DingtalkResult::class.java)
if (resp.errcode == 0L) {
if (resp?.errcode == 0L) {
SendUtils.updateLogs(logId, 2, response)
} else {
SendUtils.updateLogs(logId, 0, response)

@ -64,7 +64,7 @@ class WeworkRobotUtils private constructor() {
Log.i(TAG, response)
val resp = Gson().fromJson(response, WeworkRobotResult::class.java)
if (resp.errcode == 0L) {
if (resp?.errcode == 0L) {
SendUtils.updateLogs(logId, 2, response)
} else {
SendUtils.updateLogs(logId, 0, response)

Loading…
Cancel
Save