Program: 30093
Project: 30093
Buggy source:
public Object prepareInvocation(boolean doPreInvoke) throws Exception {
  ComponentInvocation inv=null;
  AdapterInvocationInfo adapterInvInfo=new AdapterInvocationInfo();
  if (adapter == null) {
synchronized (this) {
      if (adapter == null) {
        try {
          EjbDescriptor ejbDesc=endpoint.getEjbComponentImpl();
          Iterator<ResourceReferenceDescriptor> it=ejbDesc.getResourceReferenceDescriptors().iterator();
          while (it.hasNext()) {
            ResourceReferenceDescriptor r=it.next();
            if (r.isWebServiceContext()) {
              Iterator<InjectionTarget> iter=r.getInjectionTargets().iterator();
              boolean matchingClassFound=false;
              while (iter.hasNext()) {
                InjectionTarget target=iter.next();
                if (ejbDesc.getEjbClassName().equals(target.getClassName())) {
                  matchingClassFound=true;
                  break;
                }
              }
              if (!matchingClassFound) {
                continue;
              }
              try {
                javax.naming.InitialContext ic=new javax.naming.InitialContext();
                wsCtxt=(WebServiceContextImpl)ic.lookup("String_Node_Str" + r.getName());
              }
 catch (              Throwable t) {
                logger.fine("String_Node_Str" + t.getCause());
              }
            }
          }
          if (wsCtxt == null) {
            wsCtxt=new WebServiceContextImpl();
          }
        }
 catch (        Throwable t) {
          t.printStackTrace();
          logger.severe("String_Node_Str" + endpoint.getName() + "String_Node_Str"+ t.getMessage());
          return null;
        }
      }
    }
  }
  if (doPreInvoke) {
    inv=container.startInvocation();
    adapterInvInfo.setInv(inv);
  }
  if (!handlersConfigured && doPreInvoke) {
synchronized (this) {
      if (!handlersConfigured) {
        try {
          WsUtil wsu=new WsUtil();
          String implClassName=endpoint.getEjbComponentImpl().getEjbClassName();
          Class clazz=container.getEndpointClassLoader().loadClass(implClassName);
          String givenBinding=endpoint.getProtocolBinding();
          SDDocumentSource primaryWsdl=null;
          Collection docs=null;
          if (endpoint.getWebService().hasWsdlFile()) {
            WebServiceContractImpl wscImpl=WebServiceContractImpl.getInstance();
            ApplicationRegistry appRegistry=wscImpl.getHabitat().getByType(ApplicationRegistry.class);
            ApplicationInfo appInfo=appRegistry.get(endpoint.getBundleDescriptor().getApplication().getRegistrationName());
            URI deployedDir=appInfo.getSource().getURI();
            URL pkgedWsdl;
            if (deployedDir != null) {
              if (endpoint.getBundleDescriptor().getApplication().isVirtual()) {
                pkgedWsdl=deployedDir.resolve(endpoint.getWebService().getWsdlFileUri()).toURL();
              }
 else {
                String moduleUri1=endpoint.getBundleDescriptor().getModuleDescriptor().getArchiveUri();
                String moduleUri=FileUtils.makeFriendlyFilenameExtension(moduleUri1);
                pkgedWsdl=deployedDir.resolve(moduleUri + "String_Node_Str" + endpoint.getWebService().getWsdlFileUri()).toURL();
              }
            }
 else {
              pkgedWsdl=endpoint.getWebService().getWsdlFileUrl();
            }
            if (pkgedWsdl != null) {
              primaryWsdl=SDDocumentSource.create(pkgedWsdl);
              docs=wsu.getWsdlsAndSchemas(pkgedWsdl);
            }
          }
          JAXWSContainer container=new JAXWSContainer(null,endpoint);
          java.net.URL catalogURL=clazz.getResource('/' + endpoint.getBundleDescriptor().getDeploymentDescriptorDir() + File.separator+ "String_Node_Str");
          boolean mtomEnabled=wsu.getMtom(endpoint);
          WSBinding binding=null;
          ArrayList<WebServiceFeature> wsFeatures=new ArrayList<WebServiceFeature>();
          if (mtomEnabled) {
            int mtomThreshold=endpoint.getMtomThreshold() != null ? new Integer(endpoint.getMtomThreshold()) : 0;
            MTOMFeature mtom=new MTOMFeature(true,mtomThreshold);
            wsFeatures.add(mtom);
          }
          Addressing addressing=endpoint.getAddressing();
          if (endpoint.getAddressing() != null) {
            AddressingFeature addressingFeature=new AddressingFeature(addressing.isEnabled(),addressing.isRequired(),getResponse(addressing.getResponses()));
            wsFeatures.add(addressingFeature);
          }
          if (wsFeatures.size() > 0) {
            binding=BindingID.parse(givenBinding).createBinding(wsFeatures.toArray(new WebServiceFeature[wsFeatures.size()]));
          }
 else {
            binding=BindingID.parse(givenBinding).createBinding();
          }
          wsu.configureJAXWSServiceHandlers(endpoint,endpoint.getProtocolBinding(),binding);
          Invoker invoker=new InstanceResolverImpl(clazz).createInvoker();
          WSEndpoint wsep=WSEndpoint.create(clazz,false,new EjbInvokerImpl(clazz,invoker,webServiceEndpointServant,wsCtxt),endpoint.getServiceName(),endpoint.getWsdlPort(),container,binding,primaryWsdl,docs,catalogURL);
          String uri=endpoint.getEndpointAddressUri();
          String urlPattern=uri.startsWith("String_Node_Str") ? uri : "String_Node_Str" + uri;
          if (adapterList == null) {
            adapterList=new ServletAdapterList();
          }
          adapter=adapterList.createAdapter(endpoint.getName(),urlPattern,wsep);
          handlersConfigured=true;
        }
 catch (        Throwable t) {
          logger.log(Level.SEVERE,"String_Node_Str" + endpoint.getName() + "String_Node_Str",t);
          adapter=null;
        }
      }
    }
  }
  addWSContextInfo(wsCtxt);
  if (inv != null) {
    EJBInvocation ejbInv=(EJBInvocation)inv;
    ejbInv.setWebServiceContext(wsCtxt);
  }
  adapterInvInfo.setAdapter(adapter);
  return adapterInvInfo;
}

