[Demonstration 1]

[Buggy Method]
@Override
public String runTransition(String idTransition, T valueObject, List<String> forcedActions, Map<String, Object> storage) throws IllegalStateException {
    EventManager eManager = getEvtManager();
    // Default EventManager
    if (null == eManager) {
        eManager = new Log4jEventManagerImpl();
    }
    if (null == valueObject) {
        throw new IllegalStateException("Value object must not be null");
    }
    String keyState = adapter.getState(valueObject);
    // Searching current state in transco
    if (null == keyState || !statesById.containsKey(keyState)) {
        throw new IllegalStateException("The transition is not applicable for the state " + ((null == keyState) ? "<null>" : keyState));
    }
    LifeCycleState<T> currentState = statesById.get(keyState);
    // Searching the current state's transitions
    Map<String, LifeCycleTransition<T>> transitionsById = currentState.getTransitionsById();
    // Searching the requested id of transition in the current state's
    // allowed transitions
    if (null == transitionsById || !transitionsById.containsKey(idTransition)) {
        throw new IllegalStateException("Unknown transition (" + idTransition + ") for state " + keyState);
    }
    LifeCycleTransition<T> transition = transitionsById.get(idTransition);
    String targetState = transition.changeState(valueObject, adapter, eManager, forcedActions, storage);
    // Change state (in database or other persistence support)
    if (null != targetState && !LifeCycleConstants.FALSE.equalsIgnoreCase(targetState)) {
        adapter.setState(valueObject, targetState);
        logChangeCustom(valueObject, idTransition, keyState, adapter, targetState);
    }
    return targetState;
}

[Buggy Hunk]
throw new IllegalStateException("The transition is not applicable for the state " + ((null == keyState) ? "<null>" : keyState));

[Patch]
throw new IllegalStateException("The transition " + idTransition + " is not applicable for the state " + ((null == keyState) ? "<null>" : keyState));

[Demonstration 2]

[Buggy Method]
private int[][] sortRadix(int[] radixIndexCount, LongArray dataCache, IntArray tracker, int threads) {
    int[][] rangeParams = new int[threads][2];
    int[] bucketRange = new int[threads];
    sortBuckets = new long[threads][2];
    long dataCacheSize = dataCache.highestSetIndex() + 1;
    int bucketSize = (int) (dataCacheSize / threads);
    int count = 0, fullCount = 0 + 0;
    rangeParams[0][0] = 0;
    bucketRange[0] = 0;
    for (int i = 0, threadIndex = 0; i < radixIndexCount.length && threadIndex < threads; i++) {
        if ((count + radixIndexCount[i]) > bucketSize) {
            bucketRange[threadIndex] = i - 1;
            rangeParams[threadIndex + 1][0] = fullCount;
            rangeParams[threadIndex][1] = count;
            count = 0;
            threadIndex++;
        }
        if (threadIndex == threads - 1) {
            bucketRange[threadIndex] = radixIndexCount.length;
            rangeParams[threadIndex][1] = (int) dataCacheSize - fullCount;
            break;
        } else {
            count += radixIndexCount[i];
            fullCount += radixIndexCount[i];
        }
    }
    int[] bucketIndex = new int[threads];
    for (int i = 0; i < threads; i++) {
        bucketIndex[i] = 0;
    }
    for (long i = 0; i < dataCacheSize; i++) {
        int rIndex = getRadix(dataCache.get(i));
        for (int k = 0; k < threads; k++) {
            //if ( rangeParams[k][0] >= rIndex )
            if (rIndex <= bucketRange[k]) {
                long temp = (rangeParams[k][0] + bucketIndex[k]++);
                long temp1 = tracker.get(temp);
                if (temp1 != -1) {
                    System.out.println("error in init of tracker");
                }
                tracker.set(temp, (int) i);
                if (bucketIndex[k] == rangeParams[k][1]) {
                    sortBuckets[k][0] = bucketRange[k];
                    sortBuckets[k][1] = rangeParams[k][0];
                }
                break;
            }
        }
    }
    return rangeParams;
}

[Buggy Hunk]
int rIndex = getRadix( dataCache.get( i ) );

[Patch]
int rIndex = radixOf( dataCache.get( i ) );

[Demonstration 3]

[Buggy Method]
private ResourceInfo validateHTTPMethod(List<ResourceInfo> resources, CarbonMessage carbonMessage) {
    ResourceInfo resource = null;
    String httpMethod = (String) carbonMessage.getProperty(Constants.HTTP_METHOD);
    for (ResourceInfo resourceInfo : resources) {
        if (DispatcherUtil.isMatchingMethodExist(resourceInfo, httpMethod)) {
            resource = resourceInfo;
            break;
        }
    }
    if (resource == null) {
        resource = tryMatchingToDefaultVerb(httpMethod);
    }
    if (resource == null) {
        carbonMessage.setProperty(Constants.HTTP_STATUS_CODE, 405);
        throw new BallerinaException();
    }
    return resource;
}

[Buggy Hunk]
throw new BallerinaException();

[Patch]
throw new BallerinaException("Method not allowed");