<commit_before>package controllers;

import java.io.ByteArrayInputStream;
import java.io.InputStream;

import org.apache.commons.io.output.ByteArrayOutputStream;
import org.apache.thrift.TProcessor;
import org.apache.thrift.protocol.TCompactProtocol;
import org.apache.thrift.protocol.TProtocol;
import org.apache.thrift.protocol.TProtocolFactory;
import org.apache.thrift.transport.TIOStreamTransport;
import org.apache.thrift.transport.TTransport;

import play.mvc.Controller;
import play.mvc.Http.RawBuffer;
import play.mvc.Http.RequestBody;
import play.mvc.Result;
import thrift.TQueueServiceImpl;
import util.Constants;

import com.github.btnguyen2k.queueserver.thrift.TQueueService;

public class ThriftController extends Controller {

    static TProtocolFactory protocolFactory = new TCompactProtocol.Factory();
    static TProcessor processor = new TQueueService.Processor<TQueueService.Iface>(
            TQueueServiceImpl.instance);

    public static Result doPost() throws Exception {
        RequestBody requestBody = request().body();
        byte[] requestContent = null;
        RawBuffer rawBuffer = requestBody.asRaw();
        if (rawBuffer != null) {
            requestContent = rawBuffer.asBytes();
        } else {
            requestContent = requestBody.asText().getBytes(Constants.UTF8);
        }

        InputStream in = new ByteArrayInputStream(requestContent);
        ByteArrayOutputStream out = new ByteArrayOutputStream();
        TTransport transport = new TIOStreamTransport(in, out);
        TProtocol inProtocol = protocolFactory.getProtocol(transport);
        TProtocol outProtocol = protocolFactory.getProtocol(transport);
        processor.process(inProtocol, outProtocol);
        response().setHeader(CONTENT_TYPE, "application/x-thrift");
        return ok(out.toByteArray());
    }
}
<commit_msg>Bug fix<commit_after>package controllers;

import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.InputStream;

import org.apache.thrift.TProcessor;
import org.apache.thrift.protocol.TCompactProtocol;
import org.apache.thrift.protocol.TProtocol;
import org.apache.thrift.protocol.TProtocolFactory;
import org.apache.thrift.transport.TIOStreamTransport;
import org.apache.thrift.transport.TTransport;

import play.mvc.Controller;
import play.mvc.Http.RawBuffer;
import play.mvc.Http.RequestBody;
import play.mvc.Result;
import thrift.TQueueServiceImpl;
import util.Constants;

import com.github.btnguyen2k.queueserver.thrift.TQueueService;

public class ThriftController extends Controller {

    static TProtocolFactory protocolFactory = new TCompactProtocol.Factory();
    static TProcessor processor = new TQueueService.Processor<TQueueService.Iface>(
            TQueueServiceImpl.instance);

    public static Result doPost() throws Exception {
        RequestBody requestBody = request().body();
        byte[] requestContent = null;
        RawBuffer rawBuffer = requestBody.asRaw();
        if (rawBuffer != null) {
            requestContent = rawBuffer.asBytes();
        } else {
            requestContent = requestBody.asText().getBytes(Constants.UTF8);
        }

        InputStream in = new ByteArrayInputStream(requestContent);
        ByteArrayOutputStream out = new ByteArrayOutputStream();
        TTransport transport = new TIOStreamTransport(in, out);
        TProtocol inProtocol = protocolFactory.getProtocol(transport);
        TProtocol outProtocol = protocolFactory.getProtocol(transport);
        processor.process(inProtocol, outProtocol);
        response().setHeader(CONTENT_TYPE, "application/x-thrift");
        return ok(out.toByteArray());
    }
}

{'fraction_non_alphanumeric': 0.09314394974050806, 'fraction_numerical': 0.0010925976509150504, 'mean_word_length': 4.1360448807854135, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4609718', 'n_tokens_mistral': 967, 'n_tokens_neox': 969, 'n_words': 197}