Program: 79575
Project: 79575
Buggy source:
/** 
 * causes all scanning-based classpaths to scan the classpaths (but does _not_ load all JARs) 
 */
synchronized void load(){
  if (classpath == null)   return;
  if (classpath.getEntries() == null)   urls=new URL[0];
 else {
    urls=new URL[classpath.getEntries().size()];
    for (int i=0; i < urls.length; i++) {
      try {
        urls[i]=new URL(classpath.getEntries().get(i));
      }
 catch (      MalformedURLException e) {
        log.error("String_Node_Str" + classpath.getEntries().get(i) + "String_Node_Str"+ catalog+ "String_Node_Str");
        throw Exceptions.propagate(e);
      }
    }
  }
  String prefix=null;
  if (scanMode == null || scanMode == CatalogScanningModes.NONE)   return;
  Stopwatch timer=new Stopwatch().start();
  ReflectionScanner scanner=null;
  if (!catalog.isLocal()) {
    log.warn("String_Node_Str" + catalog);
  }
 else   if (classpath.getEntries() == null || classpath.getEntries().isEmpty()) {
    if (!catalog.isLocal()) {
      log.warn("String_Node_Str" + catalog);
    }
 else {
      ClassLoader baseCL=null;
      Iterable<URL> baseCP=null;
      if (catalog.mgmt instanceof ManagementContextInternal) {
        baseCL=((ManagementContextInternal)catalog.mgmt).getBaseClassLoader();
        baseCP=((ManagementContextInternal)catalog.mgmt).getBaseClassPathForScanning();
      }
      scanner=new ReflectionScanner(baseCL,catalog.getRootClassLoader(),baseCP,prefix);
      if (scanner.getSubTypesOf(Entity.class).isEmpty()) {
        try {
          ((ManagementContextInternal)catalog.mgmt).setBaseClassPathForScanning(ClasspathHelper.forJavaClassPath());
          log.debug("String_Node_Str");
          baseCP=((ManagementContextInternal)catalog.mgmt).getBaseClassPathForScanning();
          scanner=new ReflectionScanner(baseCL,catalog.getRootClassLoader(),baseCP,prefix);
        }
 catch (        Exception e) {
          log.info("String_Node_Str" + baseCP + "String_Node_Str");
          Exceptions.propagateIfFatal(e);
        }
      }
    }
  }
 else {
    scanner=new ReflectionScanner(getLocalClassLoader(),catalog.getRootClassLoader(),null,prefix);
  }
  if (scanner != null) {
    int count=0, countApps=0;
    if (scanMode == CatalogScanningModes.ANNOTATIONS) {
      Set<Class<?>> catalogClasses=scanner.getTypesAnnotatedWith(Catalog.class);
      for (      Class<?> c : catalogClasses) {
        try {
          CatalogItem<?> item=addCatalogEntry(c);
          count++;
          if (CatalogTemplateItemDto.class.isInstance(item))           countApps++;
        }
 catch (        Exception e) {
          log.warn("String_Node_Str" + c + "String_Node_Str",e);
        }
      }
    }
 else     if (scanMode == CatalogScanningModes.TYPES) {
      Iterable<Class<?>> entities=this.excludeInvalidClasses(Iterables.concat(scanner.getSubTypesOf(Entity.class),scanner.getSubTypesOf(Application.class),scanner.getSubTypesOf(ApplicationBuilder.class)));
      for (      Class<?> c : entities) {
        if (Application.class.isAssignableFrom(c) || ApplicationBuilder.class.isAssignableFrom(c)) {
          addCatalogEntry(new CatalogTemplateItemDto(),c);
          countApps++;
        }
 else {
          addCatalogEntry(new CatalogEntityItemDto(),c);
        }
        count++;
      }
      Iterable<Class<? extends Policy>> policies=this.excludeInvalidClasses(scanner.getSubTypesOf(Policy.class));
      for (      Class<?> c : policies) {
        addCatalogEntry(new CatalogPolicyItemDto(),c);
        count++;
      }
    }
 else {
      throw new IllegalStateException("String_Node_Str" + scanMode + "String_Node_Str"+ this);
    }
    log.info("String_Node_Str" + catalog.dto.name + "String_Node_Str"+ count+ "String_Node_Str"+ countApps+ "String_Node_Str"+ Time.makeTimeStringRounded(timer));
  }
  isLoaded=true;
}

