Source:
<code>public List<StreamsDatum> process(StreamsDatum entry) { List<StreamsDatum> result = Lists.newArrayList(); String json; ObjectNode node; if (entry.getDocument() instanceof String) { json = (String) entry.getDocument(); try { node = (ObjectNode) mapper.readTree(json); } catch (IOException e) { e.printStackTrace(); return null; } <START> } else { <END> node = (ObjectNode) entry.getDocument(); try { json = mapper.writeValueAsString(node); } catch (JsonProcessingException e) { LOGGER.warn("Invalid datum: ", node); return null; } } StringBuilder percolateRequestJson = new StringBuilder(); percolateRequestJson.append("{ \"doc\": "); percolateRequestJson.append(json); percolateRequestJson.append("}"); PercolateRequestBuilder request; PercolateResponse response; try { LOGGER.trace("Percolate request json: {}", percolateRequestJson.toString()); request = manager.getClient().preparePercolate().setIndices(config.getIndex()).setDocumentType(config.getType()).setSource(percolateRequestJson.toString()); LOGGER.trace("Percolate request: {}", mapper.writeValueAsString(request.request())); response = request.execute().actionGet(); LOGGER.trace("Percolate response: matches", response.getMatches().length); } catch (Exception e) { LOGGER.warn("Percolate exception: {}", e.getMessage()); return null; } ArrayNode tagArray = JsonNodeFactory.instance.arrayNode(); Iterator<PercolateResponse.Match> matchIterator = response.iterator(); while(matchIterator.hasNext()) { tagArray.add(matchIterator.next().getId().string()); } LOGGER.trace("Percolate matches: {}", tagArray); Activity activity = mapper.convertValue(node, Activity.class); appendMatches(tagArray, activity); entry.setDocument(activity); result.add(entry); return result; }</code><technical_language>if check types, check this is ObjectNode. Longer term, need a for processors describe types support</technical_language>

Target:
public List<StreamsDatum> process(StreamsDatum entry) { List<StreamsDatum> result = Lists.newArrayList(); String json; ObjectNode node; if (entry.getDocument() instanceof String) { json = (String) entry.getDocument(); try { node = (ObjectNode) mapper.readTree(json); } catch (IOException e) { e.printStackTrace(); return null; } } else if (entry.getDocument() instanceof ObjectNode) { node = (ObjectNode) entry.getDocument(); try { json = mapper.writeValueAsString(node); } catch (JsonProcessingException e) { LOGGER.warn("Invalid datum: ", node); return null; } } else { LOGGER.warn("Incompatible document type: ", entry.getDocument().getClass()); return null; } StringBuilder percolateRequestJson = new StringBuilder(); percolateRequestJson.append("{ \"doc\": "); percolateRequestJson.append(json); percolateRequestJson.append("}"); PercolateRequestBuilder request; PercolateResponse response; try { LOGGER.trace("Percolate request json: {}", percolateRequestJson.toString()); request = manager.getClient().preparePercolate().setIndices(config.getIndex()).setDocumentType(config.getType()).setSource(percolateRequestJson.toString()); LOGGER.trace("Percolate request: {}", mapper.writeValueAsString(request.request())); response = request.execute().actionGet(); LOGGER.trace("Percolate response: matches", response.getMatches().length); } catch (Exception e) { LOGGER.warn("Percolate exception: {}", e.getMessage()); return null; } ArrayNode tagArray = JsonNodeFactory.instance.arrayNode(); Iterator<PercolateResponse.Match> matchIterator = response.iterator(); while(matchIterator.hasNext()) { tagArray.add(matchIterator.next().getId().string()); } LOGGER.trace("Percolate matches: {}", tagArray); Activity activity = mapper.convertValue(node, Activity.class); appendMatches(tagArray, activity); entry.setDocument(activity); result.add(entry); return result; }