Source:
<code>public ImmutableList<TrackerMotion> getTrackerMotionForDate(long accountId, final String targetDateString) { final HashMap<String, AttributeValue> key = new HashMap<String, AttributeValue>(); key.put(ACCOUNT_ID_ATTRIBUTE_NAME, new AttributeValue().withN(String.valueOf(accountId))); key.put(TARGET_DATE_ATTRIBUTE_NAME, new AttributeValue().withS(targetDateString)); final GetItemRequest getItemRequest = new GetItemRequest() .withTableName(this.tableName) .withKey(key); final GetItemResult getItemResult = dynamoDBClient.getItem(getItemRequest); if(getItemResult.getItem() == null || !getItemResult.getItem().containsKey(DATA_BLOB_ATTRIBUTE_NAME)) { return ImmutableList.copyOf(new TrackerMotion[0]); } final String jasonCompactMotionData = getItemResult.getItem().get(DATA_BLOB_ATTRIBUTE_NAME).getS(); ObjectMapper mapper = new ObjectMapper(); try { final List<AmplitudeDataCompact> data = mapper.readValue(jasonCompactMotionData, new TypeReference<List<AmplitudeDataCompact>>(){}); TrackerMotion[] resultData = new TrackerMotion[data.size()]; int index = 0; for(final AmplitudeDataCompact datum:data){ TrackerMotion trackerMotion = new TrackerMotion( -1, accountId, "", datum.timestamp, datum.amplitude, datum.offsetMillis); resultData[index] = trackerMotion; index++; } return ImmutableList.copyOf(resultData); } catch (IOException e) { e.printStackTrace(); LOGGER.warn("{}", e.getStackTrace()); } <START> return ImmutableList.copyOf(new TrackerMotion[0]); <END> }</code><technical_language>return Collections.EMPTY_LIST instead</technical_language>

Target:
private ImmutableList<TrackerMotion> getTrackerMotionForDate(long accountId, final String targetDateString) { final HashMap<String, AttributeValue> key = new HashMap<String, AttributeValue>(); key.put(ACCOUNT_ID_ATTRIBUTE_NAME, new AttributeValue().withN(String.valueOf(accountId))); key.put(TARGET_DATE_ATTRIBUTE_NAME, new AttributeValue().withS(targetDateString)); final GetItemRequest getItemRequest = new GetItemRequest() .withTableName(this.tableName) .withKey(key); GetItemResult getItemResult = null; try { getItemResult = dynamoDBClient.getItem(getItemRequest); }catch (AmazonServiceException ase){ LOGGER.error("Amazon service exception {}", ase.getMessage()); }finally { if (getItemResult.getItem() == null || !getItemResult.getItem().containsKey(DATA_BLOB_ATTRIBUTE_NAME)) { return ImmutableList.copyOf(Collections.<TrackerMotion>emptyList()); } } final ByteBuffer byteBuffer = getItemResult.getItem().get(DATA_BLOB_ATTRIBUTE_NAME).getB(); try { final InputProtos.TrackerDataBatch trackerDataBatch = InputProtos.TrackerDataBatch.parseFrom(byteBuffer.array()); final List<InputProtos.TrackerDataBatch.TrackerData> dataList = trackerDataBatch.getSamplesList(); LinkedList<TrackerMotion> resultData = new LinkedList<TrackerMotion>(); for(final InputProtos.TrackerDataBatch.TrackerData datum:dataList){ TrackerMotion trackerMotion = new TrackerMotion( -1, accountId, "", datum.getTimestamp(), datum.getSvmNoGravity(), datum.getOffsetMillis()); resultData.add(trackerMotion); } return ImmutableList.copyOf(resultData); } catch (IOException e) { LOGGER.error("{}", e.getStackTrace()); } return ImmutableList.copyOf(Collections.<TrackerMotion>emptyList()); }