Skip to content

[java] AvoidSynchronizedStatement: Improve rule doc#6657

Merged
UncleOwen merged 2 commits into
pmd:mainfrom
adangel:java/doc-avoidsynchronizedstatement
May 21, 2026
Merged

[java] AvoidSynchronizedStatement: Improve rule doc#6657
UncleOwen merged 2 commits into
pmd:mainfrom
adangel:java/doc-avoidsynchronizedstatement

Conversation

@adangel

@adangel adangel commented May 8, 2026

Copy link
Copy Markdown
Member

Describe the PR

Refs #5175 (comment)

While it's not wrong to put "lock.lock()" inside the try, the best practice documented in https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/util/concurrent/locks/ReentrantLock.html puts it directly before the try.

Also added an explicit example of tryLock() usage.

Related issues

  • Fix #

Ready?

  • Added unit tests for fixed bug/feature
  • Passing all unit tests
  • Complete build ./mvnw clean verify passes (checked automatically by github actions)
  • Added (in-code) documentation (if needed)

@adangel adangel added the in:documentation Affects the documentation [doc] label May 8, 2026
@pmd-actions-helper

pmd-actions-helper Bot commented May 8, 2026

Copy link
Copy Markdown
Contributor

Documentation Preview

Compared to main:
This changeset changes 0 violations,
introduces 0 new violations, 0 new errors and 0 new configuration errors,
removes 0 violations, 15 errors and 9 configuration errors.
There are 0 changed duplications, 0 new duplications and 0 removed duplications.
There are 0 changed CPD errors, 0 new CPD errors and 0 removed CPD errors.

Regression Tester Report

(comment created at 2026-05-19 18:23:41+00:00 for 3499944)

@adangel adangel requested review from UncleOwen and zbynek May 14, 2026 15:31

@UncleOwen UncleOwen 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.

New description looks good!

Comment thread pmd-java/src/main/resources/category/java/multithreading.xml
Comment thread pmd-java/src/main/resources/category/java/multithreading.xml Outdated
adangel added 2 commits May 19, 2026 20:00
Refs pmd#5175 (comment)

While it's not wrong to put "lock.lock()" inside the try, the best
practice documented in https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/util/concurrent/locks/ReentrantLock.html
puts it directly before the try.

Also added an explicit example of tryLock() usage.
@adangel adangel force-pushed the java/doc-avoidsynchronizedstatement branch from a96aaec to 3499944 Compare May 19, 2026 18:09
@adangel adangel added this to the 7.25.0 milestone May 19, 2026
@adangel

adangel commented May 19, 2026

Copy link
Copy Markdown
Member Author

Thanks for the reviews!

@UncleOwen UncleOwen merged commit d1bbf1c into pmd:main May 21, 2026
13 checks passed
@adangel adangel deleted the java/doc-avoidsynchronizedstatement branch May 22, 2026 17:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

in:documentation Affects the documentation [doc]

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants