Partition addPartition(Partition partition, String partName, boolean ifNotExists) throws AlreadyExistsException {
    partition.setDbName(partition.getDbName().toLowerCase());
    partition.setTableName(partition.getTableName().toLowerCase());
    if (!ifNotExists && parts.containsKey(partName)) {
      throw new AlreadyExistsException("Partition " + partName + " already exists");
    }
    return parts.putIfAbsent(partName, partition);
  }
Always clone objects before adding or returning them so that callers don't modify them
via references.
ql/src/java/org/apache/hadoop/hive/ql/metadata/PartitionTree.java