nus-yam/ex-repair huggingface dataset:
Program: 13012
Project: 13012
Buggy source:
/** 
 * @see org.overlord.sramp.shell.api.shell.ShellCommand#execute()
 */
@Override public void execute() throws Exception {
  String filePathArg=this.requiredArgument(0,"String_Node_Str");
  String artifactTypeArg=this.optionalArgument(1);
  QName clientVarName=new QName("String_Node_Str","String_Node_Str");
  SrampAtomApiClient client=(SrampAtomApiClient)getContext().getVariable(clientVarName);
  if (client == null) {
    print("String_Node_Str");
    return;
  }
  InputStream content=null;
  try {
    File file=new File(filePathArg);
    ArtifactType artifactType=null;
    if (artifactTypeArg != null) {
      artifactType=ArtifactType.valueOf(artifactTypeArg);
    }
 else {
      artifactType=determineArtifactType(file);
    }
    content=FileUtils.openInputStream(file);
    BaseArtifactType artifact=client.uploadArtifact(artifactType,content,file.getName());
    QName artifactVarName=new QName("String_Node_Str","String_Node_Str");
    getContext().setVariable(artifactVarName,artifact);
    print("String_Node_Str");
    PrintArtifactMetaDataVisitor visitor=new PrintArtifactMetaDataVisitor();
    ArtifactVisitorHelper.visitArtifact(visitor,artifact);
  }
 catch (  Exception e) {
    print("String_Node_Str");
    print("String_Node_Str" + e.getMessage());
    IOUtils.closeQuietly(content);
  }
}

Fixed version (ground truth):
/** 
 * @see org.overlord.sramp.shell.api.shell.ShellCommand#execute()
 */
@Override public void execute() throws Exception {
  String filePathArg=this.requiredArgument(0,"String_Node_Str");
  String artifactTypeArg=this.optionalArgument(1);
  QName clientVarName=new QName("String_Node_Str","String_Node_Str");
  SrampAtomApiClient client=(SrampAtomApiClient)getContext().getVariable(clientVarName);
  if (client == null) {
    print("String_Node_Str");
    return;
  }
  InputStream content=null;
  try {
    File file=new File(filePathArg);
    ArtifactType artifactType=null;
    if (artifactTypeArg != null) {
      artifactType=ArtifactType.valueOf(artifactTypeArg);
      if (artifactType.isExtendedType()) {
        artifactType=ArtifactType.ExtendedDocument(artifactType.getExtendedType());
      }
    }
 else {
      artifactType=determineArtifactType(file);
    }
    content=FileUtils.openInputStream(file);
    BaseArtifactType artifact=client.uploadArtifact(artifactType,content,file.getName());
    QName artifactVarName=new QName("String_Node_Str","String_Node_Str");
    getContext().setVariable(artifactVarName,artifact);
    print("String_Node_Str");
    PrintArtifactMetaDataVisitor visitor=new PrintArtifactMetaDataVisitor();
    ArtifactVisitorHelper.visitArtifact(visitor,artifact);
  }
 catch (  Exception e) {
    print("String_Node_Str");
    print("String_Node_Str" + e.getMessage());
    IOUtils.closeQuietly(content);
  }
}
Program: 13015
Project: 13015
Buggy source:
/** 
 * @see org.overlord.sramp.shell.api.shell.ShellCommand#execute()
 */
@Override public void execute() throws Exception {
  String filePathArg=this.requiredArgument(0,"String_Node_Str");
  String artifactTypeArg=this.optionalArgument(1);
  QName clientVarName=new QName("String_Node_Str","String_Node_Str");
  SrampAtomApiClient client=(SrampAtomApiClient)getContext().getVariable(clientVarName);
  if (client == null) {
    print("String_Node_Str");
    return;
  }
  InputStream content=null;
  try {
    File file=new File(filePathArg);
    ArtifactType artifactType=null;
    if (artifactTypeArg != null) {
      artifactType=ArtifactType.valueOf(artifactTypeArg);
    }
 else {
      artifactType=determineArtifactType(file);
    }
    content=FileUtils.openInputStream(file);
    BaseArtifactType artifact=client.uploadArtifact(artifactType,content,file.getName());
    QName artifactVarName=new QName("String_Node_Str","String_Node_Str");
    getContext().setVariable(artifactVarName,artifact);
    print("String_Node_Str");
    PrintArtifactMetaDataVisitor visitor=new PrintArtifactMetaDataVisitor();
    ArtifactVisitorHelper.visitArtifact(visitor,artifact);
  }
 catch (  Exception e) {
    print("String_Node_Str");
    print("String_Node_Str" + e.getMessage());
    IOUtils.closeQuietly(content);
  }
}

Fixed version (ground truth):
/** 
 * @see org.overlord.sramp.shell.api.shell.ShellCommand#execute()
 */
@Override public void execute() throws Exception {
  String filePathArg=this.requiredArgument(0,"String_Node_Str");
  String artifactTypeArg=this.optionalArgument(1);
  QName clientVarName=new QName("String_Node_Str","String_Node_Str");
  SrampAtomApiClient client=(SrampAtomApiClient)getContext().getVariable(clientVarName);
  if (client == null) {
    print("String_Node_Str");
    return;
  }
  InputStream content=null;
  try {
    File file=new File(filePathArg);
    ArtifactType artifactType=null;
    if (artifactTypeArg != null) {
      artifactType=ArtifactType.valueOf(artifactTypeArg);
      if (artifactType.isExtendedType()) {
        artifactType=ArtifactType.ExtendedDocument(artifactType.getExtendedType());
      }
    }
 else {
      artifactType=determineArtifactType(file);
    }
    content=FileUtils.openInputStream(file);
    BaseArtifactType artifact=client.uploadArtifact(artifactType,content,file.getName());
    QName artifactVarName=new QName("String_Node_Str","String_Node_Str");
    getContext().setVariable(artifactVarName,artifact);
    print("String_Node_Str");
    PrintArtifactMetaDataVisitor visitor=new PrintArtifactMetaDataVisitor();
    ArtifactVisitorHelper.visitArtifact(visitor,artifact);
  }
 catch (  Exception e) {
    print("String_Node_Str");
    print("String_Node_Str" + e.getMessage());
    IOUtils.closeQuietly(content);
  }
}
Program: 13016
Project: 13016
Buggy source:
/** 
 * Called when a progress style notification has error'd out.
 * @param notificationBean
 */
