Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2016, 2021 Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2016, 2022 Oracle and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0, which is available at
Expand Down Expand Up @@ -305,7 +305,7 @@ public void write(byte[] ba, int off, int len) throws IOException {
if ((off | len | ba.length - (len + off) | off + len) < 0) {
throw new IndexOutOfBoundsException();
}
if ((baos.size() + len) <= maxEntitySize) {
if (baos.size() <= maxEntitySize) {
baos.write(ba, off, len);
}
out.write(ba, off, len);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2013, 2021 Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2013, 2022 Oracle and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0, which is available at
Expand Down Expand Up @@ -284,6 +284,23 @@ public void testLoggingFeatureBuilderProperty() {
assertThat(record.getMessage(), containsString(SEPARATOR));
}

@Test
public void testLoggingFeatureMaxEntitySize() {
final Response response = target("/text")
.register(LoggingFeature.class)
.property(LoggingFeature.LOGGING_FEATURE_LOGGER_NAME, LOGGER_NAME)
.property(LoggingFeature.LOGGING_FEATURE_MAX_ENTITY_SIZE, 1)
.request()
.post(Entity.text(ENTITY));

// Correct response status.
assertThat(response.getStatus(), is(Response.Status.OK.getStatusCode()));
// Check logs for trimmedEntity.
String trimmedEntity = ENTITY.charAt(0) + "...more...";
List<LogRecord> logRecords = getLoggedRecords();
assertThat(getLoggingFilterRequestLogRecord(logRecords).getMessage(), containsString(trimmedEntity));
assertThat(getLoggingFilterResponseLogRecord(logRecords).getMessage(), containsString(trimmedEntity));
}
}

/**
Expand Down