@@ -1159,23 +1159,22 @@ protected void hookOnComplete() {
1159
1159
1160
1160
@ Override
1161
1161
public void completed (Integer written , Attachment attachment ) {
1162
- this . writing . set ( false );
1163
- attachment . iterator () .close ();
1162
+ DataBuffer . ByteBufferIterator iterator = attachment . iterator ( );
1163
+ iterator .close ();
1164
1164
1165
1165
long pos = this .position .addAndGet (written );
1166
1166
ByteBuffer byteBuffer = attachment .byteBuffer ();
1167
- DataBuffer . ByteBufferIterator iterator = attachment . iterator ();
1167
+
1168
1168
if (byteBuffer .hasRemaining ()) {
1169
- this .writing .set (true );
1170
1169
this .channel .write (byteBuffer , pos , attachment , this );
1171
1170
}
1172
1171
else if (iterator .hasNext ()) {
1173
1172
ByteBuffer next = iterator .next ();
1174
- this .writing .set (true );
1175
1173
this .channel .write (next , pos , attachment , this );
1176
1174
}
1177
1175
else {
1178
- sinkDataBuffer (attachment .dataBuffer ());
1176
+ this .sink .next (attachment .dataBuffer ());
1177
+ this .writing .set (false );
1179
1178
1180
1179
Throwable throwable = this .error .get ();
1181
1180
if (throwable != null ) {
@@ -1192,15 +1191,12 @@ else if (this.completed.get()) {
1192
1191
1193
1192
@ Override
1194
1193
public void failed (Throwable exc , Attachment attachment ) {
1195
- this .writing .set (false );
1196
1194
attachment .iterator ().close ();
1197
1195
1198
- sinkDataBuffer (attachment .dataBuffer ());
1199
- this .sink .error (exc );
1200
- }
1196
+ this .sink .next (attachment .dataBuffer ());
1197
+ this .writing .set (false );
1201
1198
1202
- private void sinkDataBuffer (DataBuffer dataBuffer ) {
1203
- this .sink .next (dataBuffer );
1199
+ this .sink .error (exc );
1204
1200
}
1205
1201
1206
1202
@ Override
0 commit comments