Buggy code:
private int [ ] markStack = new int [ DDMWriter . MAX_MARKS_NESTING ] ; private int top ; private CcsidManager ccsidManager ; private DRDAConnThread agent ; private int dssLengthLocation ; private int correlationID ; private int nextCorrelationID ; private boolean isDRDAProtocol ; private DssTrace dssTrace ; private int prevHdrLocation ; private int previousCorrId ; private byte previousChainByte ; private boolean isContinuationDss ; private int lastDSSBeforeMark ; private final CharsetEncoder encoder ; DDMWriter ( CcsidManager ccsidManager , DRDAConnThread agent , DssTrace dssTrace ) { } protected void reset ( DssTrace dssTrace ) { } protected void setCMDProtocol ( ) { } protected void createDssReply ( ) { } protected void createDssRequest ( ) { } protected void createDssObject ( ) { } private void markDssAsContinued ( boolean forLob ) { } protected void endDss ( byte chainByte ) { } protected void endDss ( ) { } private void endDss ( boolean finalizeLength ) { } protected void endDdmAndDss ( ) { } protected byte [ ] copyDSSDataToEnd ( int start ) { } protected void startDdm ( int codePoint ) { } protected void clearDdm ( ) { } protected void clearBuffer ( ) { } protected void endDdm ( ) { } protected int getDSSLength ( ) { } protected void truncateDSS ( int value ) { } protected void writeByte ( int value ) { } protected void writeNetworkShort ( int value ) { } protected void writeNetworkInt ( int value ) { } protected void writeBytes ( byte [ ] buf , int length ) { } protected void writeBytes ( byte [ ] buf , int start , int length ) { } protected void writeBytes ( byte [ ] buf ) { } protected void writeLDBytes ( byte [ ] buf ) { } protected void writeLDBytes ( byte [ ] buf , int index ) { } void writeCodePoint4Bytes ( int codePoint , int value ) { } void writeScalar1Byte ( int codePoint , int value ) { } protected void writeScalar2Bytes ( int codePoint , int value ) { } protected void writeScalar2Bytes ( int value ) { } protected void startDdm ( int length , int codePoint ) { } protected void writeScalarBytes ( int codePoint , byte [ ] buf , int length ) { } protected void writeScalarStream ( boolean chainedWithSameCorrelator , int codePoint , EXTDTAInputStream in , boolean writeNullByte ) throws DRDAProtocolException { int spareDssLength = prepScalarStream ( chainedWithSameCorrelator , codePoint , writeNullByte ) ; int bytesRead = 0 ; int totalBytesRead = 0 ; try { OutputStream out = DDMWriter . placeLayerBStreamingBuffer ( agent . getOutputStream ( ) ) ; boolean isLastSegment = false ; while ( ! isLastSegment ) { int spareBufferLength = buffer . remaining ( ) ; if ( SanityManager . DEBUG ) { if ( PropertyUtil . getSystemBoolean ( "derby.debug.suicideOfLayerBStreaming" ) ) throw new IOException ( ) ; } final int offset = buffer . position ( ) ; bytesRead = in . read ( bytes , offset , Math . min ( spareDssLength , spareBufferLength ) ) ; totalBytesRead += bytesRead ; buffer . position ( ( offset + bytesRead ) ) ; spareDssLength -= bytesRead ; spareBufferLength -= bytesRead ; isLastSegment = ( DDMWriter . peekStream ( in ) ) < 0 ; if ( isLastSegment || ( spareDssLength == 0 ) ) { flushScalarStreamSegment ( isLastSegment , out ) ; if ( ! isLastSegment ) spareDssLength = ( DssConstants . MAX_DSS_LENGTH ) - 2 ; } } out . flush ( ) ; } catch ( IOException e ) { <START_BUG> agent . markCommunicationsFailure ( "DDMWriter.writeScalarStream()" , "" , e . getMessage ( ) , "*" ) ; <END_BUG> } } private void beginDss ( boolean chainedToNextStructure , int dssType ) { } private int prepScalarStream ( boolean chainedWithSameCorrelator , int codePoint , boolean writeNullByte ) throws DRDAProtocolException { } protected boolean doesRequestContainData ( ) { } private void flushScalarStreamSegment ( boolean lastSegment , OutputStream out ) throws DRDAProtocolException { } void writeLengthCodePoint ( int length , int codePoint ) { } protected void writeScalarHeader ( int codePoint , int dataLength ) { } void writeScalarString ( int codePoint , String string ) { } void writeScalarPaddedString ( int codePoint , String string , int paddedLength ) { } protected void writeScalarPaddedString ( String string , int paddedLength ) { } protected void writeScalarPaddedString ( DRDAString drdaString , int paddedLength ) { } protected void writeScalarPaddedBytes ( int codePoint , byte [ ] buf , int paddedLength , byte padByte ) { } protected void writeScalarPaddedBytes ( byte [ ] buf , int paddedLength , byte padByte ) { } protected void writeScalarBytes ( int codePoint , byte [ ] buf ) { } protected void writeScalarBytes ( int codePoint , byte [ ] buf , int start , int length ) { } protected void writeShort ( int v ) { } protected void writeShort ( boolean b ) { } protected void writeInt ( int v ) { } protected void writeLong ( long v ) { } protected void writeFloat ( float v ) { } protected void writeDouble ( double v ) { } protected void writeBigDecimal ( BigDecimal v , int precision , int scale ) throws SQLException { } protected void writeBoolean ( boolean v ) { } protected void writeLDString ( String s ) throws DRDAProtocolException { } private int maxEncodedLength ( String s ) { } protected void writeLDString ( String s , int index ) throws DRDAProtocolException { } protected void writeString ( String s ) throws DRDAProtocolException { } protected void padBytes ( byte val , int length ) { } protected void flush ( ) throws IOException { } protected void flush ( OutputStream socketOutputStream ) throws IOException { } private void beginDss ( int dssType , boolean ensureLen ) { } private void finalizeDssLength ( ) { } protected void writeExtendedLength ( long size ) { }

Fix:
agent . markCommunicationsFailure ( e , "DDMWriter.writeScalarStream()" , "" , e . getMessage ( ) , "*" ) ;