Source:
<code>public Map<String, String> addFWNameMap( @Auth final AccessToken accessToken, @PathParam("fw_version") final String fwVersion) { ObjectListing objectListing; final ListObjectsRequest listObjectsRequest = new ListObjectsRequest() .withBucketName("hello-firmware").withPrefix("sense/" + fwVersion); final List<String> keys = Lists.newArrayList(); int i = 0; do { objectListing = s3Client.listObjects(listObjectsRequest); for (S3ObjectSummary objectSummary : objectListing.getObjectSummaries()) { if(objectSummary.getKey().contains("build_info.txt")) { keys.add(objectSummary.getKey()); } } listObjectsRequest.setMarker(objectListing.getNextMarker()); i++; } while (objectListing.isTruncated() && i < 5); for(final String key: keys) { final String humanVersion = key.split("/")[1]; if (!humanVersion.equals(fwVersion)) { continue; } final S3Object s3Object = s3Client.getObject("hello-firmware", key); <START> final S3ObjectInputStream s3ObjectInputStream = s3Object.getObjectContent(); <END> String text; try { text = CharStreams.toString(new InputStreamReader(s3ObjectInputStream, Charsets.UTF_8)); } catch (IOException e) { LOGGER.error("error=build_info_read_failure key={} message={}", key, e.getMessage()); continue; } final Iterable<String> strings = Splitter.on("\n").split(text); final String firstLine = strings.iterator().next(); final String[] parts = firstLine.split(":"); final String hash = (parts[1].trim().length() < 6) ? Integer.toHexString(Integer.parseInt(parts[1].trim())) : parts[1].trim(); firmwareVersionMappingDAO.put(hash, humanVersion); LOGGER.info("action=put_fw_map hash={} key={}", hash, key); final Map<String, String> results = Maps.newHashMap(); results.put("fw_hash", hash); return results; } return Collections.EMPTY_MAP; }</code><technical_language>closing this</technical_language>

Target:
public Map<String, String> addFWNameMap( @Auth final AccessToken accessToken, @PathParam("fw_version") final String fwVersion) { ObjectListing objectListing; final ListObjectsRequest listObjectsRequest = new ListObjectsRequest() .withBucketName("hello-firmware").withPrefix("sense/" + fwVersion); final List<String> keys = Lists.newArrayList(); int i = 0; do { objectListing = s3Client.listObjects(listObjectsRequest); for (S3ObjectSummary objectSummary : objectListing.getObjectSummaries()) { if(objectSummary.getKey().contains("build_info.txt")) { keys.add(objectSummary.getKey()); } } listObjectsRequest.setMarker(objectListing.getNextMarker()); i++; } while (objectListing.isTruncated() && i < 5); for(final String key: keys) { final String humanVersion = key.split("/")[1]; if (!humanVersion.equals(fwVersion)) { continue; } final S3Object s3Object = s3Client.getObject("hello-firmware", key); String text; try(final S3ObjectInputStream s3ObjectInputStream = s3Object.getObjectContent()) { text = CharStreams.toString(new InputStreamReader(s3ObjectInputStream, Charsets.UTF_8)); } catch (IOException e) { LOGGER.error("error=build_info_read_failure key={} message={}", key, e.getMessage()); continue; } final Iterable<String> strings = Splitter.on("\n").split(text); final String firstLine = strings.iterator().next(); final String[] parts = firstLine.split(":"); final String hash = (parts[1].trim().length() < 6) ? Integer.toHexString(Integer.parseInt(parts[1].trim())) : parts[1].trim(); firmwareVersionMappingDAO.put(hash, humanVersion); LOGGER.info("action=put_fw_map hash={} key={}", hash, key); return ImmutableMap.of("fw_hash", hash); } return Collections.EMPTY_MAP; }