Skip to content
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

Malformed lines bug #47

Merged
merged 7 commits into from
Sep 3, 2019
Merged

Malformed lines bug #47

merged 7 commits into from
Sep 3, 2019

Conversation

idohalevi
Copy link
Contributor

@idohalevi idohalevi commented Aug 21, 2019

Fixing bug:
When we receive a bad request from the listener we try to send the bulk again. This creates duplicate logs in case we have valid JSON objects in that bulk that the listener processed properly(resend of valid json too).

@asafm asafm self-assigned this Aug 22, 2019
@@ -86,8 +87,10 @@ public void handle(String target, Request baseRequest, HttpServletRequest reques
logger.debug("got log: {} ", line);
});
logger.debug("Total number of logRequests {} ({})", logRequests.size(), logRequests);

// Tell Jetty we are ok, and it should return 200
} catch (IllegalArgumentException e) {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't this be a Jackson exception here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why? I'm catching exceptions from LogRequest function

@@ -110,6 +110,31 @@ public void simpleAppending() throws Exception {
mockListener.assertLogReceivedIs(message2, token, type, loggerName, LOGLEVEL);
}

@Test
public void malformedBulk() throws Exception {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This test failed before the change and now it passes?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's a new test

@idohalevi
Copy link
Contributor Author

@asafm
Done with the changes

}
else if (responseCode == HttpURLConnection.HTTP_OK) {
reporter.info("Successfully sent bulk to logz.io, size: " + payload.length);
} else {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

perhaps retry only if response code == 5xx?

Copy link
Contributor

@yyyogev yyyogev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Legit

@idohalevi idohalevi merged commit 5e2f09f into master Sep 3, 2019
@idohalevi idohalevi deleted the malformed-lines branch September 3, 2019 09:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants