<commit_before>import java.io.IOException;
import java.util.List;

import org.json.JSONException;
import org.json.JSONObject;

import com.rabbitmq.client.Channel;
import com.rabbitmq.client.Connection;
import com.rabbitmq.client.ConnectionFactory;
import com.rabbitmq.client.ConsumerCancelledException;
import com.rabbitmq.client.MessageProperties;
import com.rabbitmq.client.QueueingConsumer;
import com.rabbitmq.client.ShutdownSignalException;

public class Worker implements Runnable {

    private static final String IN_QUEUE_NAME = "raw-events";
    private static final String OUT_QUEUE_NAME = "events-with-iso";

    public static JSONObject addIsoToEvent(JSONObject event, int isoNumber) {
        String isoNumberAsString = new Integer(isoNumber).toString();
        try {
            JSONObject actor = (JSONObject) event.get("actor");
            actor.put("country_iso", isoNumberAsString);
        } catch (JSONException e) {
            e.printStackTrace();
        }
        return event;
    }

    public static String extractLocationFromEvent(JSONObject event) {
        try {
            if (event.has("actor")) {
                JSONObject actor = (JSONObject) event.get("actor");
                if (actor.has("location")) {<commit_msg>Check for actor being JSON null<commit_after>import java.io.IOException;
import java.util.List;

import org.json.JSONException;
import org.json.JSONObject;

import com.rabbitmq.client.Channel;
import com.rabbitmq.client.Connection;
import com.rabbitmq.client.ConnectionFactory;
import com.rabbitmq.client.ConsumerCancelledException;
import com.rabbitmq.client.MessageProperties;
import com.rabbitmq.client.QueueingConsumer;
import com.rabbitmq.client.ShutdownSignalException;

public class Worker implements Runnable {

    private static final String IN_QUEUE_NAME = "raw-events";
    private static final String OUT_QUEUE_NAME = "events-with-iso";

    public static JSONObject addIsoToEvent(JSONObject event, int isoNumber) {
        String isoNumberAsString = new Integer(isoNumber).toString();
        try {
            JSONObject actor = (JSONObject) event.get("actor");
            actor.put("country_iso", isoNumberAsString);
        } catch (JSONException e) {
            e.printStackTrace();
        }
        return event;
    }

    public static String extractLocationFromEvent(JSONObject event) {
        try {
            if (event.has("actor")) {
                JSONObject actor = (JSONObject) event.get("actor");
                if (actor.has("location") && !actor.isNull("location")) {
{'fraction_non_alphanumeric': 0.09910261412407335, 'fraction_numerical': 0.0, 'mean_word_length': 3.4283246977547495, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, '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': '3707475', 'n_tokens_mistral': 717, 'n_tokens_neox': 684, 'n_words': 160}