private void onProgressError(NotificationBean notificationBean){
  Notification notification=getNotification(notificationBean.getUuid());
  if (notification != null) {
    notification.getData().setTitle(notificationBean.getTitle());
    notification.getData().setMessage(notificationBean.getMessage());
    notification.getData().setBody(notificationBean.getBody());
    notification.getData().setType(NotificationType.error);
    notification.getWidget().setNotificationTitle(notificationBean.getTitle());
    if (notificationBean.getBody() != null) {
      notification.getWidget().setNotificationMessage(notificationBean.getBody());
    }
 else {
      FlowPanel errorDetails=new FlowPanel();
      if (notification.getData().getMessage() != null) {
        errorDetails.add(new InlineLabel(notification.getData().getMessage()));
      }
      if (notification.getData().getException() != null) {
      }
      notification.getWidget().setNotificationMessage(errorDetails);
    }
    notification.getWidget().removeStyleName("String_Node_Str");
    notification.getWidget().addStyleName("String_Node_Str");
    resizeNotification(notification.getIndex() + 1);
  }
}

Fixed version (ground truth):
/** 
 * Called when a progress style notification has error'd out.
 * @param notificationBean
 */
private void onProgressError(NotificationBean notificationBean){
  Notification notification=getNotification(notificationBean.getUuid());
  if (notification != null) {
    notification.getData().setTitle(notificationBean.getTitle());
    notification.getData().setMessage(notificationBean.getMessage());
    notification.getData().setMessageWidget(notificationBean.getMessageWidget());
    notification.getData().setType(NotificationType.error);
    notification.getWidget().setNotificationTitle(notificationBean.getTitle());
    if (notificationBean.getMessageWidget() != null) {
      notification.getWidget().setNotificationMessage((Widget)notificationBean.getMessageWidget());
    }
 else {
      FlowPanel errorDetails=new FlowPanel();
      if (notification.getData().getMessage() != null) {
        errorDetails.add(new InlineLabel(notification.getData().getMessage()));
      }
      if (notification.getData().getException() != null) {
      }
      notification.getWidget().setNotificationMessage(errorDetails);
    }
    notification.getWidget().removeStyleName("String_Node_Str");
    notification.getWidget().addStyleName("String_Node_Str");
    resizeNotification(notification.getIndex() + 1);
  }
}
Program: 13018
Project: 13018
Buggy source:
/** 
 * Called when a progress style notification should be completed.
 * @param notificationBean
 */
private void onProgressComplete(NotificationBean notificationBean){
  Notification notification=getNotification(notificationBean.getUuid());
  if (notification != null) {
    notification.getData().setTitle(notificationBean.getTitle());
    notification.getData().setMessage(notificationBean.getMessage());
    notification.getData().setBody(notificationBean.getBody());
    notification.getData().setType(NotificationType.notification);
    notification.getWidget().setNotificationTitle(notificationBean.getTitle());
    if (notificationBean.getBody() != null) {
      notification.getWidget().setNotificationMessage(notificationBean.getBody());
    }
 else {
      notification.getWidget().setNotificationMessage(notificationBean.getMessage(),NotificationType.notification);
    }
    notification.getWidget().removeStyleName("String_Node_Str");
    notification.getWidget().addStyleName("String_Node_Str");
    notification.getAliveTimer().schedule(5000);
    resizeNotification(notification.getIndex() + 1);
  }
}

Fixed version (ground truth):
/** 
 * Called when a progress style notification should be completed.
 * @param notificationBean
 */
private void onProgressComplete(NotificationBean notificationBean){
  Notification notification=getNotification(notificationBean.getUuid());
  if (notification != null) {
    notification.getData().setTitle(notificationBean.getTitle());
    notification.getData().setMessage(notificationBean.getMessage());
    notification.getData().setMessageWidget(notificationBean.getMessageWidget());
    notification.getData().setType(NotificationType.notification);
    notification.getWidget().setNotificationTitle(notificationBean.getTitle());
    if (notificationBean.getMessageWidget() != null) {
      notification.getWidget().setNotificationMessage((Widget)notificationBean.getMessageWidget());
    }
 else {
      notification.getWidget().setNotificationMessage(notificationBean.getMessage(),NotificationType.notification);
    }
    notification.getWidget().removeStyleName("String_Node_Str");
    notification.getWidget().addStyleName("String_Node_Str");
    notification.getAliveTimer().schedule(5000);
    resizeNotification(notification.getIndex() + 1);
  }
}
Program: 13019
Project: 13019
Buggy source:
/** 
 * @see org.overlord.sramp.common.repository.jcr.ClassificationHelper#normalize(java.net.URI)
 */
@Override public Collection<URI> normalize(URI classification) throws SrampException {
  List<SrampOntology> ontologies=getOntologies();
  for (  SrampOntology ontology : ontologies) {
    Class sclass=ontology.findClass(classification);
    if (sclass == null) {
      throw new InvalidClassifiedByException(classification.toString());
    }
    return sclass.normalize();
  }
  return Collections.emptySet();
}

Fixed version (ground truth):
/** 
 * @see org.overlord.sramp.common.repository.jcr.ClassificationHelper#normalize(java.net.URI)
 */
@Override public Collection<URI> normalize(URI classification) throws SrampException {
  List<SrampOntology> ontologies=getOntologies();
  for (  SrampOntology ontology : ontologies) {
    Class sclass=ontology.findClass(classification);
    if (sclass != null) {
      return sclass.normalize();
    }
  }
  throw new InvalidClassifiedByException(classification.toString());
}
Program: 13020
Project: 13020
Buggy source:
/** 
 * @see org.overlord.sramp.visitors.ArtifactVisitorAdapter#visit(org.s_ramp.xmlns._2010.s_ramp.UserDefinedArtifactType)
 */
@SuppressWarnings("String_Node_Str") @Override public void visit(UserDefinedArtifactType artifact){
  super.visit(artifact);
  if (this.atomEntry != null) {
    String userType=artifact.getUserType();
    this.atomEntry.getExtensionAttributes().put(SrampConstants.SRAMP_DERIVED_QNAME,userType);
  }
}

Fixed version (ground truth):
/** 
 * @see org.overlord.sramp.visitors.ArtifactVisitorAdapter#visit(org.s_ramp.xmlns._2010.s_ramp.UserDefinedArtifactType)
 */
@SuppressWarnings("String_Node_Str") @Override public void visit(UserDefinedArtifactType artifact){
  super.visit(artifact);
  if (this.atomEntry != null) {
    String userType=artifact.getUserType();
    this.atomEntry.getExtensionAttributes().put(SrampConstants.SRAMP_USER_TYPE_QNAME,userType);
  }
}
Program: 13021
Project: 13021
Buggy source:
/** 
 * @see org.overlord.sramp.visitors.ArtifactVisitorAdapter#visit(org.s_ramp.xmlns._2010.s_ramp.UserDefinedArtifactType)
 */
