@SuppressWarnings("ThrowableResultOfMethodCallIgnored") void log(PendingReferenceCheck check, InvocationOnMock invocation) { Method method = invocation.getMethod(); if (Object.class == method.getDeclaringClass() && "finalize".equals(method.getName())) { /* skip invocations to finalize - they are not of interest to us, * and GC is not predictable enough to reliably trace this. */ return; } StringBuilder entry = new StringBuilder(method.getName()).append('('); entry.append(check); for (Object arg : invocation.getArguments()) { if (arg instanceof AbstractBaseRecord) { AbstractBaseRecord record = (AbstractBaseRecord) arg; entry .append(',') .append(record.getClass().getSimpleName()) .append('[') .append(record.getLongId()) .append(']'); } } String message = entry.append(')').toString(); if (null != data.put(message, new Throwable(message))) { Integer cur = duplicates.get(message); if (cur == null) { cur = 1; } duplicates.put(message, cur + 1); } }
public static Mode fromRecordState(AbstractBaseRecord record) { return fromRecordState(record.isCreated(), record.inUse()); }