@@ -72,14 +72,17 @@ class BlobWriteChannelImpl implements BlobWriteChannel {
72
72
73
73
@ Override
74
74
public RestorableState <BlobWriteChannel > save () {
75
+ byte [] bufferToSave = null ;
75
76
if (isOpen ) {
76
77
flush ();
78
+ bufferToSave = Arrays .copyOf (buffer , limit );
77
79
}
78
80
return StateImpl .builder (options , blobInfo , uploadId )
79
81
.position (position )
80
- .buffer (Arrays . copyOf ( buffer , limit ) )
82
+ .buffer (bufferToSave )
81
83
.isOpen (isOpen )
82
- .chunkSize (chunkSize ).build ();
84
+ .chunkSize (chunkSize )
85
+ .build ();
83
86
}
84
87
85
88
private void flush () {
@@ -164,7 +167,6 @@ static class StateImpl implements RestorableState<BlobWriteChannel>, Serializabl
164
167
private final String uploadId ;
165
168
private final int position ;
166
169
private final byte [] buffer ;
167
- private final int limit ;
168
170
private final boolean isOpen ;
169
171
private final int chunkSize ;
170
172
@@ -174,7 +176,6 @@ static class StateImpl implements RestorableState<BlobWriteChannel>, Serializabl
174
176
this .uploadId = builder .uploadId ;
175
177
this .position = builder .position ;
176
178
this .buffer = builder .buffer ;
177
- this .limit = this .buffer .length ;
178
179
this .isOpen = builder .isOpen ;
179
180
this .chunkSize = builder .chunkSize ;
180
181
}
@@ -185,7 +186,6 @@ static class Builder {
185
186
private final String uploadId ;
186
187
private int position ;
187
188
private byte [] buffer ;
188
- private int limit ;
189
189
private boolean isOpen ;
190
190
private int chunkSize ;
191
191
@@ -229,15 +229,15 @@ public BlobWriteChannel restore() {
229
229
BlobWriteChannelImpl channel = new BlobWriteChannelImpl (serviceOptions , blobInfo , uploadId );
230
230
channel .position = position ;
231
231
channel .buffer = buffer .clone ();
232
- channel .limit = limit ;
232
+ channel .limit = buffer . length ;
233
233
channel .isOpen = isOpen ;
234
234
channel .chunkSize = chunkSize ;
235
235
return channel ;
236
236
}
237
237
238
238
@ Override
239
239
public int hashCode () {
240
- return Objects .hash (serviceOptions , blobInfo , uploadId , position , limit , isOpen , chunkSize ,
240
+ return Objects .hash (serviceOptions , blobInfo , uploadId , position , isOpen , chunkSize ,
241
241
Arrays .hashCode (buffer ));
242
242
}
243
243
@@ -250,14 +250,13 @@ public boolean equals(Object obj) {
250
250
return false ;
251
251
}
252
252
final StateImpl other = (StateImpl ) obj ;
253
- return Objects .equals (this .serviceOptions , other .serviceOptions ) &&
254
- Objects .equals (this .blobInfo , other .blobInfo ) &&
255
- Objects .equals (this .uploadId , other .uploadId ) &&
256
- Objects .deepEquals (this .buffer , other .buffer ) &&
257
- this .position == other .position &&
258
- this .limit == other .limit &&
259
- this .isOpen == other .isOpen &&
260
- this .chunkSize == other .chunkSize ;
253
+ return Objects .equals (this .serviceOptions , other .serviceOptions )
254
+ && Objects .equals (this .blobInfo , other .blobInfo )
255
+ && Objects .equals (this .uploadId , other .uploadId )
256
+ && Objects .deepEquals (this .buffer , other .buffer )
257
+ && this .position == other .position
258
+ && this .isOpen == other .isOpen
259
+ && this .chunkSize == other .chunkSize ;
261
260
}
262
261
263
262
@ Override
0 commit comments