Program: 96474
Project: 96474
Buggy source:
@SuppressWarnings("String_Node_Str") private Collection<ServiceContext> resolveServices(ServiceRegistry serviceRegistry,File webDir,File tempDir,ServiceType[] serviceConfigs,SecurityContext securityContext,RealmsContext realmsContext,ClusterContext clusterContext,ServiceDefaultsType defaultServiceConfig,SchedulerProvider schedulerProvider,Map<String,Object> dependencyContexts,Properties configuration,TransportFactory transportFactory,ServiceFactory serviceFactory,ResourceAddressFactory resourceAddressFactory,ServiceDefaultsType serviceDefaults) throws Exception {
  Collection<ServiceContext> serviceContexts=new HashSet<>();
  Map<String,String> serviceDefaultsMimeMappings=new HashMap<>();
  serviceDefaultsMimeMappings.putAll(defaultMimeMappings);
  if (defaultServiceConfig != null) {
    for (    MimeMappingType mimeMappingType : defaultServiceConfig.getMimeMappingArray()) {
      serviceDefaultsMimeMappings.put(mimeMappingType.getExtension().toLowerCase(),mimeMappingType.getMimeType());
    }
  }
  List<Map<String,Map<String,CrossSiteConstraintContext>>> authorityToSetOfAcceptConstraintsByURI=new ArrayList<>();
  for (  ServiceType serviceConfig : serviceConfigs) {
    String serviceName=serviceConfig.getName();
    String serviceDescription=serviceConfig.getDescription();
    String[] acceptStrings=serviceConfig.getAcceptArray();
    String[] balanceStrings=serviceConfig.getBalanceArray();
    String[] connectStrings=serviceConfig.getConnectArray();
    String serviceType=serviceConfig.getType();
    Service serviceInstance;
    Class<? extends Service> serviceClass;
    if (serviceType.startsWith(SERVICE_TYPE_CLASS_PREFIX)) {
      String className=serviceType.substring(SERVICE_TYPE_CLASS_PREFIX.length());
      try {
        Class<?> clazz=Class.forName(className);
        if (!Service.class.isAssignableFrom(clazz)) {
          throw new IllegalArgumentException("String_Node_Str" + className);
        }
        serviceClass=(Class<? extends Service>)clazz;
        serviceInstance=serviceClass.newInstance();
      }
 catch (      ClassNotFoundException e) {
        throw new IllegalArgumentException("String_Node_Str" + className);
      }
    }
 else {
      serviceInstance=serviceFactory.newService(serviceType);
      if (serviceInstance == null) {
        throw new IllegalArgumentException("String_Node_Str" + serviceType);
      }
    }
    ServicePropertiesType propertiesType=serviceConfig.getProperties();
    DefaultServiceProperties properties=parsePropertiesType(propertiesType);
    Collection<String> acceptURIs=resolveURIs(acceptStrings);
    Collection<String> balanceURIs=resolveURIs(balanceStrings);
    Collection<String> connectURIs=resolveURIs(connectStrings);
    String acceptProperty=properties.get("String_Node_Str");
    if (acceptProperty != null) {
      acceptProperty=acceptProperty.trim();
      acceptProperty=resolveURI(getCanonicalURI(acceptProperty,false));
      properties.put("String_Node_Str",acceptProperty);
    }
    String connectProperty=properties.get("String_Node_Str");
    if (connectProperty != null) {
      connectProperty=connectProperty.trim();
      properties.remove("String_Node_Str");
      connectURIs.add(resolveURI(getCanonicalURI(connectProperty,true)));
    }
    Collection<String> requireRolesCollection=new LinkedList<>();
    for (    AuthorizationConstraintType authConstraint : serviceConfig.getAuthorizationConstraintArray()) {
      Collections.addAll(requireRolesCollection,authConstraint.getRequireRoleArray());
    }
    RealmContext realmContext=null;
    String name=serviceConfig.getRealmName();
    if (serviceConfig.isSetRealmName()) {
      realmContext=realmsContext.getRealmContext(name);
      if (realmContext != null) {
        if (requireRolesCollection.isEmpty()) {
          Collections.addAll(requireRolesCollection,"String_Node_Str");
        }
      }
    }
    String[] requireRoles=requireRolesCollection.toArray(new String[requireRolesCollection.size()]);
    Map<String,String> mimeMappings=new HashMap<>();
    mimeMappings.putAll(serviceDefaultsMimeMappings);
    for (    MimeMappingType mimeMappingType : serviceConfig.getMimeMappingArray()) {
      mimeMappings.put(mimeMappingType.getExtension().toLowerCase(),mimeMappingType.getMimeType());
    }
    Map<String,Map<String,CrossSiteConstraintContext>> acceptConstraintsByURI=new HashMap<>();
    for (    String acceptURI : acceptURIs) {
      int wildcardOriginCount=0;
      CrossSiteConstraintType[] crossSiteConstraints=serviceConfig.getCrossSiteConstraintArray();
      for (      CrossSiteConstraintType crossSiteConstraint : crossSiteConstraints) {
        String allowOrigin=(String)crossSiteConstraint.getAllowOrigin();
        String allowMethods=crossSiteConstraint.getAllowMethods();
        String allowHeaders=crossSiteConstraint.getAllowHeaders();
        BigInteger maximumAgeBigInt=crossSiteConstraint.getMaximumAge();
        Integer maximumAge=(maximumAgeBigInt == null) ? null : maximumAgeBigInt.intValue();
        if (allowOrigin == null) {
          throw new IllegalArgumentException("String_Node_Str");
        }
        if ("String_Node_Str".equals(allowOrigin)) {
          wildcardOriginCount++;
        }
 else {
          String allowOriginURI=getCanonicalURI(allowOrigin,false);
          allowOrigin=allowOriginURI;
          String allowOriginScheme=getScheme(allowOriginURI);
          if (!"String_Node_Str".equals(allowOriginScheme) && !"String_Node_Str".equals(allowOriginScheme)) {
            throw new IllegalArgumentException("String_Node_Str");
          }
          if (getPath(allowOriginURI) != null && getQuery(allowOriginURI) != null || getFragment(allowOriginURI) != null) {
            throw new IllegalArgumentException("String_Node_Str");
          }
          if (getPort(allowOriginURI) == -1) {
            if ("String_Node_Str".equals(allowOriginScheme)) {
              allowOrigin+="String_Node_Str";
            }
 else             if ("String_Node_Str".equals(allowOriginScheme)) {
              allowOrigin+="String_Node_Str";
            }
 else {
              throw new IllegalArgumentException("String_Node_Str" + allowOriginScheme + "String_Node_Str");
            }
          }
        }
        if (allowMethods != null) {
          String[] allowMethodsArray=allowMethods.split("String_Node_Str");
          for (          String allowMethod : allowMethodsArray) {
            HttpMethod.valueOf(allowMethod);
          }
        }
 else {
          allowMethods="String_Node_Str";
        }
        Map<String,CrossSiteConstraintContext> acceptConstraints=acceptConstraintsByURI.get(acceptURI);
        if (acceptConstraints == null) {
          acceptConstraints=new HashMap<>();
          acceptConstraintsByURI.put(acceptURI,acceptConstraints);
        }
        authorityToSetOfAcceptConstraintsByURI.add(acceptConstraintsByURI);
        CrossSiteConstraintContext acceptConstraint=new DefaultCrossSiteConstraintContext(allowOrigin,allowMethods,allowHeaders,maximumAge);
        CrossSiteConstraintContext oldAcceptConstraint=acceptConstraints.put(allowOrigin,acceptConstraint);
        if (oldAcceptConstraint != null) {
          throw new IllegalArgumentException("String_Node_Str" + acceptURI + "String_Node_Str"+ allowOrigin);
        }
      }
      if (wildcardOriginCount > 0 && crossSiteConstraints.length > 1) {
        throw new IllegalArgumentException("String_Node_Str" + acceptURI + "String_Node_Str");
      }
      String host=getHost(acceptURI);
      if (host == null || host.isEmpty()) {
        throw new IllegalArgumentException("String_Node_Str" + acceptURI + "String_Node_Str");
      }
      if (requireRolesCollection.contains("String_Node_Str") && requireRolesCollection.size() > 1) {
        throw new IllegalArgumentException("String_Node_Str" + acceptURI + "String_Node_Str");
      }
    }
    RealmContext serviceRealmContext=null;
    final String realmName=serviceConfig.getRealmName();
    if (serviceConfig.isSetRealmName()) {
      serviceRealmContext=realmsContext.getRealmContext(realmName);
      if (serviceRealmContext == null) {
        throw new IllegalArgumentException("String_Node_Str" + realmName + "String_Node_Str");
      }
    }
    ServiceAcceptOptionsType acceptOptions=serviceConfig.getAcceptOptions();
    ServiceAcceptOptionsType defaultOptionsConfig=(defaultServiceConfig != null) ? defaultServiceConfig.getAcceptOptions() : null;
    AcceptOptionsContext acceptOptionsContext=new DefaultAcceptOptionsContext(acceptOptions,defaultOptionsConfig);
    ServiceConnectOptionsType connectOptions=serviceConfig.getConnectOptions();
    ServiceConnectOptionsType defaultConnectOptions=(serviceDefaults == null) ? ServiceConnectOptionsType.Factory.newInstance() : serviceDefaults.getConnectOptions();
    ConnectOptionsContext connectOptionsContext=new DefaultConnectOptionsContext(connectOptions,defaultConnectOptions);
    Key encryptionKey=null;
    if (serviceRealmContext == null && requireRolesCollection.size() > 0) {
      throw new IllegalArgumentException("String_Node_Str" + "String_Node_Str" + serviceDescription + "String_Node_Str");
    }
    DefaultServiceContext serviceContext=new DefaultServiceContext(serviceType,serviceName,serviceDescription,serviceInstance,webDir,tempDir,balanceURIs,acceptURIs,connectURIs,properties,requireRoles,mimeMappings,acceptConstraintsByURI,clusterContext,acceptOptionsContext,connectOptionsContext,serviceRealmContext,encryptionKey,schedulerProvider,supportsAccepts(serviceType),supportsConnects(serviceType),supportsMimeMappings(serviceType),InternalSystemProperty.TCP_PROCESSOR_COUNT.getIntProperty(configuration),transportFactory,resourceAddressFactory);
    serviceContexts.add(serviceContext);
    for (    String acceptURI : acceptURIs) {
      String authority=getAuthority(acceptURI);
      if (authority.indexOf(':') == -1) {
        SchemeConfig schemeConfig=supplySchemeConfig(getScheme(acceptURI));
        authority+="String_Node_Str" + schemeConfig.getDefaultPort();
        acceptURI=getScheme(acceptURI) + "String_Node_Str" + authority+ getPath(acceptURI);
      }
      serviceRegistry.register(acceptURI,serviceContext);
    }
  }
  for (  ServiceContext ctxt : serviceContexts) {
    ctxt.setListsOfAcceptConstraintsByURI(authorityToSetOfAcceptConstraintsByURI);
  }
  return serviceContexts;
}