@SuppressWarnings("String_Node_Str") @Override public void visit(UserDefinedArtifactType artifact){
  super.visit(artifact);
  if (this.atomEntry != null) {
    String userType=artifact.getUserType();
    this.atomEntry.getExtensionAttributes().put(SrampConstants.SRAMP_DERIVED_QNAME,userType);
  }
}

Fixed version (ground truth):
/** 
 * @see org.overlord.sramp.visitors.ArtifactVisitorAdapter#visit(org.s_ramp.xmlns._2010.s_ramp.UserDefinedArtifactType)
 */
@SuppressWarnings("String_Node_Str") @Override public void visit(UserDefinedArtifactType artifact){
  super.visit(artifact);
  if (this.atomEntry != null) {
    String userType=artifact.getUserType();
    this.atomEntry.getExtensionAttributes().put(SrampConstants.SRAMP_USER_TYPE_QNAME,userType);
  }
}
Program: 13022
Project: 13022
Buggy source:
/** 
 * Finds the assets from the given JAR file.
 * @param brmsBaseUrl
 * @param pkgName
 * @param userId
 * @param password
 * @param packageJar
 */
private void addAssetsToPackageToBRMSFromJar(String brmsBaseUrl,String pkgName,String userId,String password,File packageJar) throws Exception {
  String urlStr=brmsBaseUrl + "String_Node_Str" + pkgName+ "String_Node_Str";
  Set<String> exclusions=new HashSet<String>();
  exclusions.add("String_Node_Str");
  exclusions.add("String_Node_Str");
  JarFile jarFile=null;
  String assetPrefix="String_Node_Str" + pkgName;
  try {
    jarFile=new JarFile(packageJar);
    Enumeration<JarEntry> entries=jarFile.entries();
    while (entries.hasMoreElements()) {
      JarEntry entry=entries.nextElement();
      String entryName=entry.getName();
      if (entryName.startsWith(assetPrefix) && !entry.isDirectory()) {
        String assetName=new File(entryName).getName();
        if (!exclusions.contains(assetName)) {
          print("String_Node_Str" + entryName);
          ClientRequest addAssetRequest=fac.createRequest(urlStr);
          InputStream is=null;
          try {
            is=jarFile.getInputStream(entry);
            print("String_Node_Str" + entryName + "String_Node_Str"+ urlStr);
            uploadToBrms(entryName,is,addAssetRequest);
          }
  finally {
            is.close();
          }
        }
      }
    }
  }
  finally {
    if (jarFile != null)     jarFile.close();
  }
}

Fixed version (ground truth):
/** 
 * Finds the assets from the given JAR file.
 * @param brmsBaseUrl
 * @param pkgName
 * @param userId
 * @param password
 * @param packageJar
 */
private void addAssetsToPackageToBRMSFromJar(String brmsBaseUrl,String pkgName,String userId,String password,File packageJar) throws Exception {
  String urlStr=brmsBaseUrl + "String_Node_Str" + pkgName+ "String_Node_Str";
  Set<String> exclusions=new HashSet<String>();
  exclusions.add("String_Node_Str");
  exclusions.add("String_Node_Str");
  JarFile jarFile=null;
  String assetPrefix="String_Node_Str" + pkgName;
  try {
    jarFile=new JarFile(packageJar);
    Enumeration<JarEntry> entries=jarFile.entries();
    while (entries.hasMoreElements()) {
      JarEntry entry=entries.nextElement();
      String entryName=entry.getName();
      if (entryName.startsWith(assetPrefix) && !entry.isDirectory()) {
        String assetName=new File(entryName).getName();
        if (!exclusions.contains(assetName)) {
          print("String_Node_Str" + entryName);
          ClientRequest addAssetRequest=fac.createRequest(urlStr);
          InputStream is=null;
          try {
            is=jarFile.getInputStream(entry);
            print("String_Node_Str" + entryName + "String_Node_Str"+ urlStr);
            uploadToBrms(assetName,is,addAssetRequest);
          }
  finally {
            is.close();
          }
        }
      }
    }
  }
  finally {
    if (jarFile != null)     jarFile.close();
  }
}
Program: 13023
Project: 13023
Buggy source:
/** 
 * Uploads assets to the correct package in BRMS.
 * @param brmsBaseUrl
 * @param pkgName
 * @param userId
 * @param password
 * @param packagePath
 * @throws Exception
 */
public void addAssetsToPackageToBRMS(String brmsBaseUrl,String pkgName,String userId,String password,String packagePath) throws Exception {
  if (packagePath != null) {
    File packageJar=new File(packagePath);
    if (!packageJar.isFile())     throw new Exception("String_Node_Str" + packagePath);
    addAssetsToPackageToBRMSFromJar(brmsBaseUrl,pkgName,userId,password,packageJar);
  }
 else {
    addAssetsToPackageToBRMSFromClasspath(brmsBaseUrl,pkgName,userId,password);
  }
}

Fixed version (ground truth):
/** 
 * Uploads assets to the correct package in BRMS.
 * @param brmsBaseUrl
 * @param pkgName
 * @param userId
 * @param password
 * @param packagePath
 * @throws Exception
 */
public void addAssetsToPackageToBRMS(String brmsBaseUrl,String pkgName,String userId,String password,String packagePath) throws Exception {
  String urlStr=brmsBaseUrl + "String_Node_Str" + pkgName+ "String_Node_Str";
  Credentials credentials=new UsernamePasswordCredentials(userId,password);
  DefaultHttpClient httpClient=new DefaultHttpClient();
  httpClient.getCredentialsProvider().setCredentials(AuthScope.ANY,credentials);
  ClientExecutor clientExecutor=new ApacheHttpClient4Executor(httpClient);
  fac=new ClientRequestFactory(clientExecutor,new URI(urlStr));
  if (packagePath != null) {
    File packageJar=new File(packagePath);
    if (!packageJar.isFile())     throw new Exception("String_Node_Str" + packagePath);
    addAssetsToPackageToBRMSFromJar(brmsBaseUrl,pkgName,userId,password,packageJar);
  }
 else {
    addAssetsToPackageToBRMSFromClasspath(brmsBaseUrl,pkgName,userId,password);
  }
  String urlCompile=brmsBaseUrl + "String_Node_Str" + pkgName+ "String_Node_Str";
  ClientRequest compileRequest=fac.createRequest(urlCompile);
  ClientResponse<InputStream> compileResponse=compileRequest.get(InputStream.class);
  if (compileResponse.getStatus() == 200) {
    print("String_Node_Str");
  }
 else {
    System.err.println(compileResponse.getStatus() + "String_Node_Str" + compileResponse.getResponseStatus().getReasonPhrase());
  }
}
Program: 13025
Project: 13025
Buggy source:
/** 
 * @see org.overlord.sramp.client.shell.ShellCommandReader#read()
 */
