private List<Object> readModels(Exchange exchange, InputStream stream) {
List<Object> results = new ArrayList<Object>();
BufferedReader streamReader = IOHelper.buffered(new InputStreamReader(stream, encoding));
BeanReader in = factory.createReader(streamName, streamReader);
try {
registerErrorHandler(in);
Object readObject;
while ((readObject = in.read()) != null) {
if (readObject instanceof BeanIOHeader) {
exchange.getOut().getHeaders().putAll(((BeanIOHeader) readObject).getHeaders());
}
results.add(readObject);
}
} finally {
in.close();
}
return results;
}