Skip to content

Replace 2x LogUtils by QueryContext#101

Merged
Yury-Fridlyand merged 7 commits intointeg-query-contextfrom
dev-query-context
Aug 11, 2022
Merged

Replace 2x LogUtils by QueryContext#101
Yury-Fridlyand merged 7 commits intointeg-query-contextfrom
dev-query-context

Conversation

@Yury-Fridlyand
Copy link
Copy Markdown

Signed-off-by: Yury Fridlyand yuryf@bitquilltech.com

Description

Remove duplicated classes

Issues Resolved

Check List

  • New functionality includes testing.
    • All tests pass, including unit test, integration test and doctest
  • New functionality has been documented.
    • New functionality has javadoc added
    • New functionality has user manual doc added
  • Commits are signed per the DCO using --signoff

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.

…tils`.

Signed-off-by: Yury Fridlyand <yuryf@bitquilltech.com>
@Yury-Fridlyand Yury-Fridlyand requested a review from a team August 6, 2022 16:22
Signed-off-by: Yury Fridlyand <yuryf@bitquilltech.com>
@codecov
Copy link
Copy Markdown

codecov bot commented Aug 6, 2022

Codecov Report

❗ No coverage uploaded for pull request base (integ-query-context@1df89e3). Click here to learn what that means.
The diff coverage is n/a.

@@                  Coverage Diff                   @@
##             integ-query-context     #101   +/-   ##
======================================================
  Coverage                       ?   97.76%           
  Complexity                     ?     2880           
======================================================
  Files                          ?      276           
  Lines                          ?     7078           
  Branches                       ?      447           
======================================================
  Hits                           ?     6920           
  Misses                         ?      157           
  Partials                       ?        1           
Flag Coverage Δ
sql-engine 97.76% <0.00%> (?)

Flags with carried forward coverage won't be shown. Click here to find out more.

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

*/
private static final String REQUEST_ID_KEY = "request_id";

private static final String EMPTY_ID = "ID";
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Javadoc would be nice.

Copy link
Copy Markdown

@forestmvey forestmvey left a comment

Choose a reason for hiding this comment

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

LGTM

Signed-off-by: Yury Fridlyand <yuryf@bitquilltech.com>
public static String getRequestId() {
final String requestId = ThreadContext.get(REQUEST_ID_KEY);
return requestId;
return Optional.ofNullable(ThreadContext.get(REQUEST_ID_KEY)).orElseGet(() -> EMPTY_ID);
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

This should never happen, right?
Do we need all this code to protect ourselves from a situation that should never happen, or should we just allow the NullPointerException to get thrown...?

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Or better yet, let's call ThreadContext.addRequestId() if the REQUEST_ID_KEY doesn't exist instead of pass back a 'dummy' ID.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

This happens in test only. The test

Copy link
Copy Markdown

@acarbonetto acarbonetto Aug 8, 2022

Choose a reason for hiding this comment

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

Don't write functional-code for a test.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

It was written a time ago, I just renamed the file.
Please, see my fix in acf4ffa.

public static String getRequestId() {
final String requestId = ThreadContext.get(REQUEST_ID_KEY);
return requestId;
return Optional.ofNullable(ThreadContext.get(REQUEST_ID_KEY)).orElseGet(() -> EMPTY_ID);
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Or better yet, let's call ThreadContext.addRequestId() if the REQUEST_ID_KEY doesn't exist instead of pass back a 'dummy' ID.

Signed-off-by: Yury Fridlyand <yuryf@bitquilltech.com>
Signed-off-by: Yury Fridlyand <yuryf@bitquilltech.com>
Signed-off-by: Yury Fridlyand <yuryf@bitquilltech.com>
public static String getRequestId() {
final String requestId = ThreadContext.get(REQUEST_ID_KEY);
return requestId;
if (null == ThreadContext.get(REQUEST_ID_KEY)) {
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

if you chance addRequestId() to return the ID, you can return on that call.

if (null == ThreadContext.get(REQUEST_ID_KEY)) {
addRequestId();
}
return ThreadContext.get(REQUEST_ID_KEY);
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

you can calling ThreadContext.get(REQUEST_ID_KEY) twice. You can return if the value is !null.

Copy link
Copy Markdown

@acarbonetto acarbonetto left a comment

Choose a reason for hiding this comment

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

some small comments

Signed-off-by: Yury Fridlyand <yuryf@bitquilltech.com>
@Yury-Fridlyand Yury-Fridlyand merged commit dc2a9e9 into integ-query-context Aug 11, 2022
@Yury-Fridlyand Yury-Fridlyand deleted the dev-query-context branch August 11, 2022 23:56
andy-k-improving pushed a commit that referenced this pull request Nov 16, 2024
…_in_CI

Include feature branch in workflow to trigger CI
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