Program: 18330
Project: 18330
Buggy source:
public void handleEvent(Event event){
  EventContext ctx=event.getContext();
  if (!(ctx instanceof DocumentEventContext)) {
    return;
  }
  CoreSession session=ctx.getCoreSession();
  DocumentModel doc=((DocumentEventContext)ctx).getSourceDocument();
  if (doc == null) {
    return;
  }
  String type=doc.getType();
  if (!type.equals(DOCTYPE)) {
    return;
  }
  try {
    String title=(String)doc.getProperty("String_Node_Str","String_Node_Str");
    String url=(String)doc.getProperty(SCHEMA,PROP_URL);
    String fileUrl=(String)doc.getProperty(SCHEMA_COMMON,PROP_FILEURL);
    if (fileUrl != null) {
      Blob blob=new HttpFile(fileUrl).download().getBlob();
      if (blob == null) {
        return;
      }
      File tmpFile=File.createTempFile(doc.getId(),null);
      blob.transferTo(tmpFile);
      try {
        WSDLReader reader=WSDLFactory.newInstance().newWSDLReader();
        Description desc=reader.read(tmpFile.toURI().toURL());
        org.ow2.easywsdl.wsdl.api.Service firstService=(org.ow2.easywsdl.wsdl.api.Service)desc.getServices().get(0);
        Endpoint firstEndpoint=firstService.getEndpoints().get(0);
        url=firstEndpoint.getAddress();
        doc.setProperty(SCHEMA,PROP_URL,PropertyNormalizer.normalizeUrl(url));
        if (title == null || title.isEmpty() || title.equals(url)) {
          doc.setProperty("String_Node_Str","String_Node_Str",firstService.getQName().getLocalPart());
        }
        if (url.contains("String_Node_Str")) {
          doc.setProperty(SCHEMA,PROP_LIGHTURL,"String_Node_Str");
        }
        DocumentModel apiModel=session.getDocument(doc.getParentRef());
        String protocol=((Binding)((Endpoint)firstService.getEndpoints().get(0)).getBinding()).getTransportProtocol();
        String storedProtocol=(String)apiModel.getProperty(ServiceAPI.SCHEMA,ServiceAPI.PROP_PROTOCOLS);
        if (storedProtocol == null || !storedProtocol.contains(protocol)) {
          if (storedProtocol == null || storedProtocol.isEmpty()) {
            apiModel.setProperty(ServiceAPI.SCHEMA,ServiceAPI.PROP_PROTOCOLS,protocol);
          }
 else {
            apiModel.setProperty(ServiceAPI.SCHEMA,ServiceAPI.PROP_PROTOCOLS,storedProtocol + "String_Node_Str" + protocol);
          }
        }
        DocumentModel appliImplModel=session.getDocument(apiModel.getParentRef());
        String existingServer=(String)appliImplModel.getProperty(AppliImpl.SCHEMA,AppliImpl.PROP_SERVER);
        String newServer=InetAddress.getByName(new URL(firstEndpoint.getAddress()).getHost()).getHostAddress();
        if (existingServer == null || !newServer.equals(existingServer)) {
          appliImplModel.setProperty(AppliImpl.SCHEMA,AppliImpl.PROP_SERVER,newServer);
        }
        try {
          String provider=new URL(((Endpoint)firstService.getEndpoints().get(0)).getAddress()).getAuthority();
          String existingProvider=(String)appliImplModel.getProperty(AppliImpl.SCHEMA,AppliImpl.PROP_PROVIDER);
          if (existingProvider == null || !provider.equals(existingProvider)) {
            appliImplModel.setProperty(AppliImpl.SCHEMA,AppliImpl.PROP_PROVIDER,provider);
          }
        }
 catch (        Exception e) {
        }
        session.saveDocument(apiModel);
        session.saveDocument(appliImplModel);
      }
 catch (      Exception e) {
        log.error("String_Node_Str",e);
      }
 finally {
        tmpFile.delete();
      }
    }
    if (title == null || title.isEmpty() || title.equals(url)) {
      doc.setProperty("String_Node_Str","String_Node_Str",url.substring(title.lastIndexOf('/') + 1));
    }
    session.save();
  }
 catch (  Exception e) {
    log.error("String_Node_Str",e);
  }
}

