[Demonstration 1]

[Buggy Method]
private JSONArray photoTominimizeInfoArray(Collection list) throws JSONException {
    JSONArray Photos = new JSONArray();
    for (Object o : list) {
        Photo p = (Photo) o;
        if (p.getIdApiServices().isEmpty())
            continue;
        JSONObject jsonPhoto = new JSONObject();
        jsonPhoto.put("idApi", p.getIdApiServices());
        jsonPhoto.put("ApiType", p.getApiServiceType());
        jsonPhoto.put("id", p.getId());
        jsonPhoto.put("likes", p.getLikes());
        Photos.put(jsonPhoto);
    }
    return Photos;
}

[Buggy Hunk]
if(p.getIdApiServices().isEmpty())

[Patch]
if(p.getIdApiServices()==null)

[Demonstration 2]

[Buggy Method]
private void generateSources() {
    if (!environment.getOptionBooleanValue(OPTION_CACHE_FILES_IN_PROCESS))
        return;
    if (!FileDetails.preGenerateSources.isEmpty()) {
        //Wait for any previous instruction to write sources
        int preGenerateWaitTimeout = 60000;
        while (getExternalCacheGenerate().exists() && preGenerateWaitTimeout > 0) {
            try {
                Thread.sleep(10);
                preGenerateWaitTimeout -= 10;
            } catch (InterruptedException e) {
            }
        }
        if (preGenerateWaitTimeout <= 0) {
            LOGGER.error("An error ocurred while caching in different process. " + "\"" + getExternalCacheGenerate().getAbsolutePath() + "\" file was not removed.");
            getExternalCacheGenerate().delete();
            return;
        }
        //Run the written in background
        cacheExecutor.execute(new Runnable() {

            @Override
            public void run() {
                //Write the preGenerate file with the sources to write
                Output output = null;
                try {
                    Kryo kryo = getKryo();
                    output = new Output(new FileOutputStream(getExternalCacheGenerate()), 8192);
                    kryo.writeObject(output, FileDetails.preGenerateSources, new MapSerializer());
                    startDeclexServiceWith("generate");
                    FileDetails.preGenerateSources.clear();
                } catch (Exception e) {
                    LOGGER.error("An error ocurred while caching in different process: " + e.getMessage());
                } finally {
                    if (output != null) {
                        output.close();
                    }
                }
            }
        });
    }
}

[Buggy Hunk]
if (!FileDetails.preGenerateSources.isEmpty()) {

[Patch]
if (isCacheFilesEnabled() && !FileDetails.preGenerateSources.isEmpty()) {

[Demonstration 3]

[Buggy Method]
public int ff_h264_alloc_tables() {
    int big_mb_num = s.mb_stride * (s.mb_height + 1);
    int row_mb_num = 2 * s.mb_stride * s.thread_count;
    int x, y;
    //FF_ALLOCZ_OR_GOTO(this.s.avctx, this.intra4x4_pred_mode, row_mb_num * 8  * sizeof(uint8_t), fail)
    this.intra4x4_pred_mode = new int[row_mb_num * 8];
    //FF_ALLOCZ_OR_GOTO(this.s.avctx, this.non_zero_count    , big_mb_num * 32 * sizeof(uint8_t), fail)
    this.non_zero_count = new int[big_mb_num][32];
    //FF_ALLOCZ_OR_GOTO(this.s.avctx, this.slice_table_base  , (big_mb_num+s.mb_stride) * sizeof(*this.slice_table_base), fail)
    this.slice_table_base = new int[big_mb_num + s.mb_stride];
    //FF_ALLOCZ_OR_GOTO(this.s.avctx, this.cbp_table, big_mb_num * sizeof(uint16_t), fail)
    this.cbp_table = new int[big_mb_num];
    //FF_ALLOCZ_OR_GOTO(this.s.avctx, this.chroma_pred_mode_table, big_mb_num * sizeof(uint8_t), fail)
    this.chroma_pred_mode_table = new int[big_mb_num];
    //FF_ALLOCZ_OR_GOTO(this.s.avctx, this.mvd_table[0], 16*row_mb_num * sizeof(uint8_t), fail);
    this.mvd_table[0] = new int[8 * row_mb_num][2];
    //FF_ALLOCZ_OR_GOTO(this.s.avctx, this.mvd_table[1], 16*row_mb_num * sizeof(uint8_t), fail);
    this.mvd_table[1] = new int[8 * row_mb_num][2];
    //FF_ALLOCZ_OR_GOTO(this.s.avctx, this.direct_table, 4*big_mb_num * sizeof(uint8_t) , fail);
    this.direct_table = new int[4 * big_mb_num];
    //FF_ALLOCZ_OR_GOTO(this.s.avctx, this.list_counts, big_mb_num * sizeof(uint8_t), fail)
    this.list_counts = new int[big_mb_num];
    Arrays.fill(this.slice_table_base, -1);
    //memset(this.slice_table_base, -1, (big_mb_num+s.mb_stride)  * sizeof(*this.slice_table_base));
    this.slice_table_offset = s.mb_stride * 2 + 1;
    //FF_ALLOCZ_OR_GOTO(this.s.avctx, this.mb2b_xy  , big_mb_num * sizeof(uint32_t), fail);
    //FF_ALLOCZ_OR_GOTO(this.s.avctx, this.mb2br_xy , big_mb_num * sizeof(uint32_t), fail);
    mb2b_xy = new long[big_mb_num];
    mb2br_xy = new long[big_mb_num];
    for (y = 0; y < s.mb_height; y++) {
        for (x = 0; x < s.mb_width; x++) {
            int mb_xy = x + y * s.mb_stride;
            int b_xy = 4 * x + 4 * y * this.b_stride;
            this.mb2b_xy[mb_xy] = b_xy;
            this.mb2br_xy[mb_xy] = 8 * (mb_xy % (2 * s.mb_stride));
        }
    }
    s.obmc_scratchpad = null;
    if (null == this.dequant4_coeff[0])
        this.init_dequant_tables();
    return 0;
}

[Buggy Hunk]
Arrays.fill(this.slice_table_base, -1);

[Patch]
Arrays.fill(this.slice_table_base, 0xFFFF);