This repository was archived by the owner on Aug 20, 2025. It is now read-only.
METRON-1728: Handle null values in config in Pcap backend more gracefully#1151
Closed
mmiklavc wants to merge 2 commits intoapache:feature/METRON-1554-pcap-query-panelfrom
Closed
METRON-1728: Handle null values in config in Pcap backend more gracefully#1151mmiklavc wants to merge 2 commits intoapache:feature/METRON-1554-pcap-query-panelfrom
mmiklavc wants to merge 2 commits intoapache:feature/METRON-1554-pcap-query-panelfrom
Conversation
justinleet
reviewed
Aug 8, 2018
| long endTime; | ||
| if (configuration.containsKey(PcapOptions.END_TIME_NS.getKey())) { | ||
| endTime = PcapOptions.END_TIME_NS.get(configuration, Long.class); | ||
| endTime = PcapOptions.END_TIME_NS.getOrDefault(configuration, Long.class, System.nanoTime()); |
Contributor
There was a problem hiding this comment.
Nanotime isn't actually current time in nanos or anything objectively meaningful (and can vary by jvm or be negative or whatever). Check out https://docs.oracle.com/javase/7/docs/api/java/lang/System.html#nanoTime()
Particularly,
This method can only be used to measure elapsed time and is not related to any other notion of system or wall-clock time. The value returned represents nanoseconds since some fixed but arbitrary origin time (perhaps in the future, so values may be negative).
I'd just make it System.currentTimeMillis() and adjust, since I don't think there's a clean way to get a real nanos timestamp in Java (at least until 9, maybe)
Contributor
|
+1 by inspection. Thanks for the improvement! |
asfgit
pushed a commit
that referenced
this pull request
Aug 9, 2018
…ully (mmiklavc via mmiklavc) closes #1151
Contributor
Author
|
Closing as merged |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Contributor Comments
https://issues.apache.org/jira/browse/METRON-1728
I modified the ConfigOptions interface to provide the ability to handle default values similar to the Map interface. ie getOrDefault. For PcapJob, I only improved/changed the values we expect to be user-supplied, ie start time, end time, etc., so we don't throw NPE's if a value gets lost in translation. I think we should definitely still add some validation to users via both REST and the UI similar to what is done in PcapCLI.
Note: This PR is an improvement to existing functionality, not a regression fix.
Pull Request Checklist
For all changes:
For code changes:
Have you included steps to reproduce the behavior or problem that is being changed or addressed?
Have you included steps or a guide to how the change may be verified and tested manually?
Have you ensured that the full suite of tests and checks have been executed in the root metron folder via:
Have you written or updated unit tests and or integration tests to verify your changes?
Have you verified the basic functionality of the build by building and running locally with Vagrant full-dev environment or the equivalent?
For documentation related changes:
n/a
Note:
Please ensure that once the PR is submitted, you check travis-ci for build issues and submit an update to your PR as soon as possible.
It is also recommended that travis-ci is set up for your personal repository such that your branches are built there before submitting a pull request.