正在查看: Dostt v1.0.89 应用的 f.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
正在查看: Dostt v1.0.89 应用的 f.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
package io.sentry.cache;
import io.sentry.AbstractC1547j;
import io.sentry.B1;
import io.sentry.C;
import io.sentry.C1593t2;
import io.sentry.C1615y1;
import io.sentry.EnumC1550j2;
import io.sentry.EnumC1554k2;
import io.sentry.G2;
import io.sentry.ILogger;
import io.sentry.UncaughtExceptionHandlerIntegration;
import io.sentry.Y1;
import io.sentry.Z;
import java.io.BufferedInputStream;
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.ByteArrayInputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.FilenameFilter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.util.ArrayList;
import java.util.Date;
import java.util.Iterator;
import java.util.Map;
import java.util.UUID;
import java.util.WeakHashMap;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;
public class f extends c implements g {
private final CountDownLatch f;
private final Map o;
public f(C1593t2 c1593t2, String str, int i) {
super(c1593t2, str, i);
this.o = new WeakHashMap();
this.f = new CountDownLatch(1);
}
public static File B(String str) {
return new File(str, "session.json");
}
private synchronized File C(B1 b1) {
String str;
try {
if (this.o.containsKey(b1)) {
str = (String) this.o.get(b1);
} else {
String str2 = UUID.randomUUID() + ".envelope";
this.o.put(b1, str2);
str = str2;
}
} catch (Throwable th2) {
throw th2;
}
return new File(this.c.getAbsolutePath(), str);
}
public static File D(String str) {
return new File(str, "previous_session.json");
}
public static boolean E(File file, String str) {
return str.endsWith(".envelope");
}
private void F(C c) {
Date date;
Object g = io.sentry.util.j.g(c);
if (g instanceof io.sentry.hints.a) {
File D = D(this.c.getAbsolutePath());
if (!D.exists()) {
this.a.getLogger().c(EnumC1554k2.DEBUG, "No previous session file to end.", new Object[0]);
return;
}
ILogger logger = this.a.getLogger();
EnumC1554k2 enumC1554k2 = EnumC1554k2.WARNING;
logger.c(enumC1554k2, "Previous session is not ended, we'd need to end it.", new Object[0]);
try {
BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(new FileInputStream(D), c.e));
try {
G2 g2 = (G2) ((Z) this.b.a()).c(bufferedReader, G2.class);
if (g2 != null) {
io.sentry.hints.a aVar = (io.sentry.hints.a) g;
Long e = aVar.e();
if (e != null) {
date = AbstractC1547j.d(e.longValue());
Date k = g2.k();
if (k != null) {
if (date.before(k)) {
}
}
this.a.getLogger().c(enumC1554k2, "Abnormal exit happened before previous session start, not ending the session.", new Object[0]);
bufferedReader.close();
return;
}
date = null;
g2.q(G2.b.Abnormal, null, true, aVar.h());
g2.d(date);
L(D, g2);
}
bufferedReader.close();
} finally {
}
} catch (Throwable th2) {
this.a.getLogger().b(EnumC1554k2.ERROR, "Error processing previous session.", th2);
}
}
}
private void H(File file, B1 b1) {
Iterable c = b1.c();
if (!c.iterator().hasNext()) {
this.a.getLogger().c(EnumC1554k2.INFO, "Current envelope %s is empty", file.getAbsolutePath());
return;
}
Y1 y1 = (Y1) c.iterator().next();
if (!EnumC1550j2.Session.equals(y1.G().b())) {
this.a.getLogger().c(EnumC1554k2.INFO, "Current envelope has a different envelope type %s", y1.G().b());
return;
}
try {
BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(new ByteArrayInputStream(y1.E()), c.e));
try {
G2 g2 = (G2) ((Z) this.b.a()).c(bufferedReader, G2.class);
if (g2 == null) {
this.a.getLogger().c(EnumC1554k2.ERROR, "Item of type %s returned null by the parser.", y1.G().b());
} else {
L(file, g2);
}
bufferedReader.close();
} finally {
}
} catch (Throwable th2) {
this.a.getLogger().b(EnumC1554k2.ERROR, "Item failed to process.", th2);
}
}
private void J() {
try {
FileOutputStream fileOutputStream = new FileOutputStream(new File(this.a.getCacheDirPath(), "last_crash"));
try {
fileOutputStream.write(AbstractC1547j.g(AbstractC1547j.c()).getBytes(c.e));
fileOutputStream.flush();
fileOutputStream.close();
} finally {
}
} catch (Throwable th2) {
this.a.getLogger().b(EnumC1554k2.ERROR, "Error writing the crash marker file to the disk", th2);
}
}
private void K(File file, B1 b1) {
if (file.exists()) {
this.a.getLogger().c(EnumC1554k2.DEBUG, "Overwriting envelope to offline storage: %s", file.getAbsolutePath());
if (!file.delete()) {
this.a.getLogger().c(EnumC1554k2.ERROR, "Failed to delete: %s", file.getAbsolutePath());
}
}
try {
FileOutputStream fileOutputStream = new FileOutputStream(file);
try {
((Z) this.b.a()).b(b1, fileOutputStream);
fileOutputStream.close();
} finally {
}
} catch (Throwable th2) {
this.a.getLogger().a(EnumC1554k2.ERROR, th2, "Error writing Envelope %s to offline storage", file.getAbsolutePath());
}
}
private void L(File file, G2 g2) {
if (file.exists()) {
this.a.getLogger().c(EnumC1554k2.DEBUG, "Overwriting session to offline storage: %s", g2.j());
if (!file.delete()) {
this.a.getLogger().c(EnumC1554k2.ERROR, "Failed to delete: %s", file.getAbsolutePath());
}
}
try {
FileOutputStream fileOutputStream = new FileOutputStream(file);
try {
BufferedWriter bufferedWriter = new BufferedWriter(new OutputStreamWriter(fileOutputStream, c.e));
try {
((Z) this.b.a()).a(g2, bufferedWriter);
bufferedWriter.close();
fileOutputStream.close();
} finally {
}
} finally {
}
} catch (Throwable th2) {
this.a.getLogger().a(EnumC1554k2.ERROR, th2, "Error writing Session to offline storage: %s", g2.j());
}
}
private File[] y() {
File[] listFiles;
return (!h() || (listFiles = this.c.listFiles(new FilenameFilter() {
@Override
public final boolean accept(File file, String str) {
boolean E;
E = f.E(file, str);
return E;
}
})) == null) ? new File[0] : listFiles;
}
public static g z(C1593t2 c1593t2) {
String cacheDirPath = c1593t2.getCacheDirPath();
int maxCacheItems = c1593t2.getMaxCacheItems();
if (cacheDirPath != null) {
return new f(c1593t2, cacheDirPath, maxCacheItems);
}
c1593t2.getLogger().c(EnumC1554k2.WARNING, "cacheDirPath is null, returning NoOpEnvelopeCache", new Object[0]);
return io.sentry.transport.s.a();
}
public void A() {
this.f.countDown();
}
public void D1(B1 b1, C c) {
io.sentry.util.q.c(b1, "Envelope is required.");
s(y());
File B = B(this.c.getAbsolutePath());
File D = D(this.c.getAbsolutePath());
if (io.sentry.util.j.h(c, io.sentry.hints.l.class) && !B.delete()) {
this.a.getLogger().c(EnumC1554k2.WARNING, "Current envelope doesn't exist.", new Object[0]);
}
if (io.sentry.util.j.h(c, io.sentry.hints.a.class)) {
F(c);
}
if (io.sentry.util.j.h(c, io.sentry.hints.n.class)) {
if (B.exists()) {
this.a.getLogger().c(EnumC1554k2.WARNING, "Current session is not ended, we'd need to end it.", new Object[0]);
try {
BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(new FileInputStream(B), c.e));
try {
G2 g2 = (G2) ((Z) this.b.a()).c(bufferedReader, G2.class);
if (g2 != null) {
L(D, g2);
}
bufferedReader.close();
} finally {
}
} catch (Throwable th2) {
this.a.getLogger().b(EnumC1554k2.ERROR, "Error processing session.", th2);
}
}
H(B, b1);
boolean exists = new File(this.a.getCacheDirPath(), ".sentry-native/last_crash").exists();
if (!exists) {
File file = new File(this.a.getCacheDirPath(), "last_crash");
if (file.exists()) {
this.a.getLogger().c(EnumC1554k2.INFO, "Crash marker file exists, crashedLastRun will return true.", new Object[0]);
if (!file.delete()) {
this.a.getLogger().c(EnumC1554k2.ERROR, "Failed to delete the crash marker file. %s.", file.getAbsolutePath());
}
exists = true;
}
}
C1615y1.a().c(exists);
A();
}
File C = C(b1);
if (C.exists()) {
this.a.getLogger().c(EnumC1554k2.WARNING, "Not adding Envelope to offline storage because it already exists: %s", C.getAbsolutePath());
return;
}
this.a.getLogger().c(EnumC1554k2.DEBUG, "Adding Envelope to offline storage: %s", C.getAbsolutePath());
K(C, b1);
if (io.sentry.util.j.h(c, UncaughtExceptionHandlerIntegration.a.class)) {
J();
}
}
public boolean I() {
try {
return this.f.await(this.a.getSessionFlushTimeoutMillis(), TimeUnit.MILLISECONDS);
} catch (InterruptedException unused) {
Thread.currentThread().interrupt();
this.a.getLogger().c(EnumC1554k2.DEBUG, "Timed out waiting for previous session to flush.", new Object[0]);
return false;
}
}
@Override
public void M(B1 b1) {
io.sentry.util.q.c(b1, "Envelope is required.");
File C = C(b1);
if (!C.exists()) {
this.a.getLogger().c(EnumC1554k2.DEBUG, "Envelope was not cached: %s", C.getAbsolutePath());
return;
}
this.a.getLogger().c(EnumC1554k2.DEBUG, "Discarding envelope from cache: %s", C.getAbsolutePath());
if (C.delete()) {
return;
}
this.a.getLogger().c(EnumC1554k2.ERROR, "Failed to delete envelope: %s", C.getAbsolutePath());
}
@Override
public Iterator iterator() {
File[] y = y();
ArrayList arrayList = new ArrayList(y.length);
for (File file : y) {
try {
BufferedInputStream bufferedInputStream = new BufferedInputStream(new FileInputStream(file));
try {
arrayList.add(((Z) this.b.a()).d(bufferedInputStream));
bufferedInputStream.close();
} catch (Throwable th2) {
try {
bufferedInputStream.close();
} catch (Throwable th3) {
th2.addSuppressed(th3);
}
throw th2;
}
} catch (FileNotFoundException unused) {
this.a.getLogger().c(EnumC1554k2.DEBUG, "Envelope file '%s' disappeared while converting all cached files to envelopes.", file.getAbsolutePath());
} catch (IOException e) {
this.a.getLogger().b(EnumC1554k2.ERROR, String.format("Error while reading cached envelope from file %s", file.getAbsolutePath()), e);
}
}
return arrayList.iterator();
}
}