#vulnerable code 
                                public void load(){
        File configFile = new File(HISTORY_FILE);
        if (configFile.exists()) {
            JSONParser parser = new JSONParser();
            try {
                JSONObject root = (JSONObject)parser.parse(new FileReader(HISTORY_FILE));
                JSONArray msgsArray = (JSONArray) root.get("messages");
                messages = new String[msgsArray.size()];
                for (int i = 0; i < msgsArray.size(); i++) {
                    messages[i] = (String) msgsArray.get(i);
                }
            } catch (Exception e) {
                logger.error("Error during loading history file: ", e);
            }
        }else {
            try {
                FileWriter fileWriter = new FileWriter(HISTORY_FILE);
                JSONObject root = new JSONObject();
                root.put("messages", new JSONArray());
                fileWriter.write(root.toJSONString());
                fileWriter.flush();
                fileWriter.close();
            } catch (IOException e) {
                logger.error("Error during creating history file: ", e);
            }
        }
    } 
                            #location 23 
                            #vulnerability type RESOURCE_LEAK
#fixed code
                                public void load(){
        File configFile = new File(HISTORY_FILE);
        if (configFile.exists()) {
            JSONParser parser = new JSONParser();
            try {
                JSONObject root = (JSONObject)parser.parse(new FileReader(HISTORY_FILE));
                JSONArray msgsArray = (JSONArray) root.get("messages");
                messages = new String[msgsArray.size()];
                for (int i = 0; i < msgsArray.size(); i++) {
                    messages[i] = (String) msgsArray.get(i);
                }
            } catch (Exception e) {
                logger.error("Error during loading history file: ", e);
            }
        }else {
            createEmptyFile();
        }
    }