#vulnerable code 
                             public int compare(ItemCollection a, ItemCollection b) {

		// date compare?
		if (a.isItemValueDate(itemName)) {

			Date dateA = a.getItemValueDate(itemName);
			Date dateB = b.getItemValueDate(itemName);
			int result = dateB.compareTo(dateA);
			if (!this.ascending) {
				result = -result;
			}
			return result;

		}

		// integer compare?
		if (a.isItemValueInteger(itemName)) {
			int result = a.getItemValueInteger(itemName)
					- b.getItemValueInteger(itemName);
			if (!this.ascending) {
				result = -result;
			}
			return result;

		}

		// String compare
		int result = this.collator.compare(a.getItemValueString(itemName),
				b.getItemValueString(itemName));
		if (!this.ascending) {
			result = -result;
		}
		return result;
	} 
                            #location 8 
                            #vulnerability type NULL_DEREFERENCE
#fixed code
                             public int compare(ItemCollection a, ItemCollection b) {

		// date compare?
		if (a.isItemValueDate(itemName)) {

			Date dateA = a.getItemValueDate(itemName);
			Date dateB = b.getItemValueDate(itemName);
			if (dateA==null && dateB !=null) {
				return 1;
			}
			if (dateB==null && dateA !=null) {
				return -1;
			}
			if (dateB==null && dateA ==null) {
				return 0;
			}

			int result = dateB.compareTo(dateA);
			if (!this.ascending) {
				result = -result;
			}
			return result;

		}

		// integer compare?
		if (a.isItemValueInteger(itemName)) {
			int result = a.getItemValueInteger(itemName)
					- b.getItemValueInteger(itemName);
			if (!this.ascending) {
				result = -result;
			}
			return result;

		}

		// String compare
		int result = this.collator.compare(a.getItemValueString(itemName),
				b.getItemValueString(itemName));
		if (!this.ascending) {
			result = -result;
		}
		return result;
	}