@Override public final ShellCommand read() throws Exception {
  String line=readLine();
  if (line == null) {
    return null;
  }
  if (line.trim().length() == 0) {
    return new NoOpCommand();
  }
  String[] split=line.split("String_Node_Str");
  String encodedCommandName=split[0];
  QName commandName=null;
  if (encodedCommandName != null) {
    if (encodedCommandName.contains("String_Node_Str")) {
      String[] nameSplit=encodedCommandName.split("String_Node_Str");
      commandName=new QName(nameSplit[0],nameSplit[1]);
    }
 else {
      commandName=new QName("String_Node_Str",encodedCommandName);
    }
  }
  String[] args=Arrays.copyOfRange(split,1,split.length);
  return factory.createCommand(commandName,args);
}

Fixed version (ground truth):
/** 
 * @see org.overlord.sramp.client.shell.ShellCommandReader#read()
 */
@Override public final ShellCommand read() throws Exception {
  String line=readLine();
  if (line == null) {
    return null;
  }
  if (line.trim().length() == 0) {
    return new NoOpCommand();
  }
  String[] split=line.split("String_Node_Str");
  String encodedCommandName=split[0];
  QName commandName=null;
  if (encodedCommandName != null) {
    if (encodedCommandName.contains("String_Node_Str") && !encodedCommandName.endsWith("String_Node_Str")) {
      String[] nameSplit=encodedCommandName.split("String_Node_Str");
      commandName=new QName(nameSplit[0],nameSplit[1]);
    }
 else {
      commandName=new QName("String_Node_Str",encodedCommandName);
    }
  }
  String[] args=Arrays.copyOfRange(split,1,split.length);
  return factory.createCommand(commandName,args);
}
Program: 13026
Project: 13026
Buggy source:
/** 
 * Displays a welcome message to the user.
 */
private void displayWelcomeMessage(){
  System.out.println("String_Node_Str");
  System.out.println("String_Node_Str");
  System.out.println("String_Node_Str");
  System.out.println("String_Node_Str");
  System.out.println("String_Node_Str");
  System.out.println("String_Node_Str");
  System.out.println("String_Node_Str");
  System.out.println("String_Node_Str");
  System.out.println("String_Node_Str");
}

Fixed version (ground truth):
/** 
 * Displays a welcome message to the user.
 */
private void displayWelcomeMessage(){
  System.out.println("String_Node_Str" + "String_Node_Str" + "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str");
}
Program: 13027
Project: 13027
Buggy source:
/** 
 * @see org.overlord.sramp.repository.PersistenceManager#persistOntology(org.overlord.sramp.ontology.SrampOntology)
 */
@Override public SrampOntology persistOntology(SrampOntology ontology) throws RepositoryException {
  Session session=null;
  if (ontology.getUuid() == null) {
    ontology.setUuid(UUID.randomUUID().toString());
  }
  String ontologyPath="String_Node_Str" + ontology.getUuid();
  try {
    session=JCRRepository.getSession();
    if (session.nodeExists(ontologyPath)) {
      throw new RepositoryException("String_Node_Str");
    }
 else {
      JcrTools tools=new JcrTools();
      Node ontologiesNode=tools.findOrCreateNode(session,"String_Node_Str",null,null);
      Node ontologyNode=ontologiesNode.addNode(ontology.getUuid(),"String_Node_Str");
      o2jcr.write(ontology,ontologyNode);
      session.save();
      log.debug("String_Node_Str",ontology.getUuid());
      return ontology;
    }
  }
 catch (  RepositoryException e) {
    log.error("String_Node_Str" + ontology.getUuid(),e);
    throw e;
  }
catch (  Throwable t) {
    log.error("String_Node_Str" + ontology.getUuid(),t);
    throw new RepositoryException(t);
  }
 finally {
    JCRRepository.logoutQuietly(session);
  }
}

Fixed version (ground truth):
/** 
 * @see org.overlord.sramp.repository.PersistenceManager#persistOntology(org.overlord.sramp.ontology.SrampOntology)
 */
@Override public SrampOntology persistOntology(SrampOntology ontology) throws RepositoryException {
  Session session=null;
  if (ontology.getUuid() == null) {
    ontology.setUuid(UUID.randomUUID().toString());
  }
  String ontologyPath="String_Node_Str" + ontology.getUuid();
  try {
    session=JCRRepository.getSession();
    if (session.nodeExists(ontologyPath)) {
      throw new RepositoryException("String_Node_Str");
    }
 else {
      JcrTools tools=new JcrTools();
      Node ontologiesNode=tools.findOrCreateNode(session,"String_Node_Str","String_Node_Str");
      Node ontologyNode=ontologiesNode.addNode(ontology.getUuid(),"String_Node_Str");
      o2jcr.write(ontology,ontologyNode);
      session.save();
      log.debug("String_Node_Str",ontology.getUuid());
      return ontology;
    }
  }
 catch (  RepositoryException e) {
    log.error("String_Node_Str" + ontology.getUuid(),e);
    throw e;
  }
catch (  Throwable t) {
    log.error("String_Node_Str" + ontology.getUuid(),t);
    throw new RepositoryException(t);
  }
 finally {
    JCRRepository.logoutQuietly(session);
  }
}
Program: 13028
Project: 13028
Buggy source:
/** 
 * Can set a property (built-in or custom) on the entry.
 * @param archive
 * @param entryPath
 * @param context
 * @throws Exception
 */
private void executeSetProperty(SrampArchive archive,String entryPath,ShellContext context) throws Exception {
  String propNameArg=requiredArgument(2,"String_Node_Str");
  String propValArg=requiredArgument(3,"String_Node_Str");
  SrampArchiveEntry entry=archive.getEntry(entryPath);
  BaseArtifactType metaData=entry.getMetaData();
  SrampModelUtils.setCustomProperty(metaData,propNameArg,propValArg);
  archive.updateEntry(entry,null);
  System.out.println("String_Node_Str");
}

Fixed version (ground truth):
/** 
 * Can set a property (built-in or custom) on the entry.
 * @param archive
 * @param entryPath
 * @param context
 * @throws Exception
 */
