[Demonstration 1]

[Buggy Method]
@Override
public void doPost(HttpServletRequest req, HttpServletResponse resp) {
    try {
        String email = req.getParameter("email");
        String password = req.getParameter("password");
        if (DatastoreUtils.checkUserCredentials(email, password)) {
            HttpSession session = req.getSession(true);
            session.setAttribute("user", DatastoreUtils.getUser(email));
            resp.getWriter().print("success");
        } else
            resp.getWriter().print("fail");
    } catch (Exception e) {
        e.printStackTrace();
    }
}

[Buggy Hunk]
session.setAttribute("user", DatastoreUtils.getUser(email));

[Patch]
session.setAttribute("user", email);

[Demonstration 2]

[Buggy Method]
@RolesAllowed(AuthRole.USER)
@POST
@Path("/closeSession")
public Response closeSession(CMSMessage cmsMessage, @Context ServletContext context, @Context HttpServletRequest req, @Context HttpServletResponse resp) throws Exception {
    User user = ((PrincipalVS) req.getUserPrincipal()).getUser();
    User signer = cmsMessage.getUser();
    if (!user.getNif().equals(signer.getNif()))
        throw new ExceptionVS("signer it's not session owner");
    MessageDto messageDto = cmsMessage.getSignedContent(MessageDto.class);
    if (messageDto.getOperation() != TypeVS.CLOSE_SESSION)
        throw new ExceptionVS(format("bad message type, expected ''{0}'' found ''{1}''", TypeVS.CLOSE_SESSION, messageDto.getOperation()));
    if (!messageDto.getHttpSessionId().equals(req.getSession().getId()))
        throw new ExceptionVS("bad http session id");
    req.getSession().invalidate();
    return Response.ok().entity("").build();
}

[Buggy Hunk]
req.getSession().invalidate();

[Patch]
req.getSession().removeAttribute(PrincipalVS.USER_KEY);

[Demonstration 3]

[Buggy Method]
private void init() {
    input = new Input();
    addKeyListener(input);
    addMouseListener(input);
    addMouseMotionListener(input);
    requestFocus();
    screen = new Screen(WIDTH, HEIGHT);
    ingameHUD = new IngameHUD(this);
    pixels = ((DataBufferInt) img.getRaster().getDataBuffer()).getData();
    screen.pixels = pixels;
    try {
        SHEET = SpriteSheet.loadSheet(new File("res/PinkSquareSprites.png"));
        TERRAIN = SpriteSheet.loadSheet(new File("res/terrain2.png"));
    } catch (Exception e) {
        e.printStackTrace();
    }
    try {
        level = new Level(this, new File("res/Map3.png"));
    } catch (Exception e) {
        e.printStackTrace();
    }
    controller = new Controller();
    gui = new TitleScreen();
    Unit u = new WorkerCat(level);
    u.x = random.nextInt(level.width * 16);
    u.y = random.nextInt(level.height * 16);
    startX = u.x;
    startY = u.y;
    screen.xOff = u.x - WIDTH / 2 + 1;
    screen.yOff = u.y - HEIGHT / 2 + 1;
    level.add(u);
}

[Buggy Hunk]
Unit u = new WorkerCat(level);

[Patch]
Unit u = new OctoBase(level);