All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.ksyun.ks3.signer.internal.SdkThreadLocalsRegistry Maven / Gradle / Ivy


package com.ksyun.ks3.signer.internal;


import com.ksyun.ks3.annotation.SdkProtectedApi;

import java.util.ArrayList;
import java.util.List;

@SdkProtectedApi
public final class SdkThreadLocalsRegistry {

    private static final List> threadLocals = new ArrayList>();

    private SdkThreadLocalsRegistry() {
        // prevent instantiation
    }

    /**
     * Registers {@link ThreadLocal} objects in use by the AWS SDK so that their values can 
     * be removed via the {@link #remove()} method.
     *
     * 

To avoid memory leaks and reduce contention this method should only be called when * setting static final locations (for example finals in enums or static final fields). * * @param threadLocal ThreadLocal to register * @return the input ThreadLocal */ public static synchronized ThreadLocal register(ThreadLocal threadLocal) { threadLocals.add(threadLocal); return threadLocal; } public synchronized static void remove() { for (ThreadLocal t: threadLocals) { t.remove(); } } }





© 2015 - 2025 Weber Informatics LLC | Privacy Policy