[Demonstration 1]

[Buggy Method]
public void setFloating(Region content, Point2D translation, boolean absolutePosition) {
    // position the new stage relative to the old scene offset
    Point2D floatScene = this.localToScene(0, 0);
    Point2D floatScreen = this.localToScreen(0, 0);
    // setup window stage
    //      dockTitleBar.setVisible(node.isCustomTitleBar());
    //      dockTitleBar.setManaged(node.isCustomTitleBar());
    stage = new Stage();
    Stage parentStage = null;
    //      stage.titleProperty().bind(node.titleProperty());
    if (parentDockPane != null && parentDockPane.getStage() != null) {
        parentStage = parentDockPane.getStage();
        stage.initOwner(parentStage);
    }
    stage.initStyle(stageStyle);
    // offset the new stage to cover exactly the area the dock was local to the scene
    // this is useful for when the user presses the + sign and we have no information
    // on where the mouse was clicked
    Point2D stagePosition;
    boolean translateToCenter = false;
    if (!absolutePosition) {
        //      if (node.isDecorated()) {
        //        Window owner = stage.getOwner();
        //        stagePosition = floatScene.add(new Point2D(owner.getX(), owner.getY()));
        //      } else
        if (floatScreen != null) {
            // using coordinates the component was previously in (if available)
            stagePosition = floatScreen;
        } else {
            translateToCenter = true;
            if (null != parentStage) {
                double centerX = parentStage.getX() + (parentStage.getWidth() / 2);
                double centerY = parentStage.getY() + (parentStage.getHeight() / 2);
                stagePosition = new Point2D(centerX, centerY);
            } else {
                // using the center of the screen if no relative position is available
                Rectangle2D primScreenBounds = Screen.getPrimary().getVisualBounds();
                double centerX = (primScreenBounds.getWidth() - Math.max(getWidth(), getMinWidth())) / 2;
                double centerY = (primScreenBounds.getHeight() - Math.max(getHeight(), getMinHeight())) / 2;
                stagePosition = new Point2D(centerX, centerY);
            }
        }
        if (translation != null) {
            stagePosition = stagePosition.add(translation);
        }
    } else {
        stagePosition = translation;
    }
    // the border pane allows the dock node to
    // have a drop shadow effect on the border
    // but also maintain the layout of contents
    // such as a tab that has no content
    borderPane.setCenter(this);
    Scene scene = new Scene(borderPane);
    // apply the floating property so we can get its padding size
    // while it is floating to offset it by the drop shadow
    // this way it pops out above exactly where it was when docked
    this.floatingProperty.set(true);
    this.applyCss();
    // apply the border pane css so that we can get the insets and
    // position the stage properly
    borderPane.applyCss();
    Insets insetsDelta = borderPane.getInsets();
    double insetsWidth = insetsDelta.getLeft() + insetsDelta.getRight();
    stage.setScene(scene);
    stage.setMinWidth(borderPane.minWidth(this.getMinWidth()) + insetsWidth);
    stage.setMinHeight(borderPane.minHeight(this.getMinHeight()));
    borderPane.setPrefSize(content.getPrefWidth() + insetsWidth, content.getPrefHeight());
    if (translateToCenter) {
        // we are floating over the center of some parent, therefore align our center with theirs
        stage.setX(stagePosition.getX() - insetsDelta.getLeft() - (borderPane.getPrefWidth() / 2.0));
        stage.setY(stagePosition.getY() - insetsDelta.getTop() - (borderPane.getPrefHeight() / 2.0));
    } else {
        stage.setX(stagePosition.getX() - insetsDelta.getLeft());
        stage.setY(stagePosition.getY() - insetsDelta.getTop());
    }
    if (stageStyle == StageStyle.TRANSPARENT) {
        scene.setFill(null);
    }
    stage.setResizable(this.isStageResizable());
    if (this.isStageResizable()) {
        stage.addEventFilter(MouseEvent.MOUSE_PRESSED, this::handleMouseEvent);
        stage.addEventFilter(MouseEvent.MOUSE_MOVED, this::handleMouseEvent);
        stage.addEventFilter(MouseEvent.MOUSE_DRAGGED, this::handleMouseEvent);
    }
    // we want to set the client area size
    // without this it subtracts the native border sizes from the scene
    // size
    stage.sizeToScene();
    layout();
    // if we a child of the primary stage and its not been shown yet then we must wait before
    // showing ourselves otherwise we will not be a child stage
    if (absolutePosition && parentStage != null && !parentStage.isShowing()) {
        parentStage.setOnShown((e) -> stage.show());
    } else {
        stage.show();
    }
}

[Buggy Hunk]
parentStage.setOnShown((e) -> stage.show());

[Patch]
queueOnShow((e) -> stage.show());

[Demonstration 2]

[Buggy Method]
private void setUpViews() {
    GridView gridview = (GridView) findViewById(R.id.blockList_screen);
    gridview.setAdapter(new BlockIconAdapter(this, R.layout.view_block_icon, mBlockClassHolders));
    gridview.setOnItemClickListener(new OnItemClickListener() {

        @Override
        public void onItemClick(AdapterView<?> adapterView, View view, int position, long id) {
            BlockClassHolder selectedBlock = mBlockClassHolders.get(position);
            Intent data = new Intent();
            data.putExtra(KEY_BLOCK_CATEGORY, mCategory);
            data.putExtra(KEY_BLOCK_NAME, selectedBlock.getBlockName());
            // set the result as "ok" and return the data
            setResult(Activity.RESULT_OK, data);
            finish();
        }
    });
    findViewById(R.id.blockList_cancelButton).setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            final int[] helpImages = { R.drawable.help_sequence, R.drawable.help_repetition, R.drawable.help_selection };
            // create a view witch has a help image
            LayoutInflater inflater = LayoutInflater.from(BlockListActivity.this);
            View view = inflater.inflate(R.layout.view_help, null);
            // choose a help image based on the category
            ImageView help = (ImageView) view.findViewById(R.id.help_showHelpImage);
            help.setImageResource(helpImages[mCategory]);
            help.setAdjustViewBounds(true);
            help.setScaleType(ScaleType.FIT_CENTER);
            // create an AlertDialog that shows helps
            new AlertDialog.Builder(BlockListActivity.this).setTitle(R.string.blockList_howToUseBlock).setMessage(getString(CATEGORY_STRINGS[mCategory]) + getString(R.string.blockList_theseBlocksAreUsedLikeThis)).setView(view).setPositiveButton(R.string.close, null).show();
        }
    });
    findViewById(R.id.blockList_cancelButton).setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            setResult(Activity.RESULT_CANCELED);
            finish();
        }
    });
}

[Buggy Hunk]
findViewById(R.id.blockList_cancelButton).setOnClickListener(new OnClickListener() {

[Patch]
findViewById(R.id.blockList_helpButton).setOnClickListener(new OnClickListener() {

[Demonstration 3]

[Buggy Method]
@Override
public void disconnect() {
    socket.close();
    if (heartbeatTimer != null) {
        heartbeatTimer.cancel();
        heartbeatTimer.purge();
        heartbeatTimer = null;
    }
    if (outboxTimer != null) {
        outboxTimer.cancel();
        outboxTimer.purge();
        outboxTimer = null;
    }
    if (idleTimeoutTimer != null) {
        idleTimeoutTimer.cancel();
        idleTimeoutTimer.purge();
        idleTimeoutTimer = null;
    }
}

[Buggy Hunk]
public void disconnect() {

[Patch]
public synchronized void disconnect() {