Files
vdleakfinder/demo-app/src/main/java/com/example/leakdemo/SnoopView.java
T
Pit Friedrich d9a9647742 Initial commit
2026-10-11 17:45:06 +02:00

25 lines
824 B
Java

package com.example.leakdemo;
import com.vaadin.flow.component.Component;
import com.vaadin.flow.component.html.H2;
import com.vaadin.flow.component.html.Paragraph;
import com.vaadin.flow.component.orderedlayout.VerticalLayout;
import com.vaadin.flow.router.Route;
/** LEAK: the view of one user keeps a reference to a view of a different user. */
@Route("snoop")
public class SnoopView extends VerticalLayout {
private Component peeked;
public SnoopView() {
add(new H2("Snoop"));
synchronized (StaticLeakView.RECENT_VIEWS) {
if (!StaticLeakView.RECENT_VIEWS.isEmpty()) {
peeked = StaticLeakView.RECENT_VIEWS.get(0);
}
}
add(new Paragraph(peeked == null ? "nothing to peek at" : "peeking at " + peeked.getClass().getSimpleName()));
}
}