<commit_before>package backtype.storm.messaging;

import java.nio.ByteBuffer;

public class TaskMessage {
    private int _task;
    private byte[] _message;
    
    public TaskMessage(int task, byte[] message) {
        _task = task;
        _message = message;
    }
    
    public int task() {
        return _task;
    }

    public byte[] message() {
        return _message;
    }
    
    public ByteBuffer serialize() {
        ByteBuffer bb = ByteBuffer.allocate(_message.length+2);
        bb.putShort((short)_task);
        bb.put(_message);
        return bb;
    }
    
    public void deserialize(ByteBuffer packet) {
        if (packet==null) return;
        _task = packet.getShort();
        _message = new byte[packet.limit()-2];
        packet.get(_message);
    }

}<commit_msg>TaskMessage enhanced to enable null payload<commit_after>package backtype.storm.messaging;

import java.nio.ByteBuffer;

public class TaskMessage {
    final int SHORT_SIZE = 2;
    final int INT_SIZE = 4;    
    private int _task;
    private byte[] _message;
    
    public TaskMessage(int task, byte[] message) {
        _task = task;
        _message = message;
    }
    
    public int task() {
        return _task;
    }

    public byte[] message() {
        return _message;
    }
    
    public ByteBuffer serialize() {
        ByteBuffer bb = ByteBuffer.allocate(_message.length+SHORT_SIZE+INT_SIZE);
        bb.putShort((short)_task);
        if (_message==null) 
            bb.putInt(0);
        else {
            bb.putInt(_message.length);
            bb.put(_message);
        }
        return bb;
    }
    
    public void deserialize(ByteBuffer packet) {
        if (packet==null) return;
        _task = packet.getShort();
        int len = packet.getInt();
        if (len ==0) 
            _message = null; 
        else {
            _message = new byte[len];
            packet.get(_message);
        }
    }

    public String toString() {
        StringBuffer buf = new StringBuffer();
        buf.append("task:");
        buf.append(_task);
        buf.append(" message size:");
        if (_message!=null) buf.append(_message.length);
        else buf.append(0);
        return buf.toString();
    }
}
{'fraction_non_alphanumeric': 0.10917225950782998, 'fraction_numerical': 0.003131991051454139, 'mean_word_length': 1.9734042553191489, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '3225965', 'n_tokens_mistral': 667, 'n_tokens_neox': 644, 'n_words': 156}