@Test public void testLeakedManagedReferencePopulatedStack() { final StackTraceElement[] populated = new StackTraceElement[2]; populated[0] = new StackTraceElement("SomeClass", "method", "file", 0); populated[1] = new StackTraceElement("SomeOtherClass", "method", "file", 0); caller.referenceLeaked(reference, populated); assertEquals(1, internalErrors.get()); assertEquals( "reference foo leaked at:\n SomeClass.method(file:0)\n SomeOtherClass.method" + "(file:0)", errorMessage); }
@Override public void referenceLeaked(final Object reference, final StackTraceElement[] stack) { final String s = stack.length > 0 ? "\n" + formatStack(Arrays.stream(stack), " ") : " <unknown>"; internalError(String.format("reference %s leaked at:%s", reference, s), null); }
DirectCaller implements Caller { @Override public void referenceLeaked(final Object reference, final StackTraceElement[] stack) { final String s = stack.length > 0 ? "\n" + formatStack(Arrays.stream(stack), " ") : " <unknown>"; internalError(String.format("reference %s leaked at:%s", reference, s), null); } }
DirectCaller implements Caller { @Override public void referenceLeaked(final Object reference, final StackTraceElement[] stack) { final String s = stack.length > 0 ? "\n" + formatStack(Arrays.stream(stack), " ") : " <unknown>"; internalError(String.format("reference %s leaked at:%s", reference, s), null); }  }
DirectCaller implements Caller { @Override public void referenceLeaked(final Object reference, final StackTraceElement[] stack) { final String s = stack.length > 0 ? "\n" + formatStack(Arrays.stream(stack), " ") : " <unknown>"; internalError(String.format("reference %s leaked at:%s", reference, s), null); }  @Override void execute(final Runnable runnable); @Override void referenceLeaked(final Object reference, final StackTraceElement[] stack); }
DirectCaller implements Caller { @Override public void referenceLeaked(final Object reference, final StackTraceElement[] stack) { final String s = stack.length > 0 ? "\n" + formatStack(Arrays.stream(stack), " ") : " <unknown>"; internalError(String.format("reference %s leaked at:%s", reference, s), null); }  @Override void execute(final Runnable runnable); @Override void referenceLeaked(final Object reference, final StackTraceElement[] stack);  }