eclipse-ee4j / eclipse-ee4j/jersey

LoggingFilter always truncates if message size is larger than 4096

Open
#3,041 9 comments 0 reactions 0 assignees View on GitHub
Component: core logging Priority: Minor Type: Bug
Dominant language
Java
Stars
730
Forks
382
PR merge metrics
No merged PRs in 30d

Description

Related code in LoggingFilter.java:

```
private InputStream logInboundEntity(final StringBuilder b, InputStream stream, final Charset charset) throws IOException {
if (!stream.markSupported())

{ stream = new BufferedInputStream(stream); }

stream.mark(maxEntitySize + 1);
final byte[] entity = new byte[maxEntitySize + 1];
final int entitySize = stream.read(entity);
b.append(new String(entity, 0, Math.min(entitySize, maxEntitySize), charset));
if (entitySize > maxEntitySize)

{ b.append("...more..."); }

b.append('\n');
stream.reset();
return stream;
}
```
The stream.read(entity) reads maximum of 8192 bytes in one go (entitySize will be maximum 4096) even if the entity array size is much more larger, therefore the logging output is truncated.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.