<commit_before>import org.apache.commons.io.FileUtils

import com.google.api.client.auth.oauth2.Credential
import com.google.api.client.auth.oauth2.MemoryCredentialStore
import com.google.api.client.extensions.java6.auth.oauth2.AuthorizationCodeInstalledApp
import com.google.api.client.extensions.jdo.auth.oauth2.JdoCredentialStore
import com.google.api.client.extensions.jetty.auth.oauth2.LocalServerReceiver
import com.google.api.client.googleapis.auth.oauth2.GoogleAuthorizationCodeFlow
import com.google.api.client.googleapis.auth.oauth2.GoogleClientSecrets
import com.google.api.client.http.GenericUrl
import com.google.api.client.http.HttpTransport
import com.google.api.client.http.javanet.NetHttpTransport
import com.google.api.client.json.JsonFactory
import com.google.api.client.json.jackson2.JacksonFactory
import com.google.api.services.oauth2.Oauth2
import com.google.api.services.oauth2.model.Tokeninfo
import com.google.api.services.oauth2.model.Userinfo

import java.io.File
import java.io.IOException
import java.util.Arrays
import java.util.List
import javax.jdo.JDOHelper

class CodeFlow {
  private List<String> scopes = Arrays.asList("https://www.googleapis.com/auth/userinfo.profile", "https://www.googleapis.com/auth/userinfo.email", "https://www.googleapis.com/auth/fusiontables")
  private MemoryCredentialStore credentialStore = new MemoryCredentialStore()
  private GoogleClientSecrets secrets;

  public setSecrets(context) {
    secrets = GoogleClientSecrets.load(new JacksonFactory(), context.getResourceAsStream("client_secrets.json"))
  }
  
  public build() {
    return new GoogleAuthorizationCodeFlow.Builder(new NetHttpTransport(), new JacksonFactory(), secrets, scopes).setCredentialStore(credentialStore).setAccessType("offline").build()
  }

  private static final INSTANCE = new CodeFlow()
  static synchronized getInstance(){ return INSTANCE }
  private CodeFlow() {}
}<commit_msg>Only create HTTP/JSON factories once.<commit_after>import org.apache.commons.io.FileUtils

import com.google.api.client.auth.oauth2.Credential
import com.google.api.client.auth.oauth2.MemoryCredentialStore
import com.google.api.client.extensions.java6.auth.oauth2.AuthorizationCodeInstalledApp
import com.google.api.client.extensions.jdo.auth.oauth2.JdoCredentialStore
import com.google.api.client.extensions.jetty.auth.oauth2.LocalServerReceiver
import com.google.api.client.googleapis.auth.oauth2.GoogleAuthorizationCodeFlow
import com.google.api.client.googleapis.auth.oauth2.GoogleClientSecrets
import com.google.api.client.http.GenericUrl
import com.google.api.client.http.HttpTransport
import com.google.api.client.http.javanet.NetHttpTransport
import com.google.api.client.json.JsonFactory
import com.google.api.client.json.jackson2.JacksonFactory
import com.google.api.services.oauth2.Oauth2
import com.google.api.services.oauth2.model.Tokeninfo
import com.google.api.services.oauth2.model.Userinfo

import java.io.File
import java.io.IOException
import java.util.Arrays
import java.util.List
import javax.jdo.JDOHelper

class CodeFlow {
  private List<String> scopes = Arrays.asList("https://www.googleapis.com/auth/userinfo.profile", "https://www.googleapis.com/auth/userinfo.email", "https://www.googleapis.com/auth/fusiontables")
  private MemoryCredentialStore credentialStore = new MemoryCredentialStore()
  private GoogleClientSecrets secrets;

  public static final HttpTransport HTTP_TRANSPORT = new NetHttpTransport()
  public static final JsonFactory JSON_FACTORY = new JacksonFactory()

  public setSecrets(context) {
    secrets = GoogleClientSecrets.load(JSON_FACTORY, context.getResourceAsStream("client_secrets.json"))
  }
  
  public build() {
    return new GoogleAuthorizationCodeFlow.Builder(HTTP_TRANSPORT, JSON_FACTORY, secrets, scopes).setCredentialStore(credentialStore).setAccessType("offline").build()
  }

  private static final INSTANCE = new CodeFlow()
  static synchronized getInstance(){ return INSTANCE }
  private CodeFlow() {}
}
{'fraction_non_alphanumeric': 0.10418231905835211, 'fraction_numerical': 0.006511394941147007, 'mean_word_length': 6.069026548672566, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 6, 'lorem ipsum': 0, 'www.': 6, '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': '4417307', 'n_tokens_mistral': 1213, 'n_tokens_neox': 1199, 'n_words': 189}