Program: 6289
Project: 6289
Buggy source:
/** 
 * Ensures that the specified   {@link Id.NamespacedId} exists.
 */
public void ensureEntityExists(Id.NamespacedId entityId) throws NotFoundException {
  try {
    namespaceClient.get(entityId.getNamespace());
  }
 catch (  NamespaceNotFoundException e) {
    throw e;
  }
catch (  Exception e) {
    throw Throwables.propagate(e);
  }
  if (entityId instanceof Id.Program) {
    Id.Program program=(Id.Program)entityId;
    Id.Application application=program.getApplication();
    ApplicationSpecification appSpec=store.getApplication(application);
    if (appSpec == null) {
      throw new ApplicationNotFoundException(application);
    }
    ensureProgramExists(appSpec,program);
  }
 else   if (entityId instanceof Id.Application) {
    Id.Application application=(Id.Application)entityId;
    if (store.getApplication(application) == null) {
      throw new ApplicationNotFoundException(application);
    }
  }
 else   if (entityId instanceof Id.DatasetInstance) {
    Id.DatasetInstance datasetInstance=(Id.DatasetInstance)entityId;
    try {
      if (!datasetFramework.hasInstance(datasetInstance)) {
        throw new DatasetNotFoundException(datasetInstance);
      }
    }
 catch (    DatasetManagementException ex) {
      throw new IllegalStateException(ex);
    }
  }
 else   if (entityId instanceof Id.Stream) {
    Id.Stream stream=(Id.Stream)entityId;
    try {
      if (!streamAdmin.exists(stream)) {
        throw new StreamNotFoundException(stream);
      }
    }
 catch (    StreamNotFoundException streamEx) {
      throw streamEx;
    }
catch (    Exception ex) {
      throw new IllegalStateException(ex);
    }
  }
 else   if (entityId instanceof Id.Artifact) {
    Id.Artifact artifactId=(Id.Artifact)entityId;
    try {
      artifactStore.getArtifact(artifactId);
    }
 catch (    IOException e) {
      throw new RuntimeException(e);
    }
  }
 else   if (entityId instanceof Id.Stream.View) {
    Id.Stream.View viewId=(Id.Stream.View)entityId;
    try {
      if (!streamAdmin.viewExists(viewId)) {
        throw new ViewNotFoundException(viewId);
      }
    }
 catch (    ViewNotFoundException|StreamNotFoundException viewEx) {
      throw viewEx;
    }
catch (    Exception ex) {
      throw new IllegalStateException(ex);
    }
  }
 else {
    throw new IllegalArgumentException("String_Node_Str" + entityId);
  }
}

Fixed version (ground truth):
/** 
 * Ensures that the specified   {@link Id.NamespacedId} exists.
 */
public void ensureEntityExists(Id.NamespacedId entityId) throws NotFoundException {
  if (!Id.Namespace.SYSTEM.equals(entityId.getNamespace())) {
    try {
      namespaceClient.get(entityId.getNamespace());
    }
 catch (    NamespaceNotFoundException e) {
      throw e;
    }
catch (    Exception e) {
      throw Throwables.propagate(e);
    }
  }
  if (entityId instanceof Id.Program) {
    Id.Program program=(Id.Program)entityId;
    Id.Application application=program.getApplication();
    ApplicationSpecification appSpec=store.getApplication(application);
    if (appSpec == null) {
      throw new ApplicationNotFoundException(application);
    }
    ensureProgramExists(appSpec,program);
  }
 else   if (entityId instanceof Id.Application) {
    Id.Application application=(Id.Application)entityId;
    if (store.getApplication(application) == null) {
      throw new ApplicationNotFoundException(application);
    }
  }
 else   if (entityId instanceof Id.DatasetInstance) {
    Id.DatasetInstance datasetInstance=(Id.DatasetInstance)entityId;
    try {
      if (!datasetFramework.hasInstance(datasetInstance)) {
        throw new DatasetNotFoundException(datasetInstance);
      }
    }
 catch (    DatasetManagementException ex) {
      throw new IllegalStateException(ex);
    }
  }
 else   if (entityId instanceof Id.Stream) {
    Id.Stream stream=(Id.Stream)entityId;
    try {
      if (!streamAdmin.exists(stream)) {
        throw new StreamNotFoundException(stream);
      }
    }
 catch (    StreamNotFoundException streamEx) {
      throw streamEx;
    }
catch (    Exception ex) {
      throw new IllegalStateException(ex);
    }
  }
 else   if (entityId instanceof Id.Artifact) {
    Id.Artifact artifactId=(Id.Artifact)entityId;
    try {
      artifactStore.getArtifact(artifactId);
    }
 catch (    IOException e) {
      throw new RuntimeException(e);
    }
  }
 else   if (entityId instanceof Id.Stream.View) {
    Id.Stream.View viewId=(Id.Stream.View)entityId;
    try {
      if (!streamAdmin.viewExists(viewId)) {
        throw new ViewNotFoundException(viewId);
      }
    }
 catch (    ViewNotFoundException|StreamNotFoundException viewEx) {
      throw viewEx;
    }
catch (    Exception ex) {
      throw new IllegalStateException(ex);
    }
  }
 else {
    throw new IllegalArgumentException("String_Node_Str" + entityId);
  }
}