@Test public void testLogInboundEntityWhenMarkSupportedAndContentLongerThenMax() throws IOException { int length = LoggingStream.MAX_CONTENT_LENGTH * 2; String generatedString = RandomStringUtils.random(length, true, true); ByteArrayInputStream bais = new ByteArrayInputStream(generatedString.getBytes()); StringBuilder sb = new StringBuilder(); InputStream actual = underTest.logInboundEntity(sb, bais, Charset.defaultCharset()); Assertions.assertEquals(bais, actual); Assertions.assertTrue(sb.toString().endsWith("...more...\n")); }
public InputStream logInboundEntity(StringBuilder content, InputStream stream, Charset charset) throws IOException { if (contentLogging) { if (!stream.markSupported()) { stream = new BufferedInputStream(stream, MAX_CONTENT_LENGTH + 1); } stream.mark(MAX_CONTENT_LENGTH + 1); byte[] entity = new byte[MAX_CONTENT_LENGTH + 1]; int entitySize = IOUtils.read(stream, entity); if (entitySize != -1) { content.append(new String(entity, 0, Math.min(entitySize, MAX_CONTENT_LENGTH), charset)); if (entitySize > MAX_CONTENT_LENGTH) { content.append("...more..."); } } content.append('\n'); stream.reset(); } return stream; }
StructuredEventFilterUtil { public InputStream logInboundEntity(StringBuilder content, InputStream stream, Charset charset) throws IOException { if (contentLogging) { if (!stream.markSupported()) { stream = new BufferedInputStream(stream, MAX_CONTENT_LENGTH + 1); } stream.mark(MAX_CONTENT_LENGTH + 1); byte[] entity = new byte[MAX_CONTENT_LENGTH + 1]; int entitySize = IOUtils.read(stream, entity); if (entitySize != -1) { content.append(new String(entity, 0, Math.min(entitySize, MAX_CONTENT_LENGTH), charset)); if (entitySize > MAX_CONTENT_LENGTH) { content.append("...more..."); } } content.append('\n'); stream.reset(); } return stream; } }
StructuredEventFilterUtil { public InputStream logInboundEntity(StringBuilder content, InputStream stream, Charset charset) throws IOException { if (contentLogging) { if (!stream.markSupported()) { stream = new BufferedInputStream(stream, MAX_CONTENT_LENGTH + 1); } stream.mark(MAX_CONTENT_LENGTH + 1); byte[] entity = new byte[MAX_CONTENT_LENGTH + 1]; int entitySize = IOUtils.read(stream, entity); if (entitySize != -1) { content.append(new String(entity, 0, Math.min(entitySize, MAX_CONTENT_LENGTH), charset)); if (entitySize > MAX_CONTENT_LENGTH) { content.append("...more..."); } } content.append('\n'); stream.reset(); } return stream; }  }
StructuredEventFilterUtil { public InputStream logInboundEntity(StringBuilder content, InputStream stream, Charset charset) throws IOException { if (contentLogging) { if (!stream.markSupported()) { stream = new BufferedInputStream(stream, MAX_CONTENT_LENGTH + 1); } stream.mark(MAX_CONTENT_LENGTH + 1); byte[] entity = new byte[MAX_CONTENT_LENGTH + 1]; int entitySize = IOUtils.read(stream, entity); if (entitySize != -1) { content.append(new String(entity, 0, Math.min(entitySize, MAX_CONTENT_LENGTH), charset)); if (entitySize > MAX_CONTENT_LENGTH) { content.append("...more..."); } } content.append('\n'); stream.reset(); } return stream; }  InputStream logInboundEntity(StringBuilder content, InputStream stream, Charset charset); void sendStructuredEvent(RestRequestDetails restRequest, RestResponseDetails restResponse, Map<String, String> restParams, Long requestTime,
            String responseBody); }
StructuredEventFilterUtil { public InputStream logInboundEntity(StringBuilder content, InputStream stream, Charset charset) throws IOException { if (contentLogging) { if (!stream.markSupported()) { stream = new BufferedInputStream(stream, MAX_CONTENT_LENGTH + 1); } stream.mark(MAX_CONTENT_LENGTH + 1); byte[] entity = new byte[MAX_CONTENT_LENGTH + 1]; int entitySize = IOUtils.read(stream, entity); if (entitySize != -1) { content.append(new String(entity, 0, Math.min(entitySize, MAX_CONTENT_LENGTH), charset)); if (entitySize > MAX_CONTENT_LENGTH) { content.append("...more..."); } } content.append('\n'); stream.reset(); } return stream; }  InputStream logInboundEntity(StringBuilder content, InputStream stream, Charset charset); void sendStructuredEvent(RestRequestDetails restRequest, RestResponseDetails restResponse, Map<String, String> restParams, Long requestTime,
            String responseBody);  }