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

Removed suspicious getClass() call on Class #15367

Closed
wants to merge 1 commit into from

Conversation

dk2k
Copy link
Contributor

@dk2k dk2k commented Aug 22, 2024

Removed suspicious getClass() call on Class

Signed-off-by: Dmitry Kryukov <dk2k@ya.ru>
Copy link
Contributor

❌ Gradle check result for 34d23d1: FAILURE

Please examine the workflow log, locate, and copy-paste the failure(s) below, then iterate to green. Is the failure a flaky test unrelated to your change?

@dblock
Copy link
Member

dblock commented Aug 23, 2024

Is there a test covering this path?

Copy link
Contributor

✅ Gradle check result for 34d23d1: SUCCESS

Copy link

codecov bot commented Aug 23, 2024

Codecov Report

Attention: Patch coverage is 0% with 1 line in your changes missing coverage. Please review.

Project coverage is 71.84%. Comparing base (abb1041) to head (34d23d1).
Report is 171 commits behind head on main.

Files with missing lines Patch % Lines
...rg/opensearch/core/common/io/stream/Writeable.java 0.00% 1 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##               main   #15367      +/-   ##
============================================
- Coverage     71.93%   71.84%   -0.09%     
+ Complexity    63223    63209      -14     
============================================
  Files          5214     5214              
  Lines        295938   295938              
  Branches      42754    42754              
============================================
- Hits         212876   212627     -249     
- Misses        65601    65880     +279     
+ Partials      17461    17431      -30     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@dblock dblock added backport 2.x Backport to 2.x branch skip-changelog labels Aug 24, 2024
Copy link
Member

@dblock dblock left a comment

Choose a reason for hiding this comment

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

Reading the code seems like the .getClass() was intentional. I could be wrong.

Copy link
Member

@dbwiddis dbwiddis left a comment

Choose a reason for hiding this comment

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

Why is this suspicious?

The intention here is to display the fully qualified class name. Printing the instance toString() may expose object internals to an exception handling path.

@dk2k
Copy link
Contributor Author

dk2k commented Sep 17, 2024

@dbwiddis
Code snippet for illustration:

public static void main(String[] args) {
    StringBuilder stringBuilder = new StringBuilder();
    Class classInstance = stringBuilder.getClass();
    System.out.println(classInstance);
    System.out.println(classInstance.getClass());
}

output:
class java.lang.StringBuilder
class java.lang.Class

Which of the lines from this output do you expect to see as part of exception's message?

@dk2k dk2k requested a review from dbwiddis September 17, 2024 19:40
@dblock
Copy link
Member

dblock commented Sep 19, 2024

The log entry says "streamable custom class XYZ already registered", we expect to see XYZ

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport 2.x Backport to 2.x branch skip-changelog
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants