Program: 112414
Project: 112414
Buggy source:
private static IndexMetaDataCache getIndexMetaData(RegionCoprocessorEnvironment env,Map<String,byte[]> attributes) throws IOException {
  if (attributes == null) {
    return IndexMetaDataCache.EMPTY_INDEX_META_DATA_CACHE;
  }
  byte[] uuid=attributes.get(PhoenixIndexCodec.INDEX_UUID);
  if (uuid == null) {
    return IndexMetaDataCache.EMPTY_INDEX_META_DATA_CACHE;
  }
  boolean useProto=false;
  byte[] md=attributes.get(PhoenixIndexCodec.INDEX_PROTO_MD);
  useProto=md != null;
  if (md == null) {
    md=attributes.get(PhoenixIndexCodec.INDEX_MD);
  }
  byte[] txState=attributes.get(BaseScannerRegionObserver.TX_STATE);
  if (md != null) {
    final List<IndexMaintainer> indexMaintainers=IndexMaintainer.deserialize(md,useProto);
    final PhoenixTransactionContext txnContext=TransactionFactory.getTransactionFactory().getTransactionContext(txState);
    return new IndexMetaDataCache(){
      @Override public void close() throws IOException {
      }
      @Override public List<IndexMaintainer> getIndexMaintainers(){
        return indexMaintainers;
      }
      @Override public PhoenixTransactionContext getTransactionContext(){
        return txnContext;
      }
    }
;
  }
 else {
    byte[] tenantIdBytes=attributes.get(PhoenixRuntime.TENANT_ID_ATTRIB);
    ImmutableBytesPtr tenantId=tenantIdBytes == null ? null : new ImmutableBytesPtr(tenantIdBytes);
    TenantCache cache=GlobalCache.getTenantCache(env,tenantId);
    IndexMetaDataCache indexCache=(IndexMetaDataCache)cache.getServerCache(new ImmutableBytesPtr(uuid));
    if (indexCache == null) {
      String msg="String_Node_Str" + ServerCacheClient.idToString(uuid) + "String_Node_Str"+ env.getRegion()+ "String_Node_Str"+ env.getRegionServerServices().getServerName();
      SQLException e=new SQLExceptionInfo.Builder(SQLExceptionCode.INDEX_METADATA_NOT_FOUND).setMessage(msg).build().buildException();
      ServerUtil.throwIOException("String_Node_Str",e);
    }
    return indexCache;
  }
}

Fixed version (ground truth):
private static IndexMetaDataCache getIndexMetaData(RegionCoprocessorEnvironment env,Map<String,byte[]> attributes) throws IOException {
  if (attributes == null) {
    return IndexMetaDataCache.EMPTY_INDEX_META_DATA_CACHE;
  }
  byte[] uuid=attributes.get(PhoenixIndexCodec.INDEX_UUID);
  if (uuid == null) {
    return IndexMetaDataCache.EMPTY_INDEX_META_DATA_CACHE;
  }
  boolean useProto=false;
  byte[] md=attributes.get(PhoenixIndexCodec.INDEX_PROTO_MD);
  useProto=md != null;
  if (md == null) {
    md=attributes.get(PhoenixIndexCodec.INDEX_MD);
  }
  byte[] txState=attributes.get(BaseScannerRegionObserver.TX_STATE);
  if (md != null) {
    final List<IndexMaintainer> indexMaintainers=IndexMaintainer.deserialize(md,useProto);
    final PhoenixTransactionContext txnContext=TransactionFactory.getTransactionFactory().getTransactionContext(txState);
    return new IndexMetaDataCache(){
      @Override public void close() throws IOException {
      }
      @Override public List<IndexMaintainer> getIndexMaintainers(){
        return indexMaintainers;
      }
      @Override public PhoenixTransactionContext getTransactionContext(){
        return txnContext;
      }
    }
;
  }
 else {
    byte[] tenantIdBytes=attributes.get(PhoenixRuntime.TENANT_ID_ATTRIB);
    ImmutableBytesPtr tenantId=tenantIdBytes == null ? null : new ImmutableBytesPtr(tenantIdBytes);
    TenantCache cache=GlobalCache.getTenantCache(env,tenantId);
    IndexMetaDataCache indexCache=(IndexMetaDataCache)cache.getServerCache(new ImmutableBytesPtr(uuid));
    if (indexCache == null) {
      String msg="String_Node_Str" + ServerCacheClient.idToString(uuid) + "String_Node_Str"+ env.getRegion()+ "String_Node_Str"+ env.getServerName().getServerName();
      SQLException e=new SQLExceptionInfo.Builder(SQLExceptionCode.INDEX_METADATA_NOT_FOUND).setMessage(msg).build().buildException();
      ServerUtil.throwIOException("String_Node_Str",e);
    }
    return indexCache;
  }
}