#fixed code
                             void send(int code, MessageLite req) throws IOException {
		int len = req.getSerializedSize();
		dout.writeInt(len + 1);
		dout.write(code);
		req.writeTo(dout);
		dout.flush();
	}
#vulnerable code 
                             byte[] receive(int code) throws IOException {
		int len = din.readInt();
		int get_code = din.read();

		byte[] data = null;
        if (len > 1) {
            data = new byte[len - 1];
            din.readFully(data);
        }

        if (get_code == RiakClient.MSG_ErrorResp) {
            RpbErrorResp err = com.basho.riak.pbc.RPB.RpbErrorResp.parseFrom(data);
            throw new RiakError(err);
        }

		if (code != get_code) {
            throw new IOException("bad message code. Expected: " + code + " actual: " + get_code);
        }

		return data;
	} 
                            #location 8 
                            #vulnerability type THREAD_SAFETY_VIOLATION