You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cayenne.apache.org by ab...@apache.org on 2019/01/21 11:50:21 UTC
[cayenne] branch STABLE-4.1 updated: CAY-2517 EventManager:
optimization of adding listeners
This is an automated email from the ASF dual-hosted git repository.
abulatski pushed a commit to branch STABLE-4.1
in repository https://gitbox.apache.org/repos/asf/cayenne.git
The following commit(s) were added to refs/heads/STABLE-4.1 by this push:
new dffd558 CAY-2517 EventManager: optimization of adding listeners
dffd558 is described below
commit dffd558c2c0aeb6fbf02876855535c487b88827e
Author: Arseni Bulatski <an...@gmail.com>
AuthorDate: Mon Jan 21 14:33:15 2019 +0300
CAY-2517 EventManager: optimization of adding listeners
(cherry picked from commit c5e0f0099a49b0aa287b523146367f59b6477f53)
---
RELEASE-NOTES.txt | 1 +
.../main/java/org/apache/cayenne/util/Invocation.java | 16 +++++++---------
2 files changed, 8 insertions(+), 9 deletions(-)
diff --git a/RELEASE-NOTES.txt b/RELEASE-NOTES.txt
index e6ce40d..115feb7 100644
--- a/RELEASE-NOTES.txt
+++ b/RELEASE-NOTES.txt
@@ -29,6 +29,7 @@ CAY-2493 Save cgen configuration with datamap XML
CAY-2494 Rename dbImport tag from 'config' to 'dbImport'
CAY-2499 Support for COUNT(DISTINCT(column)) function aggregate
CAY-2514 Set SERVER_CONTEXTS_SYNC_PROPERTY default value to false
+CAY-2517 EventManager: optimization of adding listeners
Bug Fixes:
diff --git a/cayenne-server/src/main/java/org/apache/cayenne/util/Invocation.java b/cayenne-server/src/main/java/org/apache/cayenne/util/Invocation.java
index 23a6fdf..41c4553 100644
--- a/cayenne-server/src/main/java/org/apache/cayenne/util/Invocation.java
+++ b/cayenne-server/src/main/java/org/apache/cayenne/util/Invocation.java
@@ -37,6 +37,7 @@ public class Invocation {
private WeakReference _target;
private Method _method;
private Class[] _parameterTypes;
+ private int _hashCode;
/**
* Prevent use of empty default constructor
@@ -119,6 +120,11 @@ public class Invocation {
_method.setAccessible(true);
}
+ /**
+ * IMPORTANT: include Invocation target object(not a WeakReference) into
+ * algorithm is used to compute hashCode.
+ */
+ _hashCode = 31 * target.hashCode() + _method.hashCode();
_parameterTypes = parameterTypes;
_target = new WeakReference(target);
}
@@ -258,15 +264,7 @@ public class Invocation {
*/
@Override
public int hashCode() {
- // IMPORTANT: DO NOT include Invocation target into whatever
- // algorithm is used to compute hashCode, since it is using a
- // WeakReference and can be released at a later time, altering
- // hashCode, and breaking collections using Invocation as a key
- // (e.g. event DispatchQueue)
-
- // TODO: use Jakarta commons HashBuilder
- int hash = 42, hashMultiplier = 59;
- return hash * hashMultiplier + _method.hashCode();
+ return _hashCode;
}
/**