导航菜单

页面标题

页面副标题

CityMall v1.42.1 - SpotlightIntegration.java 源代码

正在查看: CityMall v1.42.1 应用的 SpotlightIntegration.java JAVA 源代码文件

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


package io.sentry;

import io.sentry.SentryOptions;
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.ApiStatus$Internal;

@ApiStatus$Internal
public final class SpotlightIntegration implements Integration, SentryOptions.BeforeEnvelopeCallback, Closeable {
    private SentryOptions a;
    private ILogger b = C0331a0.e();
    private ISentryExecutorService c = C0375f0.e();

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

    private void p(HttpURLConnection httpURLConnection) {
        try {
            httpURLConnection.getInputStream().close();
        } catch (IOException unused) {
        } catch (Throwable th) {
            httpURLConnection.disconnect();
            throw th;
        }
        httpURLConnection.disconnect();
    }

    private HttpURLConnection u(String str) {
        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;
    }

    @Override
    public void c(final Q0 q0, C0437z c0437z) {
        try {
            this.c.submit(new Runnable() {
                @Override
                public final void run() {
                    SpotlightIntegration.this.y(q0);
                }
            });
        } catch (RejectedExecutionException e) {
            this.b.b(EnumC0433x1.WARNING, "Spotlight envelope submission rejected.", e);
        }
    }

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

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

    public String v() {
        SentryOptions sentryOptions = this.a;
        return (sentryOptions == null || sentryOptions.getSpotlightConnectionUrl() == null) ? io.sentry.util.p.a() ? "http://10.0.2.2:8969/stream" : "http://localhost:8969/stream" : this.a.getSpotlightConnectionUrl();
    }
}