Fixed version (ground truth):
public Object prepareInvocation(boolean doPreInvoke) throws Exception {
  ComponentInvocation inv=null;
  AdapterInvocationInfo adapterInvInfo=new AdapterInvocationInfo();
  if (adapter == null) {
synchronized (this) {
      if (adapter == null) {
        try {
          EjbDescriptor ejbDesc=endpoint.getEjbComponentImpl();
          Iterator<ResourceReferenceDescriptor> it=ejbDesc.getResourceReferenceDescriptors().iterator();
          while (it.hasNext()) {
            ResourceReferenceDescriptor r=it.next();
            if (r.isWebServiceContext()) {
              Iterator<InjectionTarget> iter=r.getInjectionTargets().iterator();
              boolean matchingClassFound=false;
              while (iter.hasNext()) {
                InjectionTarget target=iter.next();
                if (ejbDesc.getEjbClassName().equals(target.getClassName())) {
                  matchingClassFound=true;
                  break;
                }
              }
              if (!matchingClassFound) {
                continue;
              }
              try {
                javax.naming.InitialContext ic=new javax.naming.InitialContext();
                wsCtxt=(WebServiceContextImpl)ic.lookup("String_Node_Str" + r.getName());
              }
 catch (              Throwable t) {
                logger.fine("String_Node_Str" + t.getCause());
              }
            }
          }
          if (wsCtxt == null) {
            wsCtxt=new WebServiceContextImpl();
          }
        }
 catch (        Throwable t) {
          t.printStackTrace();
          logger.severe("String_Node_Str" + endpoint.getName() + "String_Node_Str"+ t.getMessage());
          return null;
        }
      }
    }
  }
  if (doPreInvoke) {
    inv=container.startInvocation();
    adapterInvInfo.setInv(inv);
  }
  if (!handlersConfigured && doPreInvoke) {
synchronized (this) {
      if (!handlersConfigured) {
        try {
          WsUtil wsu=new WsUtil();
          String implClassName=endpoint.getEjbComponentImpl().getEjbClassName();
          Class clazz=container.getEndpointClassLoader().loadClass(implClassName);
          String givenBinding=endpoint.getProtocolBinding();
          SDDocumentSource primaryWsdl=null;
          Collection docs=null;
          if (endpoint.getWebService().hasWsdlFile()) {
            WebServiceContractImpl wscImpl=WebServiceContractImpl.getInstance();
            ApplicationRegistry appRegistry=wscImpl.getHabitat().getByType(ApplicationRegistry.class);
            ApplicationInfo appInfo=appRegistry.get(endpoint.getBundleDescriptor().getApplication().getRegistrationName());
            URI deployedDir=appInfo.getSource().getURI();
            URL pkgedWsdl;
            if (deployedDir != null) {
              if (endpoint.getBundleDescriptor().getApplication().isVirtual()) {
                pkgedWsdl=deployedDir.resolve(endpoint.getWebService().getWsdlFileUri()).toURL();
              }
 else {
                String moduleUri1=endpoint.getBundleDescriptor().getModuleDescriptor().getArchiveUri();
                String moduleUri=FileUtils.makeFriendlyFilenameExtension(moduleUri1);
                pkgedWsdl=deployedDir.resolve(moduleUri + "String_Node_Str" + endpoint.getWebService().getWsdlFileUri()).toURL();
              }
            }
 else {
              pkgedWsdl=endpoint.getWebService().getWsdlFileUrl();
            }
            if (pkgedWsdl != null) {
              primaryWsdl=SDDocumentSource.create(pkgedWsdl);
              docs=wsu.getWsdlsAndSchemas(pkgedWsdl);
            }
          }
          JAXWSContainer container=new JAXWSContainer(null,endpoint);
          java.net.URL catalogURL=clazz.getResource('/' + endpoint.getBundleDescriptor().getDeploymentDescriptorDir() + File.separator+ "String_Node_Str");
          boolean mtomEnabled=wsu.getMtom(endpoint);
          WSBinding binding=null;
          ArrayList<WebServiceFeature> wsFeatures=new ArrayList<WebServiceFeature>();
          if (mtomEnabled) {
            int mtomThreshold=endpoint.getMtomThreshold() != null ? new Integer(endpoint.getMtomThreshold()) : 0;
            MTOMFeature mtom=new MTOMFeature(true,mtomThreshold);
            wsFeatures.add(mtom);
          }
          Addressing addressing=endpoint.getAddressing();
          if (endpoint.getAddressing() != null) {
            AddressingFeature addressingFeature=new AddressingFeature(addressing.isEnabled(),addressing.isRequired(),getResponse(addressing.getResponses()));
            wsFeatures.add(addressingFeature);
          }
          if (wsFeatures.size() > 0) {
            binding=BindingID.parse(givenBinding).createBinding(wsFeatures.toArray(new WebServiceFeature[wsFeatures.size()]));
          }
 else {
            binding=BindingID.parse(givenBinding).createBinding();
          }
          wsu.configureJAXWSServiceHandlers(endpoint,endpoint.getProtocolBinding(),binding);
          Invoker invoker=new InstanceResolverImpl(clazz).createInvoker();
          WSEndpoint wsep=WSEndpoint.create(clazz,false,new EjbInvokerImpl(clazz,invoker,webServiceEndpointServant,wsCtxt),endpoint.getServiceName(),endpoint.getWsdlPort(),container,binding,primaryWsdl,docs,catalogURL);
          String uri=endpoint.getEndpointAddressUri();
          String urlPattern=uri.startsWith("String_Node_Str") ? uri : "String_Node_Str" + uri;
          if (adapterList == null) {
            adapterList=new ServletAdapterList();
          }
          adapter=adapterList.createAdapter(endpoint.getName(),urlPattern,wsep);
          handlersConfigured=true;
        }
 catch (        Throwable t) {
          logger.log(Level.SEVERE,"String_Node_Str" + endpoint.getName() + "String_Node_Str",t);
          adapter=null;
        }
      }
    }
  }
synchronized (this) {
    addWSContextInfo(wsCtxt);
    if (inv != null) {
      EJBInvocation ejbInv=(EJBInvocation)inv;
      ejbInv.setWebServiceContext(wsCtxt);
    }
  }
  adapterInvInfo.setAdapter(adapter);
  return adapterInvInfo;
}