mbien commented on code in PR #7705:
URL: https://github.com/apache/netbeans/pull/7705#discussion_r1741074873
##########
ide/project.dependency/src/org/netbeans/modules/project/dependency/reload/ProjectReloadInternal.java:
##########
@@ -743,32 +743,62 @@ public void runProjectAction(Project p, Runnable r) {
public void assertNoOperations() {
synchronized (this) {
- if (!pendingOperations.isEmpty()) {
+ Map<Project, ProjectOperations> ops = new
HashMap<>(this.pendingOperations);
+ ops.values().removeAll(this.terminatingOperations);
+ if (!ops.isEmpty()) {
System.err.println("Pending operations detected");
- for (Map.Entry<Project, ProjectOperations> en :
pendingOperations.entrySet()) {
+ for (Map.Entry<Project, ProjectOperations> en :
ops.entrySet()) {
ProjectOperations op = en.getValue();
System.err.println(en.getKey() + ": usage " + op.usage +
", pendingReloads: " + op.pendingReloads.size() + ", actions: " +
op.postponedActions.size());
for (Reloader r : op.pendingReloads) {
r.getOriginTrace().printStackTrace();
}
}
}
- if (!pendingOperations.isEmpty() || this.loaderProcessors.size()
!= PROJECT_RELOAD_CONCURRENCY) {
+ if (!ops.isEmpty() || this.loaderProcessors.size() !=
PROJECT_RELOAD_CONCURRENCY) {
throw new IllegalStateException();
}
}
}
+ private Collection<IdentityHolder> collectReleases(ProjectOperations op) {
+ Collection<IdentityHolder> releases = op.releases;
+ // this is copied from postCleanup, but can be done in batch without
+ // checking the project operation is in progress for each reference.
These are already removed
+ // from stateIdentity, so just check they did not obtain another one:
+ releases.removeIf(expired -> {
+ ProjectStateData d = expired.state.get();
+ if (d == null) {
+ return true;
+ }
+ IdentityHolder h = stateIdentity.get(d);
+ return h != null && h != expired;
+ });
+ op.releases = new ArrayList<>();
Review Comment:
moving L777 to L766 would make this a little bit safer.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists