steveloughran commented on code in PR #5780:
URL: https://github.com/apache/hadoop/pull/5780#discussion_r1245676090
##########
hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/impl/BackReference.java:
##########
@@ -0,0 +1,37 @@
+package org.apache.hadoop.fs.impl;
+
+import javax.annotation.Nullable;
+
+import org.apache.hadoop.classification.VisibleForTesting;
+
+/**
+ * Holds reference to an object to be attached to a stream or store to avoid
+ * the reference being lost to GC.
+ */
+public class BackReference {
+ private final Object reference;
+
+ public BackReference(@Nullable Object reference) {
+ this.reference = reference;
+ }
+
+ /**
+ * is the reference null?
+ * @return true if the ref. is null, else false.
+ */
+ public boolean isNull() {
+ return reference == null;
+ }
+
+ @VisibleForTesting
+ public Object getReference() {
Review Comment:
ideally i'd want this to be completely opaque: you can pass in a back
reference but never see what it was to.
I know this means the tests have to get less sophisticated, but we can still
assert that the reference is non-null and rely on code review to make sure it
is the right type
--
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]