Skip to content

[Spotbugs] Enable spotbugs in pulsar-metadata - #9253

Merged
sijie merged 5 commits into
apache:masterfrom
RobertIndie:spotbugs-pulsar-metadata
Jan 26, 2021
Merged

sijie merged 5 commits into
apache:masterfrom
RobertIndie:spotbugs-pulsar-metadata

Conversation

@RobertIndie

Copy link
Copy Markdown
Member

Fixes streamnative/pulsar#1797

Motivation

Enable spotbugs in module pulsar-metadata.

public class GetResult {

public GetResult(byte[] value, Stat stat){
this.value = value.clone();

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

While I understand the immutability aspect, making 2 extra copies and allocations of the value array it's overkill for this scenario.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Maybe we could make the value public to solve this problem(EI_EXPOSE_REP) and avoid copy, even though that would sacrifice immutability. What do you think?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I'm not super convinced in making the field public. GetResult class is part of API so I'd rather keep that behind a getter method. An implementation might not store it directly as a byte[] but instead convert that on demand.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Can we instead ignore the warning for this case?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Okay.

@sijie sijie added this to the 2.8.0 milestone Jan 21, 2021
@sijie sijie added the type/cleanup Code or doc cleanups e.g. remove the outdated documentation or remove the code no longer in use label Jan 21, 2021
@RobertIndie

Copy link
Copy Markdown
Member Author

/pulsarbot run-failure-checks

2 similar comments
@RobertIndie

Copy link
Copy Markdown
Member Author

/pulsarbot run-failure-checks

@RobertIndie

Copy link
Copy Markdown
Member Author

/pulsarbot run-failure-checks

@RobertIndie
RobertIndie force-pushed the spotbugs-pulsar-metadata branch from a6097eb to 7613ed1 Compare January 25, 2021 01:30
@RobertIndie

Copy link
Copy Markdown
Member Author

/pulsarbot run-failure-checks

4 similar comments
@RobertIndie

Copy link
Copy Markdown
Member Author

/pulsarbot run-failure-checks

@RobertIndie

Copy link
Copy Markdown
Member Author

/pulsarbot run-failure-checks

@RobertIndie

Copy link
Copy Markdown
Member Author

/pulsarbot run-failure-checks

@RobertIndie

Copy link
Copy Markdown
Member Author

/pulsarbot run-failure-checks

@sijie
sijie merged commit 0223bb1 into apache:master Jan 26, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

type/cleanup Code or doc cleanups e.g. remove the outdated documentation or remove the code no longer in use

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Enable spotbugs in module pulsar-metadata

3 participants