[Demonstration 1]

[Buggy Method]
private void init(String host, int port) {
    IOMode ioMode = IOMode.valueOf(transportConf.ioMode());
    EventLoopGroup bossGroup = NettyUtil.createEventLoop(ioMode, transportConf.serverThread(), transportConf.getModuleName() + "-server");
    EventLoopGroup workerGroup = bossGroup;
    PooledByteBufAllocator allocator = NettyUtil.createPooledByteBufAllocator(transportConf.preferDirectBuf(), true, transportConf.serverThread());
    bootstrap = new ServerBootstrap().group(bossGroup, workerGroup).channel(NettyUtil.getServerChannelClass(ioMode)).option(ChannelOption.ALLOCATOR, allocator).childOption(ChannelOption.ALLOCATOR, allocator);
    if (transportConf.backLog() > 0) {
        bootstrap.option(ChannelOption.SO_BACKLOG, transportConf.backLog());
    }
    if (transportConf.receiveBuf() > 0) {
        bootstrap.childOption(ChannelOption.SO_RCVBUF, transportConf.receiveBuf());
    }
    if (transportConf.sendBuf() > 0) {
        bootstrap.childOption(ChannelOption.SO_SNDBUF, transportConf.sendBuf());
    }
    bootstrap.childHandler(new ChannelInitializer<SocketChannel>() {

        @Override
        protected void initChannel(SocketChannel ch) throws Exception {
            RpcHandler handler = rpcHandler;
            for (TransportServerBootstrap boot : bootstraps) {
                handler = boot.doBootstrap(ch, handler);
            }
            transportContext.initChannelPipeline(ch, handler);
        }
    });
    InetSocketAddress address = host == null ? new InetSocketAddress(port) : new InetSocketAddress(host, port);
    channelFuture = bootstrap.bind(address);
    channelFuture.syncUninterruptibly();
    this.port = ((InetSocketAddress) (channelFuture.channel().localAddress())).getPort();
    log.debug("server started at port:" + port);
}

[Buggy Hunk]
log.debug("server started at port:" + port);

[Patch]
log.debug("server started at port:" + this.port);

[Demonstration 2]

[Buggy Method]
public boolean isEventAvailable(HybridThread hybridThread) {
    if (this.state.compareAndSet(0, 1)) {
        this.numberThreads.incrementAndGet();
        setMainHybridThread(hybridThread);
        return true;
    } else if (this.state.get() != 2 && this.numberThreads.get() < this.numberThreads.accumulateAndGet(1, (a, b) -> a < 16 ? a + b : a)) {
        //value -> value < 16 ? 1 : value)) {
        // Update number threads atomically, but only if the current value is less than 16
        return true;
    }
    return false;
}

[Buggy Hunk]
if(this.state.get() != 2 && this.numberThreads.get() < this.numberThreads.accumulateAndGet(1, (a,b) -> a < 16 ? a+b : a)) {

[Patch]
if(this.state.get() != 2 && this.numberThreads.get() < this.numberThreads.accumulateAndGet(1, (a,b) -> a < 8 ? a+b : a)) {

[Demonstration 3]

[Buggy Method]
@Override
public void doBeforeTransactionCompletion(SessionImplementor session) {
    if (workUnits.size() == 0 && undoQueue.size() == 0) {
        return;
    }
    if (!session.getTransactionCoordinator().isActive()) {
        log.debug("Skipping envers transaction hook due to non-active (most likely marked-rollback-only) transaction");
        return;
    }
    // see: http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4178431
    if (FlushModeType.COMMIT.equals(session.getFlushMode()) || session.isClosed()) {
        Session temporarySession = null;
        try {
            temporarySession = session.sessionWithOptions().connection().autoClose(false).connectionHandlingMode(PhysicalConnectionHandlingMode.DELAYED_ACQUISITION_AND_RELEASE_AFTER_TRANSACTION).openSession();
            executeInSession(temporarySession);
            temporarySession.flush();
        } finally {
            if (temporarySession != null) {
                temporarySession.close();
            }
        }
    } else {
        executeInSession(session);
        // Explicitly flushing the session, as the auto-flush may have already happened.
        session.flush();
    }
}

[Buggy Hunk]
if ( FlushModeType.COMMIT.equals( session.getFlushMode() ) || session.isClosed() ) {

[Patch]
if ( FlushMode.MANUAL.equals( session.getHibernateFlushMode() ) || session.isClosed() ) {