Source:
public Repo<Master> call(long tid, Master environment) throws Exception { VolumeManager fs = environment.getFileSystem(); UniqueNameAllocator namer = environment.getContext().getUniqueNameAllocator(); for (ImportedTableInfo.DirectoryMapping dm : tableInfo.directories) { Path path = new Path(dm.importDir, "mappings.txt"); BufferedWriter mappingsWriter = null; try { fs.mkdirs(new Path(dm.importDir)); FileStatus[] files = fs.listStatus(new Path(dm.exportDir)); mappingsWriter = new BufferedWriter(new OutputStreamWriter(fs.create(path), UTF_8)); for (FileStatus fileStatus : files) { String fileName = fileStatus.getPath().getName(); log.info("filename " + fileStatus.getPath()); String[] sa = fileName.split("\\."); String extension = ""; if (sa.length > 1) { extension = sa[sa.length - 1]; if (!FileOperations.getValidExtensions().contains(extension)) { continue; } } else { extension = Constants.MAPFILE_EXTENSION; } String newName = "I" + namer.getNextName() + "." + extension; mappingsWriter.append(fileName); mappingsWriter.append(':'); mappingsWriter.append(newName); mappingsWriter.newLine(); } mappingsWriter.close(); mappingsWriter = null; } catch (IOException ioe) { log.warn("{}", ioe.getMessage(), ioe); throw new AcceptableThriftTableOperationException(tableInfo.tableId.canonical(), tableInfo.tableName, TableOperation.IMPORT, TableOperationExceptionType.OTHER, "Error writing mapping file " + path + " " + ioe.getMessage()); } finally { if (mappingsWriter != null) try { mappingsWriter.close(); } catch (IOException ioe) { log.warn("Failed to close " + path, ioe); } } } return new PopulateMetadataTable(tableInfo); }

Target:
public Repo<Master> call(long tid, Master environment) throws Exception { for (ImportedTableInfo.DirectoryMapping dm : tableInfo.directories) { Path path = new Path(dm.importDir, "mappings.txt"); BufferedWriter mappingsWriter = null; try { VolumeManager fs = environment.getVolumeManager(); fs.mkdirs(new Path(dm.importDir)); FileStatus[] files = fs.listStatus(new Path(dm.exportDir)); UniqueNameAllocator namer = environment.getContext().getUniqueNameAllocator(); mappingsWriter = new BufferedWriter(new OutputStreamWriter(fs.create(path), UTF_8)); for (FileStatus fileStatus : files) { String fileName = fileStatus.getPath().getName(); log.info("filename " + fileStatus.getPath()); String[] sa = fileName.split("\\."); String extension = ""; if (sa.length > 1) { extension = sa[sa.length - 1]; if (!FileOperations.getValidExtensions().contains(extension)) { continue; } } else { extension = Constants.MAPFILE_EXTENSION; } String newName = "I" + namer.getNextName() + "." + extension; mappingsWriter.append(fileName); mappingsWriter.append(':'); mappingsWriter.append(newName); mappingsWriter.newLine(); } mappingsWriter.close(); mappingsWriter = null; } catch (IOException ioe) { log.warn("{}", ioe.getMessage(), ioe); throw new AcceptableThriftTableOperationException(tableInfo.tableId.canonical(), tableInfo.tableName, TableOperation.IMPORT, TableOperationExceptionType.OTHER, "Error writing mapping file " + path + " " + ioe.getMessage()); } finally { if (mappingsWriter != null) try { mappingsWriter.close(); } catch (IOException ioe) { log.warn("Failed to close " + path, ioe); } } } return new PopulateMetadataTable(tableInfo); }