Program: 79039
Project: 79039
Buggy source:
/** 
 * Receives a message into the given buffer and/or handles a notification. <P> If a message or notification is immediately available, or if this channel is in blocking mode and one eventually becomes available, then the message or notification is returned or handled, respectively. If this channel is in non-blocking mode and a message or notification is not immediately available then this method immediately returns   {@code null}. <P> If this method receives a message it is copied into the given byte buffer. The message is transferred into the given byte buffer starting at its current position and the buffers position is incremented by the number of bytes read. If there are fewer bytes remaining in the buffer than are required to hold the message, or the underlying input buffer does not contain the complete message, then an invocation of   {@link MessageInfo#isComplete isComplete} on the returned {@code MessageInfo} will return {@code false}, and more invocations of this method will be necessary to completely consume the messgae. Only one message at a time will be partially delivered in any stream. The socket option   {@link SctpStandardSocketOptions#SCTP_FRAGMENT_INTERLEAVE SCTP_FRAGMENT_INTERLEAVE} controls various aspects of what interlacing ofmessages occurs. <P> If this method receives a notification then the appropriate method of the given handler, if there is one, is invoked. If the handler returns {@link HandlerResult#CONTINUE CONTINUE} then this method will try toreceive another message/notification, otherwise, if  {@link HandlerResult#RETURN RETURN} is returned this method will return {@code null}. If an uncaught exception is thrown by the handler it will be propagated up the stack through this method. <P> This method may be invoked at any time. If another thread has already initiated a receive operation upon this channel, then an invocation of this method will block until the first operation is complete. The given handler is invoked without holding any locks used to enforce the above synchronization policy, that way handlers will not stall other threads from receiving. A handler should not invoke the   {@code receive} method of this channel, if it does an{@link IllegalReceiveException} will be thrown.
 * @param dst The buffer into which message bytes are to be transferred
 * @param attachment The object to attach to the receive operation; can be {@code null}
 * @param handler A handler to handle notifications from the SCTP stack, or  {@code null} to ignore any notifications.
 * @return  The {@code MessageInfo},   {@code null} if this channel is innon-blocking mode and no messages are immediately available or the notification handler returns  {@link HandlerResult#RETURN RETURN} after handling a notification
 * @throws java.nio.channels.ClosedChannelException If this channel is closed
 * @throws java.nio.channels.AsynchronousCloseException If another thread closes this channel while the read operation is in progress
 * @throws java.nio.channels.ClosedByInterruptException If another thread interrupts the current thread while the read operation is in progress, thereby closing the channel and setting the current thread's interrupt status
 * @throws java.nio.channels.NotYetConnectedException If this channel is not yet connected
 * @throws IllegalReceiveException If the given handler invokes the  {@code receive} method of thischannel
 * @throws IOException If some other I/O error occurs
 */
public abstract <T>MessageInfo receive(ByteBuffer dst,T attachment,NotificationHandler<T> handler) throws IOException ;

Fixed version (ground truth):
/** 
 * Receives a message into the given buffer and/or handles a notification. <P> If a message or notification is immediately available, or if this channel is in blocking mode and one eventually becomes available, then the message or notification is returned or handled, respectively. If this channel is in non-blocking mode and a message or notification is not immediately available then this method immediately returns   {@code null}. <P> If this method receives a message it is copied into the given byte buffer. The message is transferred into the given byte buffer starting at its current position and the buffers position is incremented by the number of bytes read. If there are fewer bytes remaining in the buffer than are required to hold the message, or the underlying input buffer does not contain the complete message, then an invocation of   {@link MessageInfo#isComplete isComplete} on the returned {@code MessageInfo} will return {@code false}, and more invocations of this method will be necessary to completely consume the messgae. Only one message at a time will be partially delivered in any stream. The socket option   {@link SctpStandardSocketOptions#SCTP_FRAGMENT_INTERLEAVE SCTP_FRAGMENT_INTERLEAVE} controls various aspects of what interlacing ofmessages occurs. <P> If this method receives a notification then the appropriate method of the given handler, if there is one, is invoked. If the handler returns {@link HandlerResult#CONTINUE CONTINUE} then this method will try toreceive another message/notification, otherwise, if  {@link HandlerResult#RETURN RETURN} is returned this method will return {@code null}. If an uncaught exception is thrown by the handler it will be propagated up the stack through this method. <P> This method may be invoked at any time. If another thread has already initiated a receive operation upon this channel, then an invocation of this method will block until the first operation is complete. The given handler is invoked without holding any locks used to enforce the above synchronization policy, that way handlers will not stall other threads from receiving. A handler should not invoke the   {@code receive} method of this channel, if it does an{@link IllegalReceiveException} will be thrown.
 * @param < T > The type of the attachment
 * @param dst The buffer into which message bytes are to be transferred
 * @param attachment The object to attach to the receive operation; can be {@code null}
 * @param handler A handler to handle notifications from the SCTP stack, or  {@code null} to ignore any notifications.
 * @return  The {@code MessageInfo},   {@code null} if this channel is innon-blocking mode and no messages are immediately available or the notification handler returns  {@link HandlerResult#RETURN RETURN} after handling a notification
 * @throws java.nio.channels.ClosedChannelException If this channel is closed
 * @throws java.nio.channels.AsynchronousCloseException If another thread closes this channel while the read operation is in progress
 * @throws java.nio.channels.ClosedByInterruptException If another thread interrupts the current thread while the read operation is in progress, thereby closing the channel and setting the current thread's interrupt status
 * @throws java.nio.channels.NotYetConnectedException If this channel is not yet connected
 * @throws IllegalReceiveException If the given handler invokes the  {@code receive} method of thischannel
 * @throws IOException If some other I/O error occurs
 */
public abstract <T>MessageInfo receive(ByteBuffer dst,T attachment,NotificationHandler<T> handler) throws IOException ;