private void executeSetProperty(SrampArchive archive,String entryPath,ShellContext context) throws Exception {
  String propNameArg=requiredArgument(2,"String_Node_Str");
  String propValArg=requiredArgument(3,"String_Node_Str");
  SrampArchiveEntry entry=archive.getEntry(entryPath);
  BaseArtifactType metaData=entry.getMetaData();
  if ("String_Node_Str".equals(propNameArg)) {
    metaData.setName(propValArg);
  }
 else   if ("String_Node_Str".equals(propNameArg)) {
    metaData.setDescription(propValArg);
  }
 else   if ("String_Node_Str".equals(propNameArg)) {
    metaData.setVersion(propValArg);
  }
 else   if ("String_Node_Str".equals(propNameArg)) {
    metaData.setCreatedBy(propValArg);
  }
 else   if ("String_Node_Str".equals(propNameArg)) {
    metaData.setLastModifiedBy(propValArg);
  }
 else   if ("String_Node_Str".equals(propNameArg)) {
    metaData.setUuid(propValArg);
  }
 else   if ("String_Node_Str".equals(propNameArg)) {
  }
 else   if ("String_Node_Str".equals(propNameArg)) {
  }
  SrampModelUtils.setCustomProperty(metaData,propNameArg,propValArg);
  archive.updateEntry(entry,null);
  System.out.println("String_Node_Str");
}
Program: 13030
Project: 13030
Buggy source:
/** 
 * @see org.overlord.sramp.repository.jcr.ArtifactToJCRNodeVisitor.JCRReferenceFactory#createReference(java.lang.String)
 */
@Override public Value createReference(String uuid){
  try {
    javax.jcr.query.QueryManager jcrQueryManager=session.getWorkspace().getQueryManager();
    String jcrSql2Query=String.format("String_Node_Str",uuid);
    javax.jcr.query.Query jcrQuery=jcrQueryManager.createQuery(jcrSql2Query,QueryLanguage.JCR_SQL2);
    QueryResult jcrQueryResult=jcrQuery.execute();
    NodeIterator jcrNodes=jcrQueryResult.getNodes();
    if (!jcrNodes.hasNext()) {
      throw new Exception("String_Node_Str" + uuid);
    }
    if (jcrNodes.getSize() > 1) {
      throw new Exception("String_Node_Str" + uuid);
    }
    Node node=jcrNodes.nextNode();
    return session.getValueFactory().createValue(node,false);
  }
 catch (  Exception e) {
    log.error("String_Node_Str" + uuid,e);
  }
  return null;
}

Fixed version (ground truth):
/** 
 * @see org.overlord.sramp.repository.jcr.ArtifactToJCRNodeVisitor.JCRReferenceFactory#createReference(java.lang.String)
 */
@Override public Value createReference(String uuid){
  try {
    Node node=findArtifactNodeByUuid(session,uuid);
    if (node == null) {
      throw new Exception("String_Node_Str" + uuid);
    }
    return session.getValueFactory().createValue(node,false);
  }
 catch (  Exception e) {
    log.error("String_Node_Str" + uuid,e);
  }
  return null;
}
Program: 13031
Project: 13031
Buggy source:
/** 
 * @see org.overlord.sramp.repository.PersistenceManager#getArtifact(java.lang.String,org.overlord.sramp.ArtifactType)
 */
@Override public BaseArtifactType getArtifact(String uuid,ArtifactType type) throws RepositoryException {
  Session session=null;
  String artifactPath=MapToJCRPath.getArtifactPath(uuid,type);
  try {
    session=JCRRepository.getSession();
    if (session.nodeExists(artifactPath)) {
      Node artifactNode=session.getNode(artifactPath);
      return JCRNodeToArtifactFactory.createArtifact(session,artifactNode,type);
    }
 else {
      return null;
    }
  }
 catch (  RepositoryException re) {
    throw re;
  }
catch (  Throwable t) {
    throw new RepositoryException(t);
  }
 finally {
    JCRRepository.logoutQuietly(session);
  }
}

Fixed version (ground truth):
/** 
 * @see org.overlord.sramp.repository.PersistenceManager#getArtifact(java.lang.String,org.overlord.sramp.ArtifactType)
 */
@Override public BaseArtifactType getArtifact(String uuid,ArtifactType type) throws RepositoryException {
  Session session=null;
  try {
    session=JCRRepository.getSession();
    Node artifactNode=null;
    if (type.getArtifactType().isDerived()) {
      artifactNode=findArtifactNodeByUuid(session,uuid);
    }
 else {
      String artifactPath=MapToJCRPath.getArtifactPath(uuid,type);
      if (session.nodeExists(artifactPath)) {
        artifactNode=session.getNode(artifactPath);
      }
    }
    if (artifactNode != null) {
      return JCRNodeToArtifactFactory.createArtifact(session,artifactNode,type);
    }
 else {
      return null;
    }
  }
 catch (  RepositoryException re) {
    throw re;
  }
catch (  Throwable t) {
    throw new RepositoryException(t);
  }
 finally {
    JCRRepository.logoutQuietly(session);
  }
}
Program: 13032
Project: 13032
Buggy source:
@Override public void shutdown(){
  JCRRepository.shutdown();
}

Fixed version (ground truth):
/** 
 * @see org.overlord.sramp.repository.PersistenceManager#shutdown()
 */
@Override public void shutdown(){
  JCRRepository.shutdown();
}
Program: 13033
Project: 13033
Buggy source:
/** 
 * @see org.overlord.sramp.visitors.HierarchicalArtifactVisitorAdapter#visitWsdlDerived(org.s_ramp.xmlns._2010.s_ramp.WsdlDerivedArtifactType)
 */
@Override protected void visitWsdlDerived(WsdlDerivedArtifactType artifact){
}

Fixed version (ground truth):
/** 
 * @see org.overlord.sramp.visitors.HierarchicalArtifactVisitorAdapter#visitWsdlDerived(org.s_ramp.xmlns._2010.s_ramp.WsdlDerivedArtifactType)
 */
@Override protected void visitWsdlDerived(WsdlDerivedArtifactType artifact){
  artifact.setNamespace(getProperty(jcrNode,"String_Node_Str"));
}
Program: 13036
Project: 13036
Buggy source:
/** 
 * Parses the build date string into a   {@link Date}.
 * @param dateString
 */
private static Date parseBuildDate(String dateString){
  if (dateString.equals("String_Node_Str"))   return new Date();
  SimpleDateFormat format=new SimpleDateFormat("String_Node_Str");
  try {
    return format.parse(dateString);
  }
 catch (  ParseException e) {
    throw new RuntimeException(e);
  }
}

