MCPcopy Create free account
hub / github.com/antlr/codebuff / cleanUp

Method cleanUp

corpus/java/training/guava/base/internal/Finalizer.java:138–169  ·  view source on GitHub ↗

Cleans up a single reference. Catches and logs all throwables. @return true if the caller should continue, false if the associated FinalizableReferenceQueue is no longer referenced.

(Reference<?> reference)

Source from the content-addressed store, hash-verified

136 * is no longer referenced.
137 */
138 private boolean cleanUp(Reference<?> reference) {
139 Method finalizeReferentMethod = getFinalizeReferentMethod();
140 if (finalizeReferentMethod == null) {
141 return false;
142 }
143 do {
144 /*
145 * This is for the benefit of phantom references. Weak and soft references will have already
146 * been cleared by this point.
147 */
148 reference.clear();
149
150 if (reference == frqReference) {
151 /*
152 * The client no longer has a reference to the FinalizableReferenceQueue. We can stop.
153 */
154 return false;
155 }
156
157 try {
158 finalizeReferentMethod.invoke(reference);
159 } catch (Throwable t) {
160 logger.log(Level.SEVERE, "Error cleaning up after reference.", t);
161 }
162
163 /*
164 * Loop as long as we have references available so as not to waste CPU looking up the Method
165 * over and over again.
166 */
167 } while ((reference = queue.poll()) != null);
168 return true;
169 }
170
171 /**
172 * Looks up FinalizableReference.finalizeReferent() method.

Callers 1

runMethod · 0.95

Calls 5

logMethod · 0.80
clearMethod · 0.65
invokeMethod · 0.45
pollMethod · 0.45

Tested by

no test coverage detected