Program: 18328
Project: 18328
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,PROP_FILEURL);
    if (fileUrl != null) {
      try {
        Blob blob=null;
        try {
          blob=new HttpFile(fileUrl).download().getBlob();
        }
 catch (        IOException e) {
          log.info("String_Node_Str" + fileUrl + "String_Node_Str"+ e.getMessage());
        }
catch (        Exception e) {
          log.info("String_Node_Str" + fileUrl + "String_Node_Str"+ e.getMessage());
        }
        if (blob != null) {
          NotificationService notifService=Framework.getService(NotificationService.class);
          doc.setProperty("String_Node_Str","String_Node_Str",blob);
          doc.setProperty("String_Node_Str","String_Node_Str",notifService.computeServiceTitle(fileUrl) + "String_Node_Str");
          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=PropertyNormalizer.normalizeUrl(firstEndpoint.getAddress());
            doc.setProperty(SCHEMA,PROP_URL,url);
            if (title == null || title.isEmpty() || title.equals(fileUrl)) {
              title=firstService.getQName().getLocalPart();
              doc.setProperty("String_Node_Str","String_Node_Str",title);
            }
            if (doc.getParentRef() != null) {
              DocumentModel apiModel=session.getDocument(doc.getParentRef());
              String storedProtocol=(String)apiModel.getProperty(ServiceAPI.SCHEMA,ServiceAPI.PROP_PROTOCOLS);
              try {
                String protocol=((Binding)((Endpoint)firstService.getEndpoints().get(0)).getBinding()).getTransportProtocol();
                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);
                  }
                }
              }
 catch (              Exception e) {
                log.warn("String_Node_Str" + e.getMessage());
              }
              if (apiModel.getParentRef() != null) {
                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(appliImplModel);
              }
              session.saveDocument(apiModel);
            }
          }
 catch (          Exception e) {
            log.error("String_Node_Str",e);
          }
 finally {
            tmpFile.delete();
          }
        }
      }
 catch (      Exception e) {
        log.error("String_Node_Str",e);
      }
    }
    if (url != null) {
      try {
        doc.setProperty(SCHEMA,PROP_URL,PropertyNormalizer.normalizeUrl(url));
      }
 catch (      MalformedURLException e) {
        log.error("String_Node_Str",e);
      }
      if (url.contains("String_Node_Str")) {
        doc.setProperty(SCHEMA,PROP_LIGHTURL,"String_Node_Str");
      }
 else       if (url.contains("String_Node_Str")) {
        doc.setProperty(SCHEMA,PROP_LIGHTURL,"String_Node_Str");
      }
    }
    if (fileUrl != null) {
      doc.setProperty(SCHEMA,PROP_FILEURL,PropertyNormalizer.normalizeUrl(fileUrl));
    }
    session.save();
    try {
      DocumentService docService=Framework.getService(DocumentService.class);
      DocumentModelList existingServiceModels=session.query("String_Node_Str" + url + "String_Node_Str");
      for (      DocumentModel existingServiceModel : existingServiceModels) {
        if (existingServiceModel != null && !existingServiceModel.getRef().equals(doc.getRef())) {
          docService.mergeDocument(session,existingServiceModel,doc,false);
        }
      }
    }
 catch (    Exception e) {
      log.error("String_Node_Str",e);
    }
  }
 catch (  Exception e) {
    log.error(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,PROP_FILEURL);
    if (fileUrl != null) {
      try {
        Blob blob=null;
        try {
          blob=new HttpFile(fileUrl).download().getBlob();
        }
 catch (        IOException e) {
          log.info("String_Node_Str" + fileUrl + "String_Node_Str"+ e.getMessage());
        }
catch (        Exception e) {
          log.info("String_Node_Str" + fileUrl + "String_Node_Str"+ e.getMessage());
        }
        if (blob != null) {
          NotificationService notifService=Framework.getService(NotificationService.class);
          doc.setProperty("String_Node_Str","String_Node_Str",blob);
          doc.setProperty("String_Node_Str","String_Node_Str",notifService.computeServiceTitle(fileUrl) + "String_Node_Str");
          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=PropertyNormalizer.normalizeUrl(firstEndpoint.getAddress());
            doc.setProperty(SCHEMA,PROP_URL,url);
            if (title == null || title.isEmpty() || title.equals(fileUrl)) {
              title=firstService.getQName().getLocalPart();
              doc.setProperty("String_Node_Str","String_Node_Str",title);
            }
            if (doc.getParentRef() != null) {
              DocumentModel apiModel=session.getDocument(doc.getParentRef());
              String storedProtocol=(String)apiModel.getProperty(ServiceAPI.SCHEMA,ServiceAPI.PROP_PROTOCOLS);
              try {
                String protocol=((Binding)((Endpoint)firstService.getEndpoints().get(0)).getBinding()).getTransportProtocol();
                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);
                  }
                }
              }
 catch (              Exception e) {
                log.warn("String_Node_Str" + e.getMessage());
              }
              if (apiModel.getParentRef() != null) {
                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(appliImplModel);
              }
              session.saveDocument(apiModel);
            }
          }
 catch (          Exception e) {
            log.error("String_Node_Str",e);
          }
 finally {
            tmpFile.delete();
          }
        }
      }
 catch (      Exception e) {
        log.error("String_Node_Str",e);
      }
    }
    if (url != null) {
      try {
        doc.setProperty(SCHEMA,PROP_URL,PropertyNormalizer.normalizeUrl(url));
      }
 catch (      MalformedURLException e) {
        log.warn("String_Node_Str",e);
      }
      if (url.contains("String_Node_Str")) {
        doc.setProperty(SCHEMA,PROP_LIGHTURL,"String_Node_Str");
      }
 else       if (url.contains("String_Node_Str")) {
        doc.setProperty(SCHEMA,PROP_LIGHTURL,"String_Node_Str");
      }
    }
    if (fileUrl != null) {
      doc.setProperty(SCHEMA,PROP_FILEURL,PropertyNormalizer.normalizeUrl(fileUrl));
    }
    session.save();
    try {
      DocumentService docService=Framework.getService(DocumentService.class);
      DocumentModelList existingServiceModels=session.query("String_Node_Str" + url + "String_Node_Str");
      for (      DocumentModel existingServiceModel : existingServiceModels) {
        if (existingServiceModel != null && !existingServiceModel.getRef().equals(doc.getRef())) {
          docService.mergeDocument(session,existingServiceModel,doc,false);
        }
      }
    }
 catch (    Exception e) {
      log.error("String_Node_Str",e);
    }
  }
 catch (  Exception e) {
    log.error(e);
  }
}