Fixed version (ground truth):
/** 
 * Parses the build date string into a   {@link Date}.
 * @param dateString
 */
private static Date parseBuildDate(String dateString){
  if (dateString.equals("String_Node_Str"))   return new Date();
  SimpleDateFormat format=new SimpleDateFormat("String_Node_Str");
  try {
    return format.parse(dateString);
  }
 catch (  ParseException e) {
  }
  format=new SimpleDateFormat("String_Node_Str");
  try {
    return format.parse(dateString);
  }
 catch (  ParseException e) {
  }
  return new Date();
}
Program: 13039
Project: 13039
Buggy source:
/** 
 * Called to configure the custom JCR node types.
 */
private static void configureNodeTypes() throws RepositoryException {
  Session session=null;
  InputStream is=null;
  try {
    session=JCRRepository.getSession();
    NodeTypeManager manager=(NodeTypeManager)session.getWorkspace().getNodeTypeManager();
    if (!manager.hasNodeType(SRAMP_UUID)) {
      is=JCRRepository.class.getResourceAsStream("String_Node_Str");
      manager.registerNodeTypes(is,true);
    }
    if (!manager.hasNodeType(OVERLORD_ARTIFACT)) {
      is=JCRRepository.class.getResourceAsStream("String_Node_Str");
      manager.registerNodeTypes(is,true);
    }
  }
 catch (  LoginException e) {
    throw e;
  }
catch (  NoSuchWorkspaceException e) {
    throw e;
  }
catch (  RepositoryException e) {
    throw e;
  }
catch (  IOException e) {
    throw new RepositoryException(e);
  }
catch (  RuntimeException e) {
    throw e;
  }
 finally {
    IOUtils.closeQuietly(is);
    if (session != null)     session.logout();
  }
}

Fixed version (ground truth):
/** 
 * Called to configure the custom JCR node types.
 */
private static void configureNodeTypes() throws RepositoryException {
  Session session=null;
  InputStream is=null;
  try {
    session=JCRRepository.getSession();
    NamespaceRegistry namespaceRegistry=session.getWorkspace().getNamespaceRegistry();
    namespaceRegistry.registerNamespace(JCRConstants.OVERLORD,JCRConstants.OVERLORD_NS);
    namespaceRegistry.registerNamespace(JCRConstants.SRAMP_PROPERTIES,JCRConstants.SRAMP_PROPERTIES_NS);
    NodeTypeManager manager=(NodeTypeManager)session.getWorkspace().getNodeTypeManager();
    if (!manager.hasNodeType(SRAMP_UUID)) {
      is=JCRRepository.class.getResourceAsStream("String_Node_Str");
      manager.registerNodeTypes(is,true);
    }
    if (!manager.hasNodeType(OVERLORD_ARTIFACT)) {
      is=JCRRepository.class.getResourceAsStream("String_Node_Str");
      manager.registerNodeTypes(is,true);
    }
  }
 catch (  LoginException e) {
    throw e;
  }
catch (  NoSuchWorkspaceException e) {
    throw e;
  }
catch (  RepositoryException e) {
    throw e;
  }
catch (  IOException e) {
    throw new RepositoryException(e);
  }
catch (  RuntimeException e) {
    throw e;
  }
 finally {
    IOUtils.closeQuietly(is);
    if (session != null)     session.logout();
  }
}
Program: 13040
Project: 13040
Buggy source:
/** 
 * Convenience method for getting a JCR session from the repo singleton.
 * @throws LoginException
 * @throws NoSuchWorkspaceException
 * @throws RepositoryException
 */
public static Session getSession() throws LoginException, NoSuchWorkspaceException, RepositoryException {
  AnonymousCredentials cred=new AnonymousCredentials();
  Session session=getInstance().login(cred,WORKSPACE_NAME);
  session.setNamespacePrefix(OVERLORD,OVERLORD_NS);
  session.setNamespacePrefix(SRAMP_PROPERTIES,SRAMP_PROPERTIES_NS);
  return session;
}

Fixed version (ground truth):
/** 
 * Convenience method for getting a JCR session from the repo singleton.
 * @throws LoginException
 * @throws NoSuchWorkspaceException
 * @throws RepositoryException
 */
public static Session getSession() throws LoginException, NoSuchWorkspaceException, RepositoryException {
  AnonymousCredentials cred=new AnonymousCredentials();
  return getInstance().login(cred,WORKSPACE_NAME);
}
Program: 13041
Project: 13041
Buggy source:
/** 
 * Gets all of the custom s-ramp property names currently stored on the given JCR node.
 * @param jcrNode
 * @throws RepositoryException 
 */
private static Set<String> getNodePropertyNames(Node jcrNode) throws RepositoryException {
  String srampPropsPrefix=JCRConstants.SRAMP_PROPERTIES + "String_Node_Str";
  Set<String> rval=new HashSet<String>();
  PropertyIterator properties=jcrNode.getProperties();
  while (properties.hasNext()) {
    Property prop=properties.nextProperty();
    String propName=prop.getName();
    if (propName.startsWith(srampPropsPrefix)) {
      propName=propName.substring(7);
      rval.add(propName);
    }
  }
  return rval;
}

Fixed version (ground truth):
/** 
 * Gets all of the custom s-ramp property names currently stored on the given JCR node.
 * @param jcrNode
 * @throws RepositoryException 
 */
private static Set<String> getNodePropertyNames(Node jcrNode) throws RepositoryException {
  String srampPropsPrefix=JCRConstants.SRAMP_PROPERTIES + "String_Node_Str";
  int srampPropsPrefixLen=srampPropsPrefix.length();
  Set<String> rval=new HashSet<String>();
  PropertyIterator properties=jcrNode.getProperties();
  while (properties.hasNext()) {
    Property prop=properties.nextProperty();
    String propName=prop.getName();
    if (propName.startsWith(srampPropsPrefix)) {
      propName=propName.substring(srampPropsPrefixLen);
      rval.add(propName);
    }
  }
  return rval;
}
Program: 13043
Project: 13043
Buggy source:
/** 
 * Gets the key into the i18n messages.properties.  This returns a key that will be used to lookup a localized title for this place.  It will look up the localized title using the standard   {@link ILocalizationService}.  Subclasses can optionally override this to provide a different key.
 */
public String getTitleKey(){
  return "String_Node_Str" + getClass().getSimpleName().toLowerCase() + "String_Node_Str";
}

Fixed version (ground truth):
/** 
 * Gets the key into the i18n messages.properties.  This returns a key that will be used to lookup a localized title for this place.  It will look up the localized title using the standard   {@link ILocalizationService}.  Subclasses can optionally override this to provide a different key.
 */
