Skip to content

KAFKA-13518: Update gson dependency#11579

Closed
dongjinleekr wants to merge 5 commits into
apache:trunkfrom
dongjinleekr:feature/KAFKA-13518
Closed

KAFKA-13518: Update gson dependency#11579
dongjinleekr wants to merge 5 commits into
apache:trunkfrom
dongjinleekr:feature/KAFKA-13518

Conversation

@dongjinleekr

Copy link
Copy Markdown
Contributor

Here is the fix. Since spotbugs 4.5.1 was released just 12 hours ago, it would take a little bit to be synched with maven central.

Committer Checklist (excluded from commit message)

  • Verify design and implementation
  • Verify test coverage and CI build status
  • Verify documentation (including upgrade notes)

@showuon showuon left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

@dongjinleekr , thanks for the PR. But there's spotBugs 4.5.2. Could you upgrade to the latest one? Also, the PR title/description can't tell what's the relationship between spotBugs and gson, could you add explanation there? Thanks.

@showuon showuon left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Also, there are build errors. Please fix them. Thanks.

@dongjinleekr dongjinleekr changed the title KAFKA-13518: Update gson and netty-codec in 3.0.0 KAFKA-13518: Update gson dependency Dec 25, 2021
@dongjinleekr

Copy link
Copy Markdown
Contributor Author

Hi @showuon,

Here it is. I just updated the issue title more clearly and updated the spotbugs dependency into 4.5.2.

@showuon showuon left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM!

@showuon showuon left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Please also help fix the build failure. Thanks.

@dongjinleekr

Copy link
Copy Markdown
Contributor Author

@showuon Sorry for bothering you. Here is the update. There were some updates on spotbugs between 4.2.2 and 4.5.2 and some previously-unfound problems are now detected:

  • In 4.3.0, spotbugs improved their detection logic for MS_EXPOSE_REP:

    MS_EXPOSE_REP and EI_EXPOSE_REP are now reported for code returning a reference to a mutable object indirectly (e.g. via a local variable)

  • In 4.4.2, spotbugs fixed some false positives for DMI_RANDOM_USED_ONLY_ONCE and started to detect some unfound problems:

    DMI_RANDOM_USED_ONLY_ONCE false positive

After the update, it works like a charm:
20211225-180841

@showuon showuon left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

@dongjinleekr , thanks for the update, but it looks like there are other failed spotBugs.

@dongjinleekr

Copy link
Copy Markdown
Contributor Author

@showuon My bad. I found several other false-positives from other modules with spotbugs; They are now fixed. (Please see the comments.) 🙇
20211227-231700

@ijuma

ijuma commented Feb 5, 2022

Copy link
Copy Markdown
Member

Thanks for the PR. Seems like the new version has more false positives. Do you know if they intend to fix those?

@dongjinleekr

Copy link
Copy Markdown
Contributor Author

@ijuma

Do you know if they intend to fix those?

Oh yes, as you can see in the updated PR, I updated spotbugs to 4.5.3 following the gradle plugin 5.0.5, and rebased onto the latest trunk. It seems like there are a bunch of false positives in the recent version of spotbugs (below) but, I verified that none of them are affecting.

20220214-191747

+1. They also have not fixed the issues I commented on in spotbugs-exclude.xml yet. I will follow up and apply them as soon as they fix them.

@ijuma

ijuma commented Feb 14, 2022

Copy link
Copy Markdown
Member

Should we wait until they fix these issues in spotBugs? It doesn't look like the cost/benefit in upgrading here isn't favorable.

@dongjinleekr

Copy link
Copy Markdown
Contributor Author

@ijuma If you don't mind CVE WS-2021-0419 introduced by gson 2.8.6. This PR is to fix it.

@dongjinleekr

Copy link
Copy Markdown
Contributor Author

Rebased onto the latest trunk. cc/ @ijuma

@Boojapho

Copy link
Copy Markdown

Gson library has another recent vulnerability: https://nvd.nist.gov/vuln/detail/CVE-2022-25647. Gson library 2.8.9 fixes this, which is included in Spotbugs 4.5.0 and higher.

@dongjinleekr dongjinleekr force-pushed the feature/KAFKA-13518 branch from 7bd7b86 to d4e9f36 Compare June 6, 2022 01:38
@dongjinleekr

Copy link
Copy Markdown
Contributor Author

@Boojapho Thanks for reporting. Here is the fix - rebased onto the latest trunk and upgraded spotbugs into 4.7.0, which also fixes the gson vulnerability.

Comment thread gradle/spotbugs-exclude.xml Outdated

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Looks like spotbugs/spotbugs@720af6c would help, but it's not available in a released version yet.

Comment thread gradle/spotbugs-exclude.xml Outdated

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Disabled by default here spotbugs/spotbugs@7ba0e74 (not released yet).

Comment thread gradle/spotbugs-exclude.xml Outdated

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Why do we have to disable this one?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

  1. Public static org.apache.kafka.server.metrics.KafkaYammerMetrics.defaultRegistry() may expose internal representation by returning KafkaYammerMetrics.metricsRegistry.
  2. Public static org.apache.kafka.common.security.auth.SecurityProtocol.names() may expose internal representation by returning SecurityProtocol.NAMES

Comment thread gradle/spotbugs-exclude.xml Outdated

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Are we disabling this one due to false positives?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Yes.

  1. Random object created and used only once in new kafka.tools.ConsoleConsumer$ConsumerConfig(String[])
  2. Random object created and used only once in new kafka.tools.ConsumerPerformance$ConsumerPerfConfig(String[])

@dongjinleekr dongjinleekr force-pushed the feature/KAFKA-13518 branch from d4e9f36 to d193b71 Compare June 11, 2022 13:43
@dongjinleekr

Copy link
Copy Markdown
Contributor Author

@ijuma Here is the update:

  1. Rebased onto the latest trunk.
  2. Gather the false positives together and add some TODO comments not to leave the workarounds later.
  3. Reduce the scope of DMI_RANDOM_USED_ONLY_ONCE and MS_EXPOSE_REP into scala-only and some specific classes only, respectively.

@ijuma

ijuma commented Aug 8, 2022

Copy link
Copy Markdown
Member

Can you please update to spotbugs 4.7.1? It seems like it fixes the false positives.

@ijuma ijuma mentioned this pull request Oct 19, 2022
3 tasks
@omkreddy

Copy link
Copy Markdown
Contributor

@dongjinleekr I have not seen this PR. I have raised draft PR #12768 to upgrade spotbugs. Can we update to spotbugs 4.7.3?

@omkreddy

Copy link
Copy Markdown
Contributor

Closing this PR in favour of #12768

@omkreddy omkreddy closed this Oct 24, 2022
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.

6 participants