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

replace guava functionality with equivalent JDK or custom features #319

Merged

Conversation

richardstartin
Copy link
Contributor

The motivation here is to reduce the deployment size by shedding a 2.7MB dependency which isn't extensively used.

…ich allows a large (2.7MB) dependency to be dropped from size-sensitive deployments
Copy link
Member

@olivielpeau olivielpeau left a comment

Choose a reason for hiding this comment

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

LGTM since the CI passes, but haven't read the code changes in details. Looking at the project history the guava dep was added very early to take advantage of a few specific types (6c89538), should be no harm replacing them with custom implementations.

Would definitely like @truthbk's review on this though, so leaving approval up to him.

@olivielpeau olivielpeau requested a review from truthbk September 2, 2020 10:58
@richardstartin
Copy link
Contributor Author

richardstartin commented Sep 2, 2020

The failing test (testServiceCheckWarning(org.datadog.jmxfetch.TestServiceChecks)) on Oracle JDK8 (see CI output) fails for me locally on master - is this a known flaky test?

@richardstartin
Copy link
Contributor Author

There are some follow up PRs which make sense if they're all merged in the order of creation. If any of them are problematic the commits can be dropped and the PRs can be merged in isolation.

import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.*;
Copy link
Contributor

Choose a reason for hiding this comment

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

minor: afaik the styleguide says don't use wildcard imports?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

doesn't apply to test

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Actually this is up to @truthbk - wildcard imports (and some unused imports) are common in the test folder.

Copy link
Member

Choose a reason for hiding this comment

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

Feel free to ignore but @mcculls is right, I know we already have a bunch of wildcard imports in the test package, but let's try to avoid adding more, if possible.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ok will address this

@@ -0,0 +1,47 @@
package org.datadog.jmxfetch.util;

public final class ByteArraySearcher {
Copy link
Contributor

Choose a reason for hiding this comment

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

interesting matching technique - I think it would be worth adding a small description of the algorithm used 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.

This is the literal version of the bitap algorithm which is the only one I know which takes less space to write than the naive quadratic algorithm used in Guava.

Copy link
Member

@truthbk truthbk left a comment

Choose a reason for hiding this comment

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

Just the wildcard to fix if you have the time, otherwise this looks great, and is very welcome!

Thank you! 🙇

}
}
if (count.get() <= max) {
// may log a little too often if there are races
Copy link
Member

Choose a reason for hiding this comment

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

I think this is fine, not a huge concern.

import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.*;
Copy link
Member

Choose a reason for hiding this comment

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

Feel free to ignore but @mcculls is right, I know we already have a bunch of wildcard imports in the test package, but let's try to avoid adding more, if possible.

@richardstartin richardstartin merged commit dd5137e into DataDog:master Sep 3, 2020
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.

5 participants