lttng: fix validation of ust ctf2 trace#373
lttng: fix validation of ust ctf2 trace#373arfio merged 1 commit intoeclipse-tracecompass:masterfrom
Conversation
Signed-off-by: Arnaud Fiorini <fiorini.arnaud@gmail.com>
📝 WalkthroughWalkthroughThe domain validation in LttngUstTrace.validate was modified to accept both Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches
🧪 Generate unit tests (beta)
Tip Issue Planner is now in beta. Read the docs and try it out! Share your feedback on Discord. Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
lttng/org.eclipse.tracecompass.lttng2.ust.core/src/org/eclipse/tracecompass/lttng2/ust/core/trace/LttngUstTrace.java (1)
193-193: LGTM — the Boolean guard is correct; one optional readability nit.The condition correctly admits the unquoted
"ust"(CTF2) alongside the legacy quoted"\"ust\""(CTF1) while still rejectingnulland any other value. No logic issues.Optional: extracting the two accepted values into named constants (or a small
Set) would make the intent self-documenting and make future format additions a one-line change:♻️ Optional refactor — named constant + Set lookup
+ private static final Set<String> VALID_DOMAINS = ImmutableSet.of("ust", "\"ust\""); //$NON-NLS-1$ //$NON-NLS-2$ + `@Override` public IStatus validate(final IProject project, final String path) { ... - if (domain == null || !(domain.equals("ust") || domain.equals("\"ust\""))) { //$NON-NLS-1$ //$NON-NLS-2$ + if (domain == null || !VALID_DOMAINS.contains(domain)) {🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@lttng/org.eclipse.tracecompass.lttng2.ust.core/src/org/eclipse/tracecompass/lttng2/ust/core/trace/LttngUstTrace.java` at line 193, The null/equals check for domain in LttngUstTrace currently hardcodes accepted values ("ust" and "\"ust\"") inline; refactor by introducing named constants (e.g., UST_UNQUOTED and UST_QUOTED) or a small immutable Set of accepted domain strings and replace the inline condition (the if that checks domain == null || !(domain.equals("ust") || domain.equals("\"ust\""))) with a clearer lookup (null-check plus contains on the Set or equals against the constants) to improve readability and make future additions trivial.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In
`@lttng/org.eclipse.tracecompass.lttng2.ust.core/src/org/eclipse/tracecompass/lttng2/ust/core/trace/LttngUstTrace.java`:
- Line 193: The null/equals check for domain in LttngUstTrace currently
hardcodes accepted values ("ust" and "\"ust\"") inline; refactor by introducing
named constants (e.g., UST_UNQUOTED and UST_QUOTED) or a small immutable Set of
accepted domain strings and replace the inline condition (the if that checks
domain == null || !(domain.equals("ust") || domain.equals("\"ust\""))) with a
clearer lookup (null-check plus contains on the Set or equals against the
constants) to improve readability and make future additions trivial.
What it does
It makes LTTng UST ctf2 traces detectable by Trace Compass by modifying the validate function.
How to test
Open a CTF2 trace generated from LTTng 2.15 with a program instrumented by LTTng-UST
Review checklist
Summary by CodeRabbit