<commit_before>/*
 * Android SDK for Piwik
 *
 * @link https://github.com/piwik/piwik-android-sdk
 * @license https://github.com/piwik/piwik-sdk-android/blob/master/LICENSE BSD-3 Clause
 */

package org.piwik.sdk;

import android.app.Application;
import android.content.Context;
import android.content.SharedPreferences;

import java.net.MalformedURLException;
import java.util.HashMap;


public class Piwik {
    public static final String LOGGER_PREFIX = "PIWIK:";

    private final static Object lock = new Object();

    private static HashMap<Application, Piwik> applications = new HashMap<Application, Piwik>();

    private Application application;

    private boolean optOut = false;

    private boolean dryRun = false;

    protected final static Thread.UncaughtExceptionHandler defaultUEH = Thread.getDefaultUncaughtExceptionHandler();

    private Piwik(Application application) {
        this.application = application;
    }

    public static Piwik getInstance(Application application) {
        synchronized (lock) {
            Piwik piwik = applications.get(application);
            if (piwik != null) {
                return piwik;
            }
            piwik = new Piwik(application);
            applications.put(application, piwik);
            return piwik;
        }
    }

    /**
     * @param trackerUrl (required) Tracking HTTP API endpoint, for example, http://your-piwik-domain.tld/piwik.php
     * @param siteId     (required) id of site
     * @param authToken  (optional) could be null or valid auth token. @deprecated since Piwik 2.8.
     *
     * @return Tracker object
     * @throws MalformedURLException
     */
    public Tracker newTracker(String trackerUrl, int siteId, String authToken) throws MalformedURLException {
        return new Tracker(trackerUrl, siteId, authToken, this);
    }

    public Tracker newTracker(String trackerUrl, int siteId) throws MalformedURLException {
        return new Tracker(trackerUrl, siteId, null, this);
    }<commit_msg>The way this is locked we can just use 'synchronized' on the method.<commit_after>/*
 * Android SDK for Piwik
 *
 * @link https://github.com/piwik/piwik-android-sdk
 * @license https://github.com/piwik/piwik-sdk-android/blob/master/LICENSE BSD-3 Clause
 */

package org.piwik.sdk;

import android.app.Application;
import android.content.Context;
import android.content.SharedPreferences;

import java.net.MalformedURLException;
import java.util.HashMap;


public class Piwik {
    public static final String LOGGER_PREFIX = "PIWIK:";

    private static HashMap<Application, Piwik> applications = new HashMap<Application, Piwik>();

    private Application application;

    private boolean optOut = false;

    private boolean dryRun = false;

    protected final static Thread.UncaughtExceptionHandler defaultUEH = Thread.getDefaultUncaughtExceptionHandler();

    private Piwik(Application application) {
        this.application = application;
    }

    public static synchronized Piwik getInstance(Application application) {
        Piwik piwik = applications.get(application);
        if (piwik != null) {
            return piwik;
        }
        piwik = new Piwik(application);
        applications.put(application, piwik);
        return piwik;
    }

    /**
     * @param trackerUrl (required) Tracking HTTP API endpoint, for example, http://your-piwik-domain.tld/piwik.php
     * @param siteId     (required) id of site
     * @param authToken  (optional) could be null or valid auth token. @deprecated since Piwik 2.8.
     *
     * @return Tracker object
     * @throws MalformedURLException
     */
    public Tracker newTracker(String trackerUrl, int siteId, String authToken) throws MalformedURLException {
        return new Tracker(trackerUrl, siteId, authToken, this);
    }

    public Tracker newTracker(String trackerUrl, int siteId) throws MalformedURLException {
        return new Tracker(trackerUrl, siteId, null, this);
    }
{'fraction_non_alphanumeric': 0.08850226928895613, 'fraction_numerical': 0.0015128593040847202, 'mean_word_length': 3.2292110874200426, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 4, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4222597', 'n_tokens_mistral': 1109, 'n_tokens_neox': 1067, 'n_words': 316}