96 lines
		
	
	
		
			3.6 KiB
		
	
	
	
		
			Java
		
	
	
	
	
	
			
		
		
	
	
			96 lines
		
	
	
		
			3.6 KiB
		
	
	
	
		
			Java
		
	
	
	
	
	
package com.google.common.util.concurrent;
 | 
						|
 | 
						|
import com.google.common.collect.ImmutableSet;
 | 
						|
import com.google.common.collect.Lists;
 | 
						|
import com.google.common.collect.MapMaker;
 | 
						|
import java.util.ArrayList;
 | 
						|
import java.util.Arrays;
 | 
						|
import java.util.logging.Logger;
 | 
						|
 | 
						|
/* loaded from: classes.dex */
 | 
						|
public class CycleDetectingLockFactory {
 | 
						|
 | 
						|
    private static class ExampleStackTrace extends IllegalStateException {
 | 
						|
        static final StackTraceElement[] EMPTY_STACK_TRACE = new StackTraceElement[0];
 | 
						|
        static final ImmutableSet<String> EXCLUDED_CLASS_NAMES = ImmutableSet.of(CycleDetectingLockFactory.class.getName(), ExampleStackTrace.class.getName(), LockGraphNode.class.getName());
 | 
						|
 | 
						|
        ExampleStackTrace(LockGraphNode lockGraphNode, LockGraphNode lockGraphNode2) {
 | 
						|
            super(lockGraphNode.a() + " -> " + lockGraphNode2.a());
 | 
						|
            StackTraceElement[] stackTrace = getStackTrace();
 | 
						|
            int length = stackTrace.length;
 | 
						|
            for (int i = 0; i < length; i++) {
 | 
						|
                if (WithExplicitOrdering.class.getName().equals(stackTrace[i].getClassName())) {
 | 
						|
                    setStackTrace(EMPTY_STACK_TRACE);
 | 
						|
                    return;
 | 
						|
                } else {
 | 
						|
                    if (!EXCLUDED_CLASS_NAMES.contains(stackTrace[i].getClassName())) {
 | 
						|
                        setStackTrace((StackTraceElement[]) Arrays.copyOfRange(stackTrace, i, length));
 | 
						|
                        return;
 | 
						|
                    }
 | 
						|
                }
 | 
						|
            }
 | 
						|
        }
 | 
						|
    }
 | 
						|
 | 
						|
    private static class LockGraphNode {
 | 
						|
        final String a;
 | 
						|
 | 
						|
        String a() {
 | 
						|
            return this.a;
 | 
						|
        }
 | 
						|
    }
 | 
						|
 | 
						|
    public enum Policies implements Policy {
 | 
						|
        THROW { // from class: com.google.common.util.concurrent.CycleDetectingLockFactory.Policies.1
 | 
						|
        },
 | 
						|
        WARN { // from class: com.google.common.util.concurrent.CycleDetectingLockFactory.Policies.2
 | 
						|
        },
 | 
						|
        DISABLED { // from class: com.google.common.util.concurrent.CycleDetectingLockFactory.Policies.3
 | 
						|
        }
 | 
						|
    }
 | 
						|
 | 
						|
    public interface Policy {
 | 
						|
    }
 | 
						|
 | 
						|
    public static final class PotentialDeadlockException extends ExampleStackTrace {
 | 
						|
        private final ExampleStackTrace conflictingStackTrace;
 | 
						|
 | 
						|
        public ExampleStackTrace getConflictingStackTrace() {
 | 
						|
            return this.conflictingStackTrace;
 | 
						|
        }
 | 
						|
 | 
						|
        @Override // java.lang.Throwable
 | 
						|
        public String getMessage() {
 | 
						|
            StringBuilder sb = new StringBuilder(super.getMessage());
 | 
						|
            for (Throwable th = this.conflictingStackTrace; th != null; th = th.getCause()) {
 | 
						|
                sb.append(", ");
 | 
						|
                sb.append(th.getMessage());
 | 
						|
            }
 | 
						|
            return sb.toString();
 | 
						|
        }
 | 
						|
 | 
						|
        private PotentialDeadlockException(LockGraphNode lockGraphNode, LockGraphNode lockGraphNode2, ExampleStackTrace exampleStackTrace) {
 | 
						|
            super(lockGraphNode, lockGraphNode2);
 | 
						|
            this.conflictingStackTrace = exampleStackTrace;
 | 
						|
            initCause(exampleStackTrace);
 | 
						|
        }
 | 
						|
    }
 | 
						|
 | 
						|
    public static final class WithExplicitOrdering<E extends Enum<E>> extends CycleDetectingLockFactory {
 | 
						|
    }
 | 
						|
 | 
						|
    static {
 | 
						|
        MapMaker mapMaker = new MapMaker();
 | 
						|
        mapMaker.g();
 | 
						|
        mapMaker.f();
 | 
						|
        Logger.getLogger(CycleDetectingLockFactory.class.getName());
 | 
						|
        new ThreadLocal<ArrayList<LockGraphNode>>() { // from class: com.google.common.util.concurrent.CycleDetectingLockFactory.1
 | 
						|
            /* JADX INFO: Access modifiers changed from: protected */
 | 
						|
            @Override // java.lang.ThreadLocal
 | 
						|
            public ArrayList<LockGraphNode> initialValue() {
 | 
						|
                return Lists.b(3);
 | 
						|
            }
 | 
						|
        };
 | 
						|
    }
 | 
						|
}
 |