public String getTitleKey(){
  String[] ksplit=getClass().toString().split("String_Node_Str");
  String k=ksplit[ksplit.length - 1];
  return "String_Node_Str" + k.toLowerCase() + "String_Node_Str";
}
Program: 13044
Project: 13044
Buggy source:
public static void showTags(){
  List<CucumberFeature> features=CucumberService.loadFeatures();
  Comparator<Tag> byName=Comparator.comparing(Tag::getName);
  Supplier<TreeSet<Tag>> supplier=() -> new TreeSet<>(byName);
  SortedSet<Tag> tags=features.stream().flatMap(cucumberFeature -> cucumberFeature.getFeature().getTags().stream()).sorted(Comparator.comparing(Tag::getName)).collect(Collectors.toCollection(supplier));
  render(tags);
}

Fixed version (ground truth):
public static void showTags(){
  List<CucumberFeature> features=CucumberService.loadFeatures();
  Comparator<Tag> byName=Comparator.comparing(Tag::getName);
  Supplier<TreeSet<Tag>> supplier=() -> new TreeSet<>(byName);
  SortedSet<Tag> tags=features.stream().flatMap(cucumberFeature -> cucumberFeature.getGherkinFeature().getTags().stream()).sorted(Comparator.comparing(Tag::getName)).collect(Collectors.toCollection(supplier));
  render(tags);
}
Program: 13045
Project: 13045
Buggy source:
@Override protected boolean isValueExpectedRecursive(XExpression expr){
  EObject container=expr.eContainer();
  if (container instanceof RichString || container instanceof RichStringForLoop) {
    return true;
  }
  return super.isValueExpectedRecursive(expr);
}

Fixed version (ground truth):
@Override protected boolean isValueExpectedRecursive(XExpression expr){
  EObject container=expr.eContainer();
  if (container instanceof RichString || container instanceof RichStringForLoop || container instanceof XtendField) {
    return true;
  }
  return super.isValueExpectedRecursive(expr);
}
Program: 13046
Project: 13046
Buggy source:
public XtendFormatterConfig getFormatterConfiguration(Resource resource){
  IProject project=null;
  if (resource.getURI().isPlatform()) {
    Iterable<Pair<IStorage,IProject>> storages=mapper.getStorages(resource.getURI());
    for (    Pair<IStorage,IProject> pair : storages) {
      project=pair.getSecond();
      if (project != null) {
        break;
      }
    }
  }
  IPreferenceStore store=preferenceStoreAccess.getContextPreferenceStore(project);
  Map<String,String> storedValues=new HashMap<String,String>();
  for (  String key : new XtendFormatterConfig().asMap().keySet()) {
    String value=store.getString(key);
    if (value != null && !value.isEmpty())     storedValues.put(key,value);
  }
  return new XtendFormatterConfig(storedValues);
}

Fixed version (ground truth):
public XtendFormatterConfig getFormatterConfiguration(Resource resource){
  IProject project=null;
  if (resource.getURI().isPlatform()) {
    Iterable<Pair<IStorage,IProject>> storages=mapper.getStorages(resource.getURI());
    for (    Pair<IStorage,IProject> pair : storages) {
      project=pair.getSecond();
      if (project != null) {
        break;
      }
    }
  }
  IPreferenceStore store=preferenceStoreAccess.getContextPreferenceStore(project);
  Map<String,String> storedValues=new HashMap<String,String>();
  for (  String key : new XtendFormatterConfig().asMap().keySet()) {
    String value=store.getString(key);
    if (value != null && value.length() != 0)     storedValues.put(key,value);
  }
  return new XtendFormatterConfig(storedValues);
}
Program: 13047
Project: 13047
Buggy source:
@Override protected void updateWidget(){
  final boolean hasKey=getKey() != null;
  boolean enabled=hasKey && getEnabled();
  label.setEnabled(enabled);
  minText.setEnabled(enabled);
  maxText.setEnabled(enabled);
  minMaxRange=new NewLineConfig("String_Node_Str");
  if (hasKey) {
    try {
      String s=getPreferences().get(getKey());
      minMaxRange=new NewLineConfig(s);
    }
 catch (    NumberFormatException e) {
    }
  }
  fillFields(minMaxRange);
}

Fixed version (ground truth):
@Override protected void updateWidget(){
  final boolean hasKey=getKey() != null;
  boolean enabled=hasKey && getEnabled();
  label.setEnabled(enabled);
  minText.setEnabled(enabled);
  maxText.setEnabled(enabled);
  minMaxRange=new NewLineConfig("String_Node_Str");
  if (hasKey) {
    try {
      String s=(String)getPreferences().get(getKey());
      minMaxRange=new NewLineConfig(s);
    }
 catch (    NumberFormatException e) {
    }
  }
  fillFields(minMaxRange);
}
Program: 13048
Project: 13048
Buggy source:
private static void setLatestCompliance(Map map){
  JavaModelUtil.set50ComplianceOptions(map);
}

Fixed version (ground truth):
private static void setLatestCompliance(Map map){
}
Program: 13049
Project: 13049
Buggy source:
@Override public List<?> readProfiles(IScopeContext scope) throws CoreException {
  return readProfilesFromString(scope.getNode(xtendNodeID).get(XTEND_PROFILES_KEY,null));
}

Fixed version (ground truth):
@Override public List readProfiles(IScopeContext scope) throws CoreException {
  return readProfilesFromString(scope.getNode(xtendNodeID).get(XTEND_PROFILES_KEY,null));
}
Program: 13051
Project: 13051
Buggy source:
public void acceptStaticImport(JvmMember member){
  final JvmDeclaredType declaringType=member.getDeclaringType();
  JvmDeclaredType currentlyChecked=thisType;
  while (currentlyChecked != null) {
    if (currentlyChecked == declaringType)     return;
    final JvmTypeReference typeRefToSuperClass=IterableExtensions.findFirst(currentlyChecked.getSuperTypes(),new Function1<JvmTypeReference,Boolean>(){
      public Boolean apply(      JvmTypeReference type){
        if (type.getType() instanceof JvmGenericType) {
          JvmGenericType genericType=(JvmGenericType)type.getType();
          return !genericType.isInterface();
        }
        return false;
      }
    }
);
    currentlyChecked=typeRefToSuperClass == null ? null : (JvmDeclaredType)typeRefToSuperClass.getType();
  }
  staticMembers.add(declaringType);
}

