导航菜单

页面标题

页面副标题

Oolka v2.4.42 - SpotlightIntegration.java 源代码

正在查看: Oolka v2.4.42 应用的 SpotlightIntegration.java JAVA 源代码文件

本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。


package io.sentry;

import io.sentry.SentryOptions;
import io.sentry.util.Platform;
import java.io.Closeable;
import java.io.IOException;
import java.io.OutputStream;
import java.net.HttpURLConnection;
import java.net.URI;
import java.util.concurrent.RejectedExecutionException;
import java.util.zip.GZIPOutputStream;
import org.jetbrains.annotations.NotNull;

public final class SpotlightIntegration implements w0, SentryOptions.c, Closeable {
    public SentryOptions a;

    @NotNull
    public ILogger b = p1.e();

    @NotNull
    public p0 c = v1.e();

    @Override
    public void a(@NotNull final h3 h3Var, Hint hint) {
        try {
            this.c.submit(new Runnable() {
                @Override
                public final void run() {
                    SpotlightIntegration.this.g(h3Var);
                }
            });
        } catch (RejectedExecutionException e) {
            this.b.b(SentryLevel.WARNING, "Spotlight envelope submission rejected.", e);
        }
    }

    @Override
    public void c(@NotNull g0 g0Var, @NotNull SentryOptions sentryOptions) {
        this.a = sentryOptions;
        this.b = sentryOptions.getLogger();
        if (sentryOptions.getBeforeEnvelopeCallback() != null || !sentryOptions.isEnableSpotlight()) {
            this.b.c(SentryLevel.DEBUG, "SpotlightIntegration is not enabled. BeforeEnvelopeCallback is already set or spotlight is not enabled.", new Object[0]);
            return;
        }
        this.c = new SentryExecutorService();
        sentryOptions.setBeforeEnvelopeCallback(this);
        this.b.c(SentryLevel.DEBUG, "SpotlightIntegration enabled.", new Object[0]);
    }

    @Override
    public void close() throws IOException {
        this.c.a(0L);
        SentryOptions sentryOptions = this.a;
        if (sentryOptions == null || sentryOptions.getBeforeEnvelopeCallback() != this) {
            return;
        }
        this.a.setBeforeEnvelopeCallback(null);
    }

    public final void d(@NotNull HttpURLConnection httpURLConnection) {
        try {
            httpURLConnection.getInputStream().close();
        } catch (IOException unused) {
        } catch (Throwable th) {
            httpURLConnection.disconnect();
            throw th;
        }
        httpURLConnection.disconnect();
    }

    @NotNull
    public final HttpURLConnection e(@NotNull String str) throws Exception {
        HttpURLConnection httpURLConnection = (HttpURLConnection) URI.create(str).toURL().openConnection();
        httpURLConnection.setReadTimeout(1000);
        httpURLConnection.setConnectTimeout(1000);
        httpURLConnection.setRequestMethod("POST");
        httpURLConnection.setDoOutput(true);
        httpURLConnection.setRequestProperty("Content-Encoding", "gzip");
        httpURLConnection.setRequestProperty("Content-Type", "application/x-sentry-envelope");
        httpURLConnection.setRequestProperty("Accept", "application/json");
        httpURLConnection.setRequestProperty("Connection", "close");
        httpURLConnection.connect();
        return httpURLConnection;
    }

    public String f() {
        SentryOptions sentryOptions = this.a;
        return (sentryOptions == null || sentryOptions.getSpotlightConnectionUrl() == null) ? Platform.a() ? "http://10.0.2.2:8969/stream" : "http://localhost:8969/stream" : this.a.getSpotlightConnectionUrl();
    }

    public final void g(@NotNull h3 h3Var) {
        try {
            if (this.a == null) {
                throw new IllegalArgumentException("SentryOptions are required to send envelopes.");
            }
            HttpURLConnection e = e(f());
            try {
                OutputStream outputStream = e.getOutputStream();
                try {
                    GZIPOutputStream gZIPOutputStream = new GZIPOutputStream(outputStream);
                    try {
                        this.a.getSerializer().b(h3Var, gZIPOutputStream);
                        gZIPOutputStream.close();
                        if (outputStream != null) {
                            outputStream.close();
                        }
                        this.b.c(SentryLevel.DEBUG, "Envelope sent to spotlight: %d", Integer.valueOf(e.getResponseCode()));
                    } finally {
                    }
                } finally {
                }
            } catch (Throwable th) {
                try {
                    this.b.b(SentryLevel.ERROR, "An exception occurred while submitting the envelope to the Sentry server.", th);
                    this.b.c(SentryLevel.DEBUG, "Envelope sent to spotlight: %d", Integer.valueOf(e.getResponseCode()));
                } catch (Throwable th2) {
                    this.b.c(SentryLevel.DEBUG, "Envelope sent to spotlight: %d", Integer.valueOf(e.getResponseCode()));
                    d(e);
                    throw th2;
                }
            }
            d(e);
        } catch (Exception e2) {
            this.b.b(SentryLevel.ERROR, "An exception occurred while creating the connection to spotlight.", e2);
        }
    }
}