Program: 53012
Project: 53012
Buggy source:
private static ImmutableList<AppleCxxPlatform> buildAppleCxxPlatforms(Supplier<Optional<Path>> appleDeveloperDirectorySupplier,ImmutableList<Path> extraToolchainPaths,ImmutableList<Path> extraPlatformPaths,BuckConfig buckConfig,AppleConfig appleConfig,SwiftBuckConfig swiftBuckConfig,ProcessExecutor processExecutor) throws IOException {
  Optional<Path> appleDeveloperDirectory=appleDeveloperDirectorySupplier.get();
  if (appleDeveloperDirectory.isPresent() && !Files.isDirectory(appleDeveloperDirectory.get())) {
    LOG.error("String_Node_Str",appleDeveloperDirectory.get());
    return ImmutableList.of();
  }
  ImmutableList.Builder<AppleCxxPlatform> appleCxxPlatformsBuilder=ImmutableList.builder();
  ImmutableMap<String,AppleToolchain> toolchains=AppleToolchainDiscovery.discoverAppleToolchains(appleDeveloperDirectory,extraToolchainPaths);
  ImmutableMap<AppleSdk,AppleSdkPaths> sdkPaths=AppleSdkDiscovery.discoverAppleSdkPaths(appleDeveloperDirectory,extraPlatformPaths,toolchains,appleConfig);
  Optional<String> swiftVersion=swiftBuckConfig.getVersion();
  Optional<AppleToolchain> swiftToolChain=Optional.empty();
  if (swiftVersion.isPresent()) {
    Optional<String> swiftToolChainName=swiftVersion.map(AppleCxxPlatform.SWIFT_VERSION_TO_TOOLCHAIN_IDENTIFIER);
    swiftToolChain=toolchains.values().stream().filter(input -> input.getIdentifier().equals(swiftToolChainName.get())).findFirst();
  }
  for (  Map.Entry<AppleSdk,AppleSdkPaths> entry : sdkPaths.entrySet()) {
    AppleSdk sdk=entry.getKey();
    AppleSdkPaths appleSdkPaths=entry.getValue();
    String targetSdkVersion=appleConfig.getTargetSdkVersion(sdk.getApplePlatform()).orElse(sdk.getVersion());
    LOG.debug("String_Node_Str",sdk,targetSdkVersion);
    for (    String architecture : sdk.getArchitectures()) {
      AppleCxxPlatform appleCxxPlatform=AppleCxxPlatforms.build(sdk,targetSdkVersion,architecture,appleSdkPaths,buckConfig,appleConfig,Optional.of(processExecutor),swiftToolChain);
      appleCxxPlatformsBuilder.add(appleCxxPlatform);
    }
  }
  return appleCxxPlatformsBuilder.build();
}

Fixed version (ground truth):
private static ImmutableList<AppleCxxPlatform> buildAppleCxxPlatforms(ProjectFilesystem filesystem,Supplier<Optional<Path>> appleDeveloperDirectorySupplier,ImmutableList<Path> extraToolchainPaths,ImmutableList<Path> extraPlatformPaths,BuckConfig buckConfig,AppleConfig appleConfig,SwiftBuckConfig swiftBuckConfig,ProcessExecutor processExecutor) throws IOException {
  Optional<Path> appleDeveloperDirectory=appleDeveloperDirectorySupplier.get();
  if (appleDeveloperDirectory.isPresent() && !Files.isDirectory(appleDeveloperDirectory.get())) {
    LOG.error("String_Node_Str",appleDeveloperDirectory.get());
    return ImmutableList.of();
  }
  ImmutableList.Builder<AppleCxxPlatform> appleCxxPlatformsBuilder=ImmutableList.builder();
  ImmutableMap<String,AppleToolchain> toolchains=AppleToolchainDiscovery.discoverAppleToolchains(appleDeveloperDirectory,extraToolchainPaths);
  ImmutableMap<AppleSdk,AppleSdkPaths> sdkPaths=AppleSdkDiscovery.discoverAppleSdkPaths(appleDeveloperDirectory,extraPlatformPaths,toolchains,appleConfig);
  Optional<String> swiftVersion=swiftBuckConfig.getVersion();
  Optional<AppleToolchain> swiftToolChain=Optional.empty();
  if (swiftVersion.isPresent()) {
    Optional<String> swiftToolChainName=swiftVersion.map(AppleCxxPlatform.SWIFT_VERSION_TO_TOOLCHAIN_IDENTIFIER);
    swiftToolChain=toolchains.values().stream().filter(input -> input.getIdentifier().equals(swiftToolChainName.get())).findFirst();
  }
  for (  Map.Entry<AppleSdk,AppleSdkPaths> entry : sdkPaths.entrySet()) {
    AppleSdk sdk=entry.getKey();
    AppleSdkPaths appleSdkPaths=entry.getValue();
    String targetSdkVersion=appleConfig.getTargetSdkVersion(sdk.getApplePlatform()).orElse(sdk.getVersion());
    LOG.debug("String_Node_Str",sdk,targetSdkVersion);
    for (    String architecture : sdk.getArchitectures()) {
      AppleCxxPlatform appleCxxPlatform=AppleCxxPlatforms.build(filesystem,sdk,targetSdkVersion,architecture,appleSdkPaths,buckConfig,appleConfig,Optional.of(processExecutor),swiftToolChain);
      appleCxxPlatformsBuilder.add(appleCxxPlatform);
    }
  }
  return appleCxxPlatformsBuilder.build();
}