Fixed version (ground truth):
/** 
 * causes all scanning-based classpaths to scan the classpaths (but does _not_ load all JARs) 
 */
synchronized void load(){
  if (classpath == null)   return;
  if (classpath.getEntries() == null)   urls=new URL[0];
 else {
    urls=new URL[classpath.getEntries().size()];
    for (int i=0; i < urls.length; i++) {
      try {
        urls[i]=new URL(classpath.getEntries().get(i));
      }
 catch (      MalformedURLException e) {
        log.error("String_Node_Str" + classpath.getEntries().get(i) + "String_Node_Str"+ catalog+ "String_Node_Str");
        throw Exceptions.propagate(e);
      }
    }
  }
  String prefix=null;
  if (scanMode == null || scanMode == CatalogScanningModes.NONE)   return;
  Stopwatch timer=new Stopwatch().start();
  ReflectionScanner scanner=null;
  if (!catalog.isLocal()) {
    log.warn("String_Node_Str" + catalog);
  }
 else   if (classpath.getEntries() == null || classpath.getEntries().isEmpty()) {
    if (!catalog.isLocal()) {
      log.warn("String_Node_Str" + catalog);
    }
 else {
      ClassLoader baseCL=null;
      Iterable<URL> baseCP=null;
      if (catalog.mgmt instanceof ManagementContextInternal) {
        baseCL=((ManagementContextInternal)catalog.mgmt).getBaseClassLoader();
        baseCP=((ManagementContextInternal)catalog.mgmt).getBaseClassPathForScanning();
      }
      scanner=new ReflectionScanner(baseCP,prefix,baseCL,catalog.getRootClassLoader());
      if (scanner.getSubTypesOf(Entity.class).isEmpty()) {
        try {
          ((ManagementContextInternal)catalog.mgmt).setBaseClassPathForScanning(ClasspathHelper.forJavaClassPath());
          log.debug("String_Node_Str");
          baseCP=((ManagementContextInternal)catalog.mgmt).getBaseClassPathForScanning();
          scanner=new ReflectionScanner(baseCP,prefix,baseCL,catalog.getRootClassLoader());
        }
 catch (        Exception e) {
          log.info("String_Node_Str" + baseCP + "String_Node_Str");
          Exceptions.propagateIfFatal(e);
        }
      }
    }
  }
 else {
    scanner=new ReflectionScanner(urls == null || urls.length == 0 ? null : Arrays.asList(urls),prefix,getLocalClassLoader());
  }
  if (scanner != null) {
    int count=0, countApps=0;
    if (scanMode == CatalogScanningModes.ANNOTATIONS) {
      Set<Class<?>> catalogClasses=scanner.getTypesAnnotatedWith(Catalog.class);
      for (      Class<?> c : catalogClasses) {
        try {
          CatalogItem<?> item=addCatalogEntry(c);
          count++;
          if (CatalogTemplateItemDto.class.isInstance(item))           countApps++;
        }
 catch (        Exception e) {
          log.warn("String_Node_Str" + c + "String_Node_Str",e);
        }
      }
    }
 else     if (scanMode == CatalogScanningModes.TYPES) {
      Iterable<Class<?>> entities=this.excludeInvalidClasses(Iterables.concat(scanner.getSubTypesOf(Entity.class),scanner.getSubTypesOf(Application.class),scanner.getSubTypesOf(ApplicationBuilder.class)));
      for (      Class<?> c : entities) {
        if (Application.class.isAssignableFrom(c) || ApplicationBuilder.class.isAssignableFrom(c)) {
          addCatalogEntry(new CatalogTemplateItemDto(),c);
          countApps++;
        }
 else {
          addCatalogEntry(new CatalogEntityItemDto(),c);
        }
        count++;
      }
      Iterable<Class<? extends Policy>> policies=this.excludeInvalidClasses(scanner.getSubTypesOf(Policy.class));
      for (      Class<?> c : policies) {
        addCatalogEntry(new CatalogPolicyItemDto(),c);
        count++;
      }
    }
 else {
      throw new IllegalStateException("String_Node_Str" + scanMode + "String_Node_Str"+ this);
    }
    log.info("String_Node_Str" + catalog.dto.name + "String_Node_Str"+ count+ "String_Node_Str"+ Strings.s(count)+ "String_Node_Str"+ countApps+ "String_Node_Str"+ Strings.s(countApps)+ "String_Node_Str"+ Time.makeTimeStringRounded(timer));
  }
  isLoaded=true;
}