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

[java] [7.0-rc1] ReplaceHashtableWithMap on java.util.Properties #4433

Closed
ben-manes opened this issue Mar 26, 2023 · 1 comment · Fixed by #4545
Closed

[java] [7.0-rc1] ReplaceHashtableWithMap on java.util.Properties #4433

ben-manes opened this issue Mar 26, 2023 · 1 comment · Fixed by #4545
Assignees
Labels
a:false-positive PMD flags a piece of code that is not problematic
Milestone

Comments

@ben-manes
Copy link

Affects PMD Version:
7.0-rc1 upgrading from 6.55

Rule:
ReplaceHashtableWithMap

Description:
The rule suggests replacing when (a) the subtype cannot be replaced due to the api contract and (b) Properties now delegates to a ConcurrentHashMap. This rule should not apply to subtypes where the api is out of the author's control.

Code Sample demonstrating the issue:
JCache returns Properties in its api, so this code is flagged.

Expected outcome:
PMD reports a violation, but the user cannot make the suggested refactoring.

# File Line Problem
1 jcache/CacheManagerImpl.java 48 Consider replacing this Hashtable with the newer java.util.Map

Running PMD through: Gradle
This requires workaround in gradle/gradle#24502

@ben-manes ben-manes added the a:false-positive PMD flags a piece of code that is not problematic label Mar 26, 2023
@road723
Copy link

road723 commented Mar 28, 2023

JavaMail has a similar dependency on java.util.Properties so at least having this as a configurable property would be excellent

@jsotuyod jsotuyod added this to the 7.0.0 milestone Mar 31, 2023
@oowekyala oowekyala self-assigned this May 3, 2023
adangel added a commit to adangel/pmd that referenced this issue May 28, 2023
adangel added a commit to adangel/pmd that referenced this issue May 28, 2023
…ties

[java] Fix pmd#4433 - FP with ReplaceHashtableWithMap pmd#4545
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
a:false-positive PMD flags a piece of code that is not problematic
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants