Skip to content

[core] Allow for thread-safe report listeners #193

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

Merged
merged 2 commits into from
Feb 10, 2017

Conversation

jsotuyod
Copy link
Member

  • This follows discussion on [core] Incremental analysis #125 (comment)
  • We add a marker interface for thread-safe listeners, and implement it were appropriate.
  • Breaking change: getSynchronizedListeners and addSynchronizedListeners now handle
    List<ThreadSafeReportListener>.
  • We may mark the non-thread-safe methods and interfaces as deprecated and force everyone
    to handle synchronization on their own for future releases.

 - This follows discussion on pmd#125 (comment)
 - We add a marker interface for thread-safe listeners, and implement it were appropriate.
 - Breaking change: `getSynchronizedListeners` and `addSynchronizedListeners` now handle
    `List<ThreadSafeReportListener>`.
 - We may mark the non-thread-safe methods and interfaces as deprecated and force everyone
    to handle synchronization on their own for future releases.
@jsotuyod jsotuyod added an:enhancement An improvement on existing features / rules in:pmd-internals Affects PMD's internals labels Jan 17, 2017
@jsotuyod jsotuyod added this to the 5.6.0 milestone Jan 17, 2017
Copy link
Member Author

@jsotuyod jsotuyod left a comment

Choose a reason for hiding this comment

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

Shall I deprecate ReportListener too and start encouraging everyone to move to ThreadSafeReportListener?

@@ -512,7 +522,7 @@ public long getElapsedTimeInMillis() {
return end - start;
}

public List<SynchronizedReportListener> getSynchronizedListeners() {
public List<ThreadSafeReportListener> getSynchronizedListeners() {
Copy link
Member Author

Choose a reason for hiding this comment

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

I was not sure, since I'm already breaking the API, if I should rename this method right now or not. What do you think @adangel ?

Copy link
Member

Choose a reason for hiding this comment

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

I'd say, rename the method right away.
I think, it's ok to break the API since we are on the master (5.6.x) branch only.
However, we should have a short notice in the changelog under section "API Changes" - just in case.
I assume, integration/upgrading of PMD with other tools, usually works like this: Upgrade PMD dependency and if it compiles and tests successfully -> great. If not, maybe look at the changelog or just read the code...

@jsotuyod jsotuyod added the for:performance The goal of this change is to improve PMD's performance label Jan 17, 2017
@@ -512,7 +522,7 @@ public long getElapsedTimeInMillis() {
return end - start;
}

public List<SynchronizedReportListener> getSynchronizedListeners() {
public List<ThreadSafeReportListener> getSynchronizedListeners() {
Copy link
Member

Choose a reason for hiding this comment

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

I'd say, rename the method right away.
I think, it's ok to break the API since we are on the master (5.6.x) branch only.
However, we should have a short notice in the changelog under section "API Changes" - just in case.
I assume, integration/upgrading of PMD with other tools, usually works like this: Upgrade PMD dependency and if it compiles and tests successfully -> great. If not, maybe look at the changelog or just read the code...

* extra synchronization.
*
* Thread-safety is required only for concurrently notifying about different files.
* Same file violations are guaranteed to be reported serially.
Copy link
Member

Choose a reason for hiding this comment

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

Good comment!

@@ -9,7 +9,7 @@
/**
* Wraps a report listener in order to synchronize calls to it.
*/
public final class SynchronizedReportListener implements ReportListener {
public final class SynchronizedReportListener implements ThreadSafeReportListener {
Copy link
Member

Choose a reason for hiding this comment

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

Do we still need this SynchronizedReportListener? I think, PMD itself doesn't use it directly anymore with your changes... so we could delete it (or deprecate it)

Or should we provide it as an example of a very simple, but possibly too much synchronizing listener, e.g. as a help to migrate your existing listener to a ThreadSafeReportListener?

 - Breaking change to public API to retrieve listeners.
@jsotuyod
Copy link
Member Author

@adangel there you go!

I renamed the method, and deprecated both the old ReportListener and SynchronizedReportListener. For 5.7.0 we may finally remove them, but wanted to give some time for developers to accommodate this change.

We should definitely add proper warnings in the changelog when we merge.

@adangel
Copy link
Member

adangel commented Feb 10, 2017

Thanks!

@adangel adangel merged commit 86b214d into pmd:master Feb 10, 2017
adangel added a commit that referenced this pull request Feb 10, 2017
@jsotuyod jsotuyod deleted the thread-safe-listeners branch February 10, 2017 23:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
an:enhancement An improvement on existing features / rules for:performance The goal of this change is to improve PMD's performance in:pmd-internals Affects PMD's internals
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants