Program: 178021
Project: 178021
Buggy source:
/** 
 * Publish a Mosaic already in a filesystem readable by GeoServer. <P> Sample cUrl usage:<BR> <TT>curl -u admin:geoserver -XPUT -H 'Content-type: text' -d "file:$ABSPORTDIR" http://$GSIP:$GSPORT/$SERVLET/rest/workspaces/$WORKSPACE/coveragestores/$BAREDIR/external.imagemosaic </TT>
 * @param workspace an existing workspace
 * @param storeName the name of the coverageStore to be created
 * @param mosaicDir the directory where the raster images are located
 * @param coverageEncoder the set of parameters to be set to the coverage (bbox, srs, ...)
 * @param layerEncoder  the set of parameters to be set to the layer (defaultstyle, wmspath, ...)
 * @return true if the operation completed successfully.
 * @throws FileNotFoundException
 */
public RESTCoverageStore publishExternalMosaic(String workspace,String storeName,File mosaicDir,GSCoverageEncoder coverageEncoder,GSLayerEncoder layerEncoder) throws FileNotFoundException {
  RESTCoverageStore store=configureExternaMosaicDatastore(workspace,storeName,mosaicDir);
  if (coverageEncoder == null) {
    if (LOGGER.isDebugEnabled()) {
      LOGGER.debug("String_Node_Str" + workspace + "String_Node_Str"+ storeName);
    }
    coverageEncoder=new GSCoverageEncoder();
  }
  if (layerEncoder == null) {
    if (LOGGER.isDebugEnabled()) {
      LOGGER.debug("String_Node_Str" + workspace + "String_Node_Str"+ storeName);
    }
    layerEncoder=new GSLayerEncoder();
  }
  if (store != null) {
    try {
      GeoServerRESTReader reader=new GeoServerRESTReader(restURL,gsuser,gspass);
      RESTCoverageList covList=reader.getCoverages(store.getWorkspaceName(),storeName);
      if (covList.isEmpty()) {
        LOGGER.error("String_Node_Str" + storeName);
        return null;
      }
      String coverageName=covList.get(0).getName();
      coverageEncoder.setName(FilenameUtils.getBaseName(mosaicDir.getName()));
      configureCoverage(coverageEncoder,workspace,storeName,coverageName);
      configureLayer(workspace,storeName,layerEncoder);
    }
 catch (    Exception e) {
      if (LOGGER.isEnabledFor(Level.WARN))       LOGGER.warn("String_Node_Str" + storeName,e);
      store=null;
    }
  }
  return store;
}

Fixed version (ground truth):
/** 
 * Publish a Mosaic already in a filesystem readable by GeoServer. <P> Sample cUrl usage:<BR> <TT>curl -u admin:geoserver -XPUT -H 'Content-type: text' -d "file:$ABSPORTDIR" http://$GSIP:$GSPORT/$SERVLET/rest/workspaces/$WORKSPACE/coveragestores/$BAREDIR/external.imagemosaic </TT>
 * @param workspace an existing workspace
 * @param storeName the name of the coverageStore to be created
 * @param mosaicDir the directory where the raster images are located
 * @param coverageEncoder the set of parameters to be set to the coverage (bbox, srs, ...)
 * @param layerEncoder the set of parameters to be set to the layer (defaultstyle, wmspath, ...)
 * @return the created RESTCoverageStore
 * @deprecated this is keep only for backward compatibility usecreateExternalMosaic and getCoverageStore separately
 * @throws FileNotFoundException
 */
public RESTCoverageStore publishExternalMosaic(String workspace,String storeName,File mosaicDir,GSCoverageEncoder coverageEncoder,GSLayerEncoder layerEncoder) throws FileNotFoundException {
  if (!createExternalMosaic(workspace,storeName,mosaicDir,coverageEncoder,layerEncoder)) {
    return null;
  }
  GeoServerRESTReader reader;
  try {
    reader=new GeoServerRESTReader(restURL,gsuser,gspass);
  }
 catch (  MalformedURLException e1) {
    LOGGER.warn("String_Node_Str" + storeName,e1);
    return null;
  }
  final RESTCoverageStore store=reader.getCoverageStore(workspace,storeName);
  if (store == null) {
    LOGGER.warn("String_Node_Str" + workspace + "String_Node_Str"+ storeName+ "String_Node_Str");
    return null;
  }
  return store;
}