Fixed version (ground truth):
public void acceptStaticImport(JvmMember member){
  if (thisType == member.getDeclaringType())   return;
  if (knownTypesForStaticImports == null) {
    JvmParameterizedTypeReference reference=TypesFactory.eINSTANCE.createJvmParameterizedTypeReference();
    reference.setType(thisType);
    knownTypesForStaticImports=superTypeCollector.collectSuperTypesAsRawTypes(reference);
  }
  if (knownTypesForStaticImports.contains(member.getDeclaringType()))   return;
  staticMembers.add(member.getDeclaringType());
}
Program: 13052
Project: 13052
Buggy source:
public void setThisType(JvmDeclaredType declaredType){
  this.thisType=declaredType;
}

Fixed version (ground truth):
public void setThisType(JvmDeclaredType declaredType){
  this.thisType=declaredType;
  knownTypesForStaticImports=null;
}
Program: 13054
Project: 13054
Buggy source:
@SuppressWarnings({"String_Node_Str","String_Node_Str"}) @Override protected ProfileManager createProfileManager(List profiles,IScopeContext context,PreferencesAccess access,IProfileVersioner profileVersioner){
  return new FormatterProfileManager(profiles,context,access,profileVersioner);
}

Fixed version (ground truth):
@SuppressWarnings("String_Node_Str") @Override protected ProfileManager createProfileManager(List profiles,IScopeContext context,PreferencesAccess access,IProfileVersioner profileVersioner){
  return new FormatterProfileManager(profiles,context,access,profileVersioner);
}
Program: 13055
Project: 13055
Buggy source:
private static List<Object> addBuiltinProfiles(final List<Object> profiles,IProfileVersioner profileVersioner){
  final Profile javaProfile=new BuiltInProfile(DEFUALT_PROFILE_KEY,DEFAULT_PROFILE_LABEL,getXtendSettings(),1,profileVersioner.getCurrentVersion(),profileVersioner.getProfileKind());
  profiles.add(javaProfile);
  return profiles;
}

Fixed version (ground truth):
private static List addBuiltinProfiles(final List profiles,IProfileVersioner profileVersioner){
  final Profile javaProfile=new BuiltInProfile(DEFUALT_PROFILE_KEY,DEFAULT_PROFILE_LABEL,getXtendSettings(),1,profileVersioner.getCurrentVersion(),profileVersioner.getProfileKind());
  profiles.add(javaProfile);
  return profiles;
}
Program: 13056
Project: 13056
Buggy source:
public FormatterProfileManager(List<Object> profiles,IScopeContext context,PreferencesAccess preferencesAccess,IProfileVersioner profileVersioner){
  super(addBuiltinProfiles(profiles,profileVersioner),context,preferencesAccess,profileVersioner,KEY_SETS,PROFILE_KEY,FORMATTER_SETTINGS_VERSION);
}

Fixed version (ground truth):
public FormatterProfileManager(List profiles,IScopeContext context,PreferencesAccess preferencesAccess,IProfileVersioner profileVersioner){
  super(addBuiltinProfiles(profiles,profileVersioner),context,preferencesAccess,profileVersioner,KEY_SETS,PROFILE_KEY,FORMATTER_SETTINGS_VERSION);
}
Program: 13057
Project: 13057
Buggy source:
private static Map<Object,Object> getXtendSettings(){
  final Map<Object,Object> options=new HashMap<Object,Object>();
  return options;
}

Fixed version (ground truth):
private static Map<String,String> getXtendSettings(){
  final Map<String,String> options=new HashMap<String,String>();
  return options;
}
Program: 13058
Project: 13058
Buggy source:
/** 
 * checks next available job and returns when it will be available (if it will, otherwise returns   {@link Long#MAX_VALUE}) also creates a timer to notify listeners at that time
 * @param hasNetwork .
 * @return time wait until next job (in milliseconds)
 */
private long ensureConsumerWhenNeeded(Boolean hasNetwork){
  if (hasNetwork == null) {
    hasNetwork=networkUtil instanceof NetworkEventProvider ? hasNetwork() : true;
  }
  Long nextRunNs;
synchronized (nonPersistentJobQueue) {
    nextRunNs=nonPersistentJobQueue.getNextJobDelayUntilNs(hasNetwork);
  }
  if (nextRunNs != null && nextRunNs <= System.nanoTime()) {
    notifyJobConsumer();
    return 0L;
  }
  Long persistedJobRunNs;
synchronized (persistentJobQueue) {
    persistedJobRunNs=persistentJobQueue.getNextJobDelayUntilNs(hasNetwork);
  }
  if (persistedJobRunNs != null) {
    if (nextRunNs == null) {
      nextRunNs=persistedJobRunNs;
    }
 else     if (persistedJobRunNs < nextRunNs) {
      nextRunNs=persistedJobRunNs;
    }
  }
  if (nextRunNs != null) {
    long diff=(long)Math.ceil((double)(nextRunNs - System.nanoTime()) / NS_PER_MS);
    if (diff <= 0) {
      notifyJobConsumer();
      return 0L;
    }
 else {
      ensureConsumerOnTime(diff);
      return diff;
    }
  }
  return Long.MAX_VALUE;
}

Fixed version (ground truth):
/** 
 * checks next available job and returns when it will be available (if it will, otherwise returns   {@link Long#MAX_VALUE}) also creates a timer to notify listeners at that time
 * @param hasNetwork .
 * @return time wait until next job (in milliseconds)
 */
private long ensureConsumerWhenNeeded(Boolean hasNetwork){
  if (hasNetwork == null) {
    hasNetwork=networkUtil instanceof NetworkEventProvider ? hasNetwork() : true;
  }
  Long nextRunNs;
synchronized (nonPersistentJobQueue) {
    nextRunNs=nonPersistentJobQueue.getNextJobDelayUntilNs(hasNetwork);
  }
  if (nextRunNs != null && nextRunNs <= System.nanoTime()) {
    notifyJobConsumer();
    return 0L;
  }
  Long persistedJobRunNs;
synchronized (persistentJobQueue) {
    persistedJobRunNs=persistentJobQueue.getNextJobDelayUntilNs(hasNetwork);
  }
  if (persistedJobRunNs != null) {
    if (nextRunNs == null) {
      nextRunNs=persistedJobRunNs;
    }
 else     if (persistedJobRunNs < nextRunNs) {
      nextRunNs=persistedJobRunNs;
    }
  }
  if (nextRunNs != null) {
    if (nextRunNs < System.nanoTime()) {
      notifyJobConsumer();
      return 0L;
    }
    long diff=(long)Math.ceil((double)(nextRunNs - System.nanoTime()) / NS_PER_MS);
    ensureConsumerOnTime(diff);
    return diff;
  }
  return Long.MAX_VALUE;
}