红果免费短剧 v6.2.3.32版本的 MD5 值为:a6b05492607eab2c8a25f26d2f238ae0
以下内容为反编译后的 b.java 源代码,内容仅作参考
package com.bytedance.article.common.monitor.stack;
import android.text.TextUtils;
import com.bytedance.accountseal.a.l;
import com.bytedance.apm.ApmContext;
import com.bytedance.apm.internal.ApmDelegate;
import com.bytedance.apm.thread.AsyncEventManager;
import com.bytedance.apm.util.UrlUtils;
import com.bytedance.article.common.monitor.stack.HttpUtil;
import java.util.LinkedList;
import org.json.JSONArray;
import org.json.JSONObject;
public class b implements AsyncEventManager.IMonitorTimeTask {
public static String f12709a = "https://mon.zijieapi.com/monitor/collect/c/exception";
public static final Object d = new Object();
private static volatile b i;
private static volatile a j;
public volatile int f12710b;
public volatile JSONObject f12711c;
public final LinkedList<e> e = new LinkedList<>();
private volatile long f;
private volatile boolean g;
private volatile long h;
private volatile com.bytedance.article.common.monitor.stack.a k;
public interface a {
void a(String str);
}
private b() {
AsyncEventManager.getInstance().addTimeTask(this);
this.k = new com.bytedance.article.common.monitor.stack.a();
}
public static b a() {
if (i == null) {
synchronized (d) {
if (i == null) {
i = new b();
}
}
}
return i;
}
private void c() {
this.f = System.currentTimeMillis();
AsyncEventManager.getInstance().submitTask(new Runnable() {
@Override
public void run() {
try {
LinkedList linkedList = new LinkedList();
synchronized (b.d) {
linkedList.addAll(b.this.e);
b.this.e.clear();
b.this.f12710b = 0;
}
if (linkedList.isEmpty()) {
return;
}
JSONObject jSONObject = new JSONObject();
JSONArray jSONArray = new JSONArray();
while (!linkedList.isEmpty()) {
e eVar = (e) linkedList.poll();
if (eVar != null) {
jSONArray.put(new JSONObject(eVar.f12714b));
}
}
jSONObject.put(l.n, jSONArray);
if (b.this.f12711c == null) {
b.this.f12711c = ApmContext.getHeader();
}
jSONObject.put("header", b.this.f12711c);
b.this.a(b.f12709a, jSONObject.toString());
} catch (Throwable th) {
th.printStackTrace();
}
}
});
}
public boolean b() {
if (ApmDelegate.a().e && !ApmDelegate.a().a("exception_filter_network")) {
return true;
}
return false;
}
public static void a(String str) {
f12709a = str;
}
public static void a(a aVar) {
if (j == null) {
j = aVar;
}
}
boolean b(String str) {
return ApmDelegate.a().a(str);
}
@Override
public void onTimeEvent(long j2) {
try {
if (this.k != null) {
this.k.a();
}
long currentTimeMillis = System.currentTimeMillis();
if ((currentTimeMillis - this.f > 1200000 && this.f12710b > 0) || this.f12710b > 20) {
c();
}
if (this.g && currentTimeMillis - this.h > 1800000) {
this.g = false;
}
} catch (Throwable th) {
th.printStackTrace();
}
}
public void a(String str, String str2) {
try {
if (ApmDelegate.a().e) {
HttpUtil.a(1048576L, UrlUtils.addParamsToURL(str, ApmContext.getQueryParamsMap()), str2.getBytes(), HttpUtil.CompressType.GZIP, "application/json; charset=utf-8", true);
}
} catch (Throwable th) {
int i2 = -1;
if (th instanceof HttpResponseException) {
i2 = th.getStatusCode();
}
if (i2 >= 500 && i2 <= 600) {
this.h = System.currentTimeMillis();
this.g = true;
}
}
}
public void a(Throwable th, String str) {
try {
StackTraceElement[] stackTrace = th.getStackTrace();
String className = stackTrace[0].getClassName();
String methodName = stackTrace[0].getMethodName();
int lineNumber = stackTrace[0].getLineNumber();
String a2 = d.a(th);
JSONObject jSONObject = new JSONObject();
jSONObject.put("event_type", "exception");
jSONObject.put("timestamp", System.currentTimeMillis());
jSONObject.put("class_ref", className);
jSONObject.put("method", methodName);
jSONObject.put("line_num", lineNumber);
jSONObject.put("stack", a2);
jSONObject.put("exception_type", 1);
jSONObject.put("is_core", 1);
jSONObject.put("message", str);
JSONObject jSONObject2 = new JSONObject();
JSONArray jSONArray = new JSONArray();
jSONArray.put(jSONObject);
jSONObject2.put(l.n, jSONArray);
if (this.f12711c == null) {
this.f12711c = ApmContext.getHeader();
}
jSONObject2.put("header", this.f12711c);
HttpUtil.a(1048576L, UrlUtils.addParamsToURL(f12709a, ApmContext.getQueryParamsMap()), jSONObject2.toString().getBytes(), HttpUtil.CompressType.GZIP, "application/json; charset=utf-8", true);
} catch (Throwable unused) {
}
}
public void a(StackTraceElement stackTraceElement, String str, String str2) {
try {
String className = stackTraceElement.getClassName();
String methodName = stackTraceElement.getMethodName();
int lineNumber = stackTraceElement.getLineNumber();
JSONObject jSONObject = new JSONObject();
jSONObject.put("event_type", "exception");
jSONObject.put("timestamp", System.currentTimeMillis());
jSONObject.put("class_ref", className);
jSONObject.put("method", methodName);
jSONObject.put("line_num", lineNumber);
jSONObject.put("stack", str);
jSONObject.put("exception_type", 1);
jSONObject.put("is_core", 1);
jSONObject.put("message", str2);
JSONObject jSONObject2 = new JSONObject();
JSONArray jSONArray = new JSONArray();
jSONArray.put(jSONObject);
jSONObject2.put(l.n, jSONArray);
if (this.f12711c == null) {
this.f12711c = ApmContext.getHeader();
}
jSONObject2.put("header", this.f12711c);
HttpUtil.a(1048576L, UrlUtils.addParamsToURL(f12709a, ApmContext.getQueryParamsMap()), jSONObject2.toString().getBytes(), HttpUtil.CompressType.GZIP, "application/json; charset=utf-8", true);
} catch (Throwable unused) {
}
}
public void a(String str, String str2, String str3, boolean z) {
try {
if (!TextUtils.isEmpty(str) && !TextUtils.isEmpty(str2)) {
boolean z2 = false;
if (z) {
JSONObject jSONObject = new JSONObject(str2);
jSONObject.put("log_type", "log_exception");
if (str3 != null) {
if (str3.length() > 10240) {
jSONObject.put("extraMessage", str3.substring(0, 10240));
} else {
jSONObject.put("extraMessage", str3);
}
}
if (j != null) {
j.a(jSONObject.toString());
}
}
if (!ApmDelegate.a().e) {
if (this.k != null) {
this.k.a(str, str2);
return;
}
return;
}
boolean b2 = b(str);
boolean b3 = ApmDelegate.a().b(str3);
if ((!b2 && !b3) || this.g) {
return;
}
synchronized (d) {
int size = this.e.size();
if (size >= 20) {
z2 = true;
}
this.e.add(new e(str, str2));
this.f12710b = size + 1;
}
if (z2) {
c();
}
}
} catch (Throwable th) {
th.printStackTrace();
}
}
}