#vulnerable code 
                             public static void main(String[] args) throws IOException {
		IngestReader ir = new IngestReader();

		try {
			if(args.length < 2) {
				throw new IngestException();
			}
			
			String command = args[0];
			if(args.length == 2) {
				if(command.equals("-gx")) {
					XmlHelper.generateXml(args[1]);
				}
				else if(command.equals("-b")) {
					//In the case of bills, we also need to make sure we reindex all ammended versions
					Bill bill = (Bill)ir.loadObject(args[1], Bill.class);
					if(ir.reindexAmendedVersions((Bill)bill))
						bill.setLuceneActive(false);
					ir.indexSenateObject(bill);
				}
				else if(command.equals("-c")) {
					ir.indexSenateObject(ir.loadObject(args[1], Calendar.class));
				}
				else if(command.equals("-a")) {
					ir.indexSenateObject(ir.loadObject(args[1], Agenda.class));
				}
				else if(command.equals("-t")) {
					ir.indexSenateObject(ir.loadObject(args[1], Transcript.class));
				}
				
				else {
					throw new IngestException();
				}
			}
			else if(args.length == 3){
				if(command.equals("-i")) {
					WRITE_DIRECTORY = args[1];
					ir.processPath(args[2]);
				}
				else if(command.equals("-it")) {
					//Processes, writes, and indexes a directory of transcripts
					WRITE_DIRECTORY = args[1];
					ir.handleTranscript(new File(args[2]));
				}
				else {
					throw new IngestException();
				}
			}
			else if(args.length == 5) {				
				if(command.equals("-pull")) {
					ir.pullSobis(args[1], args[2], args[3], args[4]);
				}
				else {
					throw new IngestException();
				}
			}
		} catch(IngestException e) {
			System.err.println("appropriate usage is:\n" +
					"\t-i <json directory> <sobi directory> (to create index)\n" +
					"\t-gx <sobi directory> (to generate agenda and calendar xml from sobi)\n" +
					"\t-b <bill json path> (to reindex single bill)\n" +
					"\t-c <calendar json path> (to reindex single calendar)\n" +
					"\t-a <agenda json path> (to reindex single agenda)\n" +
					"\t-t <transcript json path> (to reindex single transcript)" +
					"\t-it <transcript sobi path> (to reindex dir of transcripts)\n" +
					"\t-pull <sobi directory> <output directory> <id> <year> (get an objects referencing sobis)");
		}
	} 
                            #location 18 
                            #vulnerability type NULL_DEREFERENCE
#fixed code
                             public static void main(String[] args) throws IOException {
		IngestReader ir = new IngestReader();
		
		try {
			if(args.length < 2) {
				throw new IngestException();
			}
			
			String command = args[0];
			if(args.length == 2) {
				if(command.equals("-gx")) {
					XmlHelper.generateXml(args[1]);
				}
				else if(command.equals("-b")) {
					//In the case of bills, we also need to make sure we reindex all ammended versions
					Bill bill = (Bill)ir.loadObject(args[1], Bill.class);
					if(ir.reindexAmendedVersions((Bill)bill))
						bill.setLuceneActive(false);
					ir.indexSenateObject(bill);
				}
				else if(command.equals("-c")) {
					ir.indexSenateObject(ir.loadObject(args[1], Calendar.class));
				}
				else if(command.equals("-a")) {
					ir.indexSenateObject(ir.loadObject(args[1], Agenda.class));
				}
				else if(command.equals("-t")) {
					ir.indexSenateObject(ir.loadObject(args[1], Transcript.class));
				}
				else {
					throw new IngestException();
				}
			}
			else if(args.length == 3){
				if(command.equals("-i")) {
					WRITE_DIRECTORY = args[1];
					ir.processPath(args[2]);
				}
				else if(command.equals("-it")) {
					//Processes, writes, and indexes a directory of transcripts
					WRITE_DIRECTORY = args[1];
					ir.handleTranscript(new File(args[2]));
				}
				else if(command.equals("-bulk")) {
					ir.bulkIndexJsonDirectory(ir.getIngestType(args[1]).clazz(),args[2]);
				}
				else {
					throw new IngestException();
				}
			}
			else if(args.length == 5) {				
				if(command.equals("-pull")) {
					ir.pullSobis(args[1], args[2], args[3], args[4]);
				}
				else {
					throw new IngestException();
				}
			}
		} catch(IngestException e) {
			System.err.println("appropriate usage is:\n" +
					"\t-i <json directory> <sobi directory> (to create index)\n" +
					"\t-gx <sobi directory> (to generate agenda and calendar xml from sobi)\n" +
					"\t-b <bill json path> (to reindex single bill)\n" +
					"\t-c <calendar json path> (to reindex single calendar)\n" +
					"\t-a <agenda json path> (to reindex single agenda)\n" +
					"\t-t <transcript json path> (to reindex single transcript)" +
					"\t-it <transcript sobi path> (to reindex dir of transcripts)\n" +
					"\t-pull <sobi directory> <output directory> <id> <year> (get an objects referencing sobis)" +
					"\t-bulk <object type> <json directory> (bulk index directory ofjson objects)");
		}
	}