Skip to content

Apache Lucene open-source search software

LUCENE-9424: add a performance warning to AttributeSource.captureState javadocs

Mike McCandlesse4c2be98fa2f
diff --git a/lucene/CHANGES.txt b/lucene/CHANGES.txt
index 96f1b2587e6..fc1fbbcf798 100644
--- a/lucene/CHANGES.txt
+++ b/lucene/CHANGES.txt
@@ -183,6 +183,12 @@ Bug Fixes
---------------------
(No changes)
+Documentation
+---------------------
+
+* LUCENE-9424: Add a performance warning to AttributeSource.captureState javadocs (Haoyu Zhai)
+
+
Other
---------------------
(No changes)
diff --git a/lucene/core/src/java/org/apache/lucene/util/AttributeSource.java b/lucene/core/src/java/org/apache/lucene/util/AttributeSource.java
index e962fedc1de..fe4e4f1cd0a 100644
--- a/lucene/core/src/java/org/apache/lucene/util/AttributeSource.java
+++ b/lucene/core/src/java/org/apache/lucene/util/AttributeSource.java
@@ -292,6 +292,8 @@ public class AttributeSource {
/**
* Captures the state of all Attributes. The return value can be passed to
* {@link #restoreState} to restore the state of this or another AttributeSource.
+ *
+ * Be careful, this method comes with a cost of deep copying all attributes in the source.
*/
public final State captureState() {
final State state = this.getCurrentState();