#vulnerable code 
                                @Override
    public void doWrite(Query query) throws Exception {
        Socket socket = new Socket(host, port);

        DataOutputStream out = new DataOutputStream(
                socket.getOutputStream());

        BufferedReader inFromServer = new BufferedReader(new InputStreamReader(socket.getInputStream()));
        List<String> resultStrings = new LinkedList<String>();
        for (Result result : query.getResults()) {
            for(String resultString: resultParser(result)) {
                System.out.println(resultString);
                out.writeBytes(resultString + "\n");
            }
        }

        socket.close();
    } 
                            #location 8 
                            #vulnerability type RESOURCE_LEAK
#fixed code
                                @Override
    public void doWrite(Query query) throws Exception {
        Socket socket = new Socket(host, port);
        DataOutputStream out = new DataOutputStream(
                socket.getOutputStream());

        for (Result result : query.getResults()) {
            for(String resultString: resultParser(result)) {
                if (isDebugEnabled())
                    log.debug(resultString);
                out.writeBytes(resultString + "\n");
            }
        }

        socket.close();
    }