Fixed version (ground truth):
@SuppressWarnings("String_Node_Str") private Collection<ServiceContext> resolveServices(ServiceRegistry serviceRegistry,File webDir,File tempDir,ServiceType[] serviceConfigs,SecurityContext securityContext,RealmsContext realmsContext,ClusterContext clusterContext,ServiceDefaultsType defaultServiceConfig,SchedulerProvider schedulerProvider,Map<String,Object> dependencyContexts,Properties configuration,TransportFactory transportFactory,ServiceFactory serviceFactory,ResourceAddressFactory resourceAddressFactory,ServiceDefaultsType serviceDefaults) throws Exception {
  Collection<ServiceContext> serviceContexts=new HashSet<>();
  Map<String,String> serviceDefaultsMimeMappings=new HashMap<>();
  serviceDefaultsMimeMappings.putAll(defaultMimeMappings);
  if (defaultServiceConfig != null) {
    for (    MimeMappingType mimeMappingType : defaultServiceConfig.getMimeMappingArray()) {
      serviceDefaultsMimeMappings.put(mimeMappingType.getExtension().toLowerCase(),mimeMappingType.getMimeType());
    }
  }
  List<Map<String,Map<String,CrossSiteConstraintContext>>> authorityToSetOfAcceptConstraintsByURI=new ArrayList<>();
  for (  ServiceType serviceConfig : serviceConfigs) {
    String serviceName=serviceConfig.getName();
    String serviceDescription=serviceConfig.getDescription();
    String[] acceptStrings=serviceConfig.getAcceptArray();
    String[] balanceStrings=serviceConfig.getBalanceArray();
    String[] connectStrings=serviceConfig.getConnectArray();
    String serviceType=serviceConfig.getType();
    Service serviceInstance;
    Class<? extends Service> serviceClass;
    if (serviceType.startsWith(SERVICE_TYPE_CLASS_PREFIX)) {
      String className=serviceType.substring(SERVICE_TYPE_CLASS_PREFIX.length());
      try {
        Class<?> clazz=Class.forName(className);
        if (!Service.class.isAssignableFrom(clazz)) {
          throw new IllegalArgumentException("String_Node_Str" + className);
        }
        serviceClass=(Class<? extends Service>)clazz;
        serviceInstance=serviceClass.newInstance();
      }
 catch (      ClassNotFoundException e) {
        throw new IllegalArgumentException("String_Node_Str" + className);
      }
    }
 else {
      serviceInstance=serviceFactory.newService(serviceType);
      if (serviceInstance == null) {
        throw new IllegalArgumentException("String_Node_Str" + serviceType);
      }
    }
    ServicePropertiesType propertiesType=serviceConfig.getProperties();
    DefaultServiceProperties properties=parsePropertiesType(propertiesType);
    Collection<String> acceptURIs=resolveURIs(acceptStrings);
    Collection<String> balanceURIs=resolveURIs(balanceStrings);
    Collection<String> connectURIs=resolveURIs(connectStrings);
    String acceptProperty=properties.get("String_Node_Str");
    if (acceptProperty != null) {
      acceptProperty=acceptProperty.trim();
      acceptProperty=resolveURI(getCanonicalURI(acceptProperty,false));
      properties.put("String_Node_Str",acceptProperty);
    }
    String connectProperty=properties.get("String_Node_Str");
    if (connectProperty != null) {
      connectProperty=connectProperty.trim();
      properties.remove("String_Node_Str");
      connectURIs.add(resolveURI(getCanonicalURI(connectProperty,true)));
    }
    Collection<String> requireRolesCollection=new LinkedList<>();
    for (    AuthorizationConstraintType authConstraint : serviceConfig.getAuthorizationConstraintArray()) {
      Collections.addAll(requireRolesCollection,authConstraint.getRequireRoleArray());
    }
    String[] requireRoles=requireRolesCollection.toArray(new String[requireRolesCollection.size()]);
    Map<String,String> mimeMappings=new HashMap<>();
    mimeMappings.putAll(serviceDefaultsMimeMappings);
    for (    MimeMappingType mimeMappingType : serviceConfig.getMimeMappingArray()) {
      mimeMappings.put(mimeMappingType.getExtension().toLowerCase(),mimeMappingType.getMimeType());
    }
    Map<String,Map<String,CrossSiteConstraintContext>> acceptConstraintsByURI=new HashMap<>();
    for (    String acceptURI : acceptURIs) {
      int wildcardOriginCount=0;
      CrossSiteConstraintType[] crossSiteConstraints=serviceConfig.getCrossSiteConstraintArray();
      for (      CrossSiteConstraintType crossSiteConstraint : crossSiteConstraints) {
        String allowOrigin=(String)crossSiteConstraint.getAllowOrigin();
        String allowMethods=crossSiteConstraint.getAllowMethods();
        String allowHeaders=crossSiteConstraint.getAllowHeaders();
        BigInteger maximumAgeBigInt=crossSiteConstraint.getMaximumAge();
        Integer maximumAge=(maximumAgeBigInt == null) ? null : maximumAgeBigInt.intValue();
        if (allowOrigin == null) {
          throw new IllegalArgumentException("String_Node_Str");
        }
        if ("String_Node_Str".equals(allowOrigin)) {
          wildcardOriginCount++;
        }
 else {
          String allowOriginURI=getCanonicalURI(allowOrigin,false);
          allowOrigin=allowOriginURI;
          String allowOriginScheme=getScheme(allowOriginURI);
          if (!"String_Node_Str".equals(allowOriginScheme) && !"String_Node_Str".equals(allowOriginScheme)) {
            throw new IllegalArgumentException("String_Node_Str");
          }
          if (getPath(allowOriginURI) != null && getQuery(allowOriginURI) != null || getFragment(allowOriginURI) != null) {
            throw new IllegalArgumentException("String_Node_Str");
          }
          if (getPort(allowOriginURI) == -1) {
            if ("String_Node_Str".equals(allowOriginScheme)) {
              allowOrigin+="String_Node_Str";
            }
 else             if ("String_Node_Str".equals(allowOriginScheme)) {
              allowOrigin+="String_Node_Str";
            }
 else {
              throw new IllegalArgumentException("String_Node_Str" + allowOriginScheme + "String_Node_Str");
            }
          }
        }
        if (allowMethods != null) {
          String[] allowMethodsArray=allowMethods.split("String_Node_Str");
          for (          String allowMethod : allowMethodsArray) {
            HttpMethod.valueOf(allowMethod);
          }
        }
 else {
          allowMethods="String_Node_Str";
        }
        Map<String,CrossSiteConstraintContext> acceptConstraints=acceptConstraintsByURI.get(acceptURI);
        if (acceptConstraints == null) {
          acceptConstraints=new HashMap<>();
          acceptConstraintsByURI.put(acceptURI,acceptConstraints);
        }
        authorityToSetOfAcceptConstraintsByURI.add(acceptConstraintsByURI);
        CrossSiteConstraintContext acceptConstraint=new DefaultCrossSiteConstraintContext(allowOrigin,allowMethods,allowHeaders,maximumAge);
        CrossSiteConstraintContext oldAcceptConstraint=acceptConstraints.put(allowOrigin,acceptConstraint);
        if (oldAcceptConstraint != null) {
          throw new IllegalArgumentException("String_Node_Str" + acceptURI + "String_Node_Str"+ allowOrigin);
        }
      }
      if (wildcardOriginCount > 0 && crossSiteConstraints.length > 1) {
        throw new IllegalArgumentException("String_Node_Str" + acceptURI + "String_Node_Str");
      }
      String host=getHost(acceptURI);
      if (host == null || host.isEmpty()) {
        throw new IllegalArgumentException("String_Node_Str" + acceptURI + "String_Node_Str");
      }
      if (requireRolesCollection.contains("String_Node_Str") && requireRolesCollection.size() > 1) {
        throw new IllegalArgumentException("String_Node_Str" + acceptURI + "String_Node_Str");
      }
    }
    RealmContext serviceRealmContext=null;
    final String realmName=serviceConfig.getRealmName();
    if (serviceConfig.isSetRealmName()) {
      serviceRealmContext=realmsContext.getRealmContext(realmName);
      if (serviceRealmContext == null) {
        throw new IllegalArgumentException("String_Node_Str" + realmName + "String_Node_Str");
      }
    }
    ServiceAcceptOptionsType acceptOptions=serviceConfig.getAcceptOptions();
    ServiceAcceptOptionsType defaultOptionsConfig=(defaultServiceConfig != null) ? defaultServiceConfig.getAcceptOptions() : null;
    AcceptOptionsContext acceptOptionsContext=new DefaultAcceptOptionsContext(acceptOptions,defaultOptionsConfig);
    ServiceConnectOptionsType connectOptions=serviceConfig.getConnectOptions();
    ServiceConnectOptionsType defaultConnectOptions=(serviceDefaults == null) ? ServiceConnectOptionsType.Factory.newInstance() : serviceDefaults.getConnectOptions();
    ConnectOptionsContext connectOptionsContext=new DefaultConnectOptionsContext(connectOptions,defaultConnectOptions);
    Key encryptionKey=null;
    if (serviceRealmContext == null && requireRolesCollection.size() > 0) {
      throw new IllegalArgumentException("String_Node_Str" + "String_Node_Str" + serviceDescription + "String_Node_Str");
    }
    DefaultServiceContext serviceContext=new DefaultServiceContext(serviceType,serviceName,serviceDescription,serviceInstance,webDir,tempDir,balanceURIs,acceptURIs,connectURIs,properties,requireRoles,mimeMappings,acceptConstraintsByURI,clusterContext,acceptOptionsContext,connectOptionsContext,serviceRealmContext,encryptionKey,schedulerProvider,supportsAccepts(serviceType),supportsConnects(serviceType),supportsMimeMappings(serviceType),InternalSystemProperty.TCP_PROCESSOR_COUNT.getIntProperty(configuration),transportFactory,resourceAddressFactory);
    serviceContexts.add(serviceContext);
    for (    String acceptURI : acceptURIs) {
      String authority=getAuthority(acceptURI);
      if (authority.indexOf(':') == -1) {
        SchemeConfig schemeConfig=supplySchemeConfig(getScheme(acceptURI));
        authority+="String_Node_Str" + schemeConfig.getDefaultPort();
        acceptURI=getScheme(acceptURI) + "String_Node_Str" + authority+ getPath(acceptURI);
      }
      serviceRegistry.register(acceptURI,serviceContext);
    }
  }
  for (  ServiceContext ctxt : serviceContexts) {
    ctxt.setListsOfAcceptConstraintsByURI(authorityToSetOfAcceptConstraintsByURI);
  }
  return serviceContexts;
}