Program: 71801
Project: 71801
Buggy source:
/** 
 * Receives a message and/or handles a notification via this channel. <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 and an   {@link MessageInfo} is returned.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 to receive anothermessage/notification, otherwise, if  {@link HandlerResult#RETURN RETURN} is returnedthis 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> If a security manager has been installed then for each new association setup this method verifies that the associations source address and port number are permitted by the security manager's   {@link java.lang.SecurityManager#checkAccept(String,int) checkAccept} 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 buffer The buffer into which 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  {@code RETURN} after handlinga 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 NotYetBoundException If this channel is not yet bound
 * @throws IllegalReceiveException If the given handler invokes the  {@code receive} method of thischannel
 * @throws SecurityException If a security manager has been installed and it does not permit new associations to be accepted from the message's sender
 * @throws IOException If some other I/O error occurs
 */
public abstract <T>MessageInfo receive(ByteBuffer buffer,T attachment,NotificationHandler<T> handler) throws IOException ;

Fixed version (ground truth):
/** 
 * Receives a message and/or handles a notification via this channel. <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 and an   {@link MessageInfo} is returned.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 to receive anothermessage/notification, otherwise, if  {@link HandlerResult#RETURN RETURN} is returnedthis 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> If a security manager has been installed then for each new association setup this method verifies that the associations source address and port number are permitted by the security manager's   {@link java.lang.SecurityManager#checkAccept(String,int) checkAccept} 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 buffer The buffer into which 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  {@code RETURN} after handlinga 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 NotYetBoundException If this channel is not yet bound
 * @throws IllegalReceiveException If the given handler invokes the  {@code receive} method of thischannel
 * @throws SecurityException If a security manager has been installed and it does not permit new associations to be accepted from the message's sender
 * @throws IOException If some other I/O error occurs
 */
public abstract <T>MessageInfo receive(ByteBuffer buffer,T attachment,NotificationHandler<T> handler) throws IOException ;