/*
 * Decompiled with CFR 0.152.
 * 
 * Could not load the following classes:
 *  com.l7tech.gateway.common.jdbc.InvalidPropertyException
 *  com.l7tech.gateway.common.jdbc.JdbcConnection
 *  com.l7tech.util.Background
 *  com.l7tech.util.ExceptionUtils
 *  com.l7tech.util.ResourceUtils
 *  com.mchange.v2.c3p0.ComboPooledDataSource
 */
package com.l7tech.server.jdbc;

import com.l7tech.gateway.common.jdbc.InvalidPropertyException;
import com.l7tech.gateway.common.jdbc.JdbcConnection;
import com.l7tech.server.jdbc.JdbcAdminImpl;
import com.l7tech.server.jdbc.r;
import com.l7tech.util.Background;
import com.l7tech.util.ExceptionUtils;
import com.l7tech.util.ResourceUtils;
import com.mchange.v2.c3p0.ComboPooledDataSource;
import java.sql.Connection;
import java.sql.SQLException;
import java.util.TimerTask;
import java.util.concurrent.Callable;
import java.util.logging.Level;
import javax.security.auth.Subject;

class g
implements Callable<String> {
    final JdbcConnection val$connection;
    final JdbcAdminImpl this$0;
    private static final String[] a;

    /*
     * Ignored method signature, as it can't be verified against descriptor
     */
    g(JdbcAdminImpl jdbcAdminImpl, JdbcConnection jdbcConnection) {
        this.this$0 = jdbcAdminImpl;
        this.val$connection = jdbcConnection;
    }

    @Override
    public String call() throws Exception {
        ComboPooledDataSource comboPooledDataSource;
        try {
            comboPooledDataSource = this.this$0.g.getTestConnectionPool(this.val$connection);
        }
        catch (InvalidPropertyException invalidPropertyException) {
            return invalidPropertyException.getMessage();
        }
        catch (RuntimeException runtimeException) {
            String[] stringArray = a;
            String string = stringArray[1];
            JdbcAdminImpl.access$000().log(Level.WARNING, stringArray[4] + ExceptionUtils.getMessage((Throwable)runtimeException), ExceptionUtils.getDebugException((Throwable)runtimeException));
            return stringArray[2];
        }
        Callable<String> callable = () -> this.lambda$call$0(comboPooledDataSource);
        try {
            if (this.this$0.a(this.val$connection)) {
                return Subject.callAs(null, callable);
            }
        }
        catch (InvalidPropertyException invalidPropertyException) {
            throw g.a((Exception)((Object)invalidPropertyException));
        }
        return callable.call();
    }

    /*
     * WARNING - Removed try catching itself - possible behaviour change.
     */
    private String lambda$call$0(ComboPooledDataSource comboPooledDataSource) throws Exception {
        Connection connection = null;
        try {
            connection = comboPooledDataSource.getConnection();
        }
        catch (SQLException sQLException) {
            try {
                Throwable throwable;
                try {
                    if (JdbcAdminImpl.access$100().isLoggable(Level.FINEST)) {
                        JdbcAdminImpl.access$200().log(Level.FINEST, ExceptionUtils.getStackTraceAsString((Throwable)sQLException));
                    }
                }
                catch (SQLException sQLException2) {
                    throw g.a(sQLException2);
                }
                Throwable throwable2 = comboPooledDataSource.getLastAcquisitionFailure(comboPooledDataSource.getUser(), comboPooledDataSource.getPassword());
                try {
                    throwable = throwable2 != null ? throwable2 : sQLException;
                }
                catch (SQLException sQLException3) {
                    throw g.a(sQLException3);
                }
                String[] stringArray = a;
                String string = stringArray[7] + ExceptionUtils.getMessage((Throwable)throwable);
                try {
                    if (JdbcAdminImpl.access$300().isLoggable(Level.FINEST)) {
                        JdbcAdminImpl.access$400().log(Level.FINEST, string);
                    }
                }
                catch (SQLException sQLException4) {
                    throw g.a(sQLException4);
                }
                String string2 = string;
                return string2;
            }
            catch (SQLException sQLException5) {
                String[] stringArray = a;
                String string = stringArray[8] + ExceptionUtils.getMessage((Throwable)sQLException);
                try {
                    if (JdbcAdminImpl.access$500().isLoggable(Level.FINEST)) {
                        JdbcAdminImpl.access$600().log(Level.FINEST, string + stringArray[3] + ExceptionUtils.getStackTraceAsString((Throwable)sQLException5));
                    }
                }
                catch (SQLException sQLException6) {
                    throw g.a(sQLException6);
                }
                String string3 = string;
                return string3;
            }
        }
        catch (Throwable throwable) {
            String[] stringArray = a;
            String string = stringArray[6] + throwable.getClass().getSimpleName() + stringArray[0];
            try {
                if (JdbcAdminImpl.access$700().isLoggable(Level.FINEST)) {
                    JdbcAdminImpl.access$800().log(Level.FINEST, string + stringArray[5] + ExceptionUtils.getStackTraceAsString((Throwable)throwable));
                }
            }
            catch (SQLException sQLException) {
                throw g.a(sQLException);
            }
            String string4 = string;
            return string4;
        }
        finally {
            ResourceUtils.closeQuietly((Connection)connection);
            Background.scheduleOneShot((TimerTask)new r(this, comboPooledDataSource), (long)0L);
        }
        return "";
    }

    private static Exception a(Exception exception) {
        return exception;
    }

    /*
     * Unable to fully structure code
     */
    static {
        block10: {
            block9: {
                var5 = new String[9];
                var3_1 = 0;
                var2_2 = "Hh(fO0a&=r%lP\"l\u001cy$4P5`\np%y\u00003j\u001bh)zGgl\u0007r.qC3f\u0007rn&=r%lP\"l\u001cy$4P5`\np%y\u00003j\u001bh)zGgl\u0007r.qC3f\u0007rn\u0002H\u0016'=r%lP\"l\u001cy$4P5`\np%y\u00003j\u001bh)zGgl\u0007r.qC3f\u0007rn4\u0002H\u0016\u0012\u001dr%lP\"l\u001cy$4E5}\u0007nl4";
                var4_3 = "Hh(fO0a&=r%lP\"l\u001cy$4P5`\np%y\u00003j\u001bh)zGgl\u0007r.qC3f\u0007rn&=r%lP\"l\u001cy$4P5`\np%y\u00003j\u001bh)zGgl\u0007r.qC3f\u0007rn\u0002H\u0016'=r%lP\"l\u001cy$4P5`\np%y\u00003j\u001bh)zGgl\u0007r.qC3f\u0007rn4\u0002H\u0016\u0012\u001dr%lP\"l\u001cy$4E5}\u0007nl4".length();
                var1_4 = 7;
                var0_5 = -1;
lbl7:
                // 2 sources

                while (true) {
                    v0 = 24;
                    v1 = ++var0_5;
                    v2 = var2_2.substring(v1, v1 + var1_4);
                    v3 = -1;
                    break block9;
                    break;
                }
lbl13:
                // 1 sources

                while (true) {
                    var5[var3_1++] = g.a(v0, g.a(v2));
                    if ((var0_5 += var1_4) < var4_3) {
                        var1_4 = var2_2.charAt(var0_5);
                        ** continue;
                    }
                    var2_2 = "\u001ai-nW5pSd4aU9w\u0007n4a\u001b,f\u001cw>}O5q\u0000'(jO(}\u001d`u/1(\u001ai-nW5pSd4aU9w\u0007n4a\u001b,f\u001cw>}O5q\u0000'(jO(}\u001d`u/1";
                    var4_3 = "\u001ai-nW5pSd4aU9w\u0007n4a\u001b,f\u001cw>}O5q\u0000'(jO(}\u001d`u/1(\u001ai-nW5pSd4aU9w\u0007n4a\u001b,f\u001cw>}O5q\u0000'(jO(}\u001d`u/1".length();
                    var1_4 = 40;
                    var0_5 = -1;
lbl22:
                    // 2 sources

                    while (true) {
                        v0 = 3;
                        v4 = ++var0_5;
                        v2 = var2_2.substring(v4, v4 + var1_4);
                        v3 = 0;
                        break block9;
                        break;
                    }
                    break;
                }
lbl28:
                // 1 sources

                while (true) {
                    var5[var3_1++] = g.a(v0, g.a(v2));
                    if ((var0_5 += var1_4) < var4_3) {
                        var1_4 = var2_2.charAt(var0_5);
                        ** continue;
                    }
                    break block10;
                    break;
                }
            }
            switch (v3) {
                default: {
                    ** continue;
                }
                ** case 0:
lbl39:
                // 1 sources

                ** continue;
            }
        }
        g.a = var5;
    }

    private static char[] a(String string) {
        char[] cArray = string.toCharArray();
        if (cArray.length < 2) {
            cArray = cArray;
            cArray[0] = (char)(cArray[0] ^ 0x17);
        }
        return cArray;
    }

    /*
     * Handled impossible loop by duplicating code
     * Enabled aggressive block sorting
     */
    private static String a(int n2, char[] cArray) {
        char[] cArray2;
        block11: {
            int n3;
            int n4;
            int n5;
            block10: {
                n5 = n2;
                cArray2 = cArray;
                n4 = cArray.length;
                n3 = 0;
                if (!true) break block10;
                n4 = n4;
                if (n4 <= n3) break block11;
            }
            do {
                n5 = n5;
                cArray2 = cArray2;
                int n6 = n3;
                cArray2[n6] = (char)(cArray2[n6] ^ (n5 ^ (switch (n3 % 7) {
                    case 0 -> 112;
                    case 1 -> 4;
                    case 2 -> 88;
                    case 3 -> 12;
                    case 4 -> 56;
                    case 5 -> 95;
                    default -> 23;
                })));
                ++n3;
                n4 = n4;
            } while (n4 > n3);
        }
        return new String(cArray2).intern();
    }
}