Fixed version (ground truth):
public void handleEvent(Event event){
  EventContext ctx=event.getContext();
  if (!(ctx instanceof DocumentEventContext)) {
    return;
  }
  CoreSession session=ctx.getCoreSession();
  DocumentModel doc=((DocumentEventContext)ctx).getSourceDocument();
  if (doc == null) {
    return;
  }
  String type=doc.getType();
  if (!type.equals(DOCTYPE)) {
    return;
  }
  try {
    String title=(String)doc.getProperty("String_Node_Str","String_Node_Str");
    String url=(String)doc.getProperty(SCHEMA,PROP_URL);
    String fileUrl=(String)doc.getProperty(SCHEMA_COMMON,PROP_FILEURL);
    if (fileUrl != null) {
      Blob blob=new HttpFile(fileUrl).download().getBlob();
      if (blob == null) {
        return;
      }
      File tmpFile=File.createTempFile(doc.getId(),null);
      blob.transferTo(tmpFile);
      try {
        WSDLReader reader=WSDLFactory.newInstance().newWSDLReader();
        Description desc=reader.read(tmpFile.toURI().toURL());
        org.ow2.easywsdl.wsdl.api.Service firstService=(org.ow2.easywsdl.wsdl.api.Service)desc.getServices().get(0);
        Endpoint firstEndpoint=firstService.getEndpoints().get(0);
        url=firstEndpoint.getAddress();
        doc.setProperty(SCHEMA,PROP_URL,PropertyNormalizer.normalizeUrl(url));
        DocumentService docService=Framework.getService(DocumentService.class);
        DocumentModel existingServiceModel=docService.findService(session,url);
        if (existingServiceModel != null && !existingServiceModel.getRef().equals(doc.getRef())) {
          docService.mergeDocument(session,existingServiceModel,doc,false);
        }
        if (title == null || title.isEmpty() || title.equals(url)) {
          doc.setProperty("String_Node_Str","String_Node_Str",firstService.getQName().getLocalPart());
        }
        if (url.contains("String_Node_Str")) {
          doc.setProperty(SCHEMA,PROP_LIGHTURL,"String_Node_Str");
        }
        DocumentModel apiModel=session.getDocument(doc.getParentRef());
        String protocol=((Binding)((Endpoint)firstService.getEndpoints().get(0)).getBinding()).getTransportProtocol();
        String storedProtocol=(String)apiModel.getProperty(ServiceAPI.SCHEMA,ServiceAPI.PROP_PROTOCOLS);
        if (storedProtocol == null || !storedProtocol.contains(protocol)) {
          if (storedProtocol == null || storedProtocol.isEmpty()) {
            apiModel.setProperty(ServiceAPI.SCHEMA,ServiceAPI.PROP_PROTOCOLS,protocol);
          }
 else {
            apiModel.setProperty(ServiceAPI.SCHEMA,ServiceAPI.PROP_PROTOCOLS,storedProtocol + "String_Node_Str" + protocol);
          }
        }
        DocumentModel appliImplModel=session.getDocument(apiModel.getParentRef());
        String existingServer=(String)appliImplModel.getProperty(AppliImpl.SCHEMA,AppliImpl.PROP_SERVER);
        String newServer=InetAddress.getByName(new URL(firstEndpoint.getAddress()).getHost()).getHostAddress();
        if (existingServer == null || !newServer.equals(existingServer)) {
          appliImplModel.setProperty(AppliImpl.SCHEMA,AppliImpl.PROP_SERVER,newServer);
        }
        try {
          String provider=new URL(((Endpoint)firstService.getEndpoints().get(0)).getAddress()).getAuthority();
          String existingProvider=(String)appliImplModel.getProperty(AppliImpl.SCHEMA,AppliImpl.PROP_PROVIDER);
          if (existingProvider == null || !provider.equals(existingProvider)) {
            appliImplModel.setProperty(AppliImpl.SCHEMA,AppliImpl.PROP_PROVIDER,provider);
          }
        }
 catch (        Exception e) {
        }
        session.saveDocument(apiModel);
        session.saveDocument(appliImplModel);
      }
 catch (      Exception e) {
        log.error("String_Node_Str",e);
      }
 finally {
        tmpFile.delete();
      }
    }
    if (title == null || title.isEmpty() || title.equals(url)) {
      doc.setProperty("String_Node_Str","String_Node_Str",url.substring(title.lastIndexOf('/') + 1));
    }
    session.save();
  }
 catch (  Exception e) {
    log.error("String_Node_Str",e);
  }
}