-
-
Notifications
You must be signed in to change notification settings - Fork 26
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Message lost if exceeding maxStringLength and emptyPropertyExclusionEnabled is true #55
Comments
There is something pretty weird going on when @Test
public void test_maxStringLength_with_emptyPropertyExclusionEnabled() throws JsonProcessingException {
// Create the event template.
ObjectNode eventTemplateRootNode = JSON_NODE_FACTORY.objectNode();
eventTemplateRootNode.put("message", "${json:message}");
String eventTemplate = eventTemplateRootNode.toString();
// Create the layout.
int maxStringLength = 10;
BuiltConfiguration configuration = ConfigurationBuilderFactory.newConfigurationBuilder().build();
LogstashLayout layout = LogstashLayout
.newBuilder()
.setConfiguration(configuration)
.setEventTemplate(eventTemplate)
.setMaxStringLength(maxStringLength)
.setEmptyPropertyExclusionEnabled(false)
.build();
// Create the log event.
SimpleMessage message = new SimpleMessage(Strings.repeat('m', maxStringLength) + 'x');
LogEvent logEvent = Log4jLogEvent
.newBuilder()
.setLoggerName(LogstashLayoutTest.class.getSimpleName())
.setMessage(message)
.build();
// Check the serialized event.
String serializedLogEvent = layout.toSerializable(logEvent);
JsonNode rootNode = OBJECT_MAPPER.readTree(serializedLogEvent);
assertThat(point(rootNode, "message").asText()).isEqualTo(message.getFormattedMessage());
} Here |
@waldeinburg, I have implemented a work around for FasterXML/jackson-core#609 in 634aec3. Would you mind checking if it works for you, please? |
The workaround works, thanks! |
I've just released v1.0.2 including this fix. |
If maxStringLength is exceeded and emptyPropertyExclusionEnabled is true, Jackson UTF8JsonGenerator will throw a JsonGenerationException: "Can not write a string, expecting field name (context: Object)".
The text was updated successfully, but these errors were encountered: