Skip to content

Commit b6988af

Browse files
committed
---
yaml --- r: 1059 b: refs/heads/master c: 2060526 h: refs/heads/master i: 1057: 84befb0 1055: 28daa1e v: v3
1 parent e4421cd commit b6988af

3 files changed

Lines changed: 22 additions & 23 deletions

File tree

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
---
2-
refs/heads/master: 71604bba52031a8609b682903ada37943f158b1b
2+
refs/heads/master: 2060526a1469fbbf6a492594ac3dc66d06aaa51c
33
refs/heads/travis: 0fa997e2fc9c6b61b2d91e6d163655aae67d44b6
44
refs/heads/gh-pages: 5a10432ecc75f29812e33a8236c900379509fe99

trunk/gcloud-java-storage/src/main/java/com/google/gcloud/storage/BlobReadChannelImpl.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -237,13 +237,13 @@ public boolean equals(Object obj) {
237237
return false;
238238
}
239239
final StateImpl other = (StateImpl) obj;
240-
return Objects.equals(this.serviceOptions, other.serviceOptions) &&
241-
Objects.equals(this.blob, other.blob) &&
242-
Objects.equals(this.requestOptions, other.requestOptions) &&
243-
this.position == other.position &&
244-
this.isOpen == other.isOpen &&
245-
this.endOfStream == other.endOfStream &&
246-
this.chunkSize == other.chunkSize;
240+
return Objects.equals(this.serviceOptions, other.serviceOptions)
241+
&& Objects.equals(this.blob, other.blob)
242+
&& Objects.equals(this.requestOptions, other.requestOptions)
243+
&& this.position == other.position
244+
&& this.isOpen == other.isOpen
245+
&& this.endOfStream == other.endOfStream
246+
&& this.chunkSize == other.chunkSize;
247247
}
248248

249249
@Override

trunk/gcloud-java-storage/src/main/java/com/google/gcloud/storage/BlobWriteChannelImpl.java

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -72,14 +72,17 @@ class BlobWriteChannelImpl implements BlobWriteChannel {
7272

7373
@Override
7474
public RestorableState<BlobWriteChannel> save() {
75+
byte[] bufferToSave = null;
7576
if (isOpen) {
7677
flush();
78+
bufferToSave = Arrays.copyOf(buffer, limit);
7779
}
7880
return StateImpl.builder(options, blobInfo, uploadId)
7981
.position(position)
80-
.buffer(Arrays.copyOf(buffer, limit))
82+
.buffer(bufferToSave)
8183
.isOpen(isOpen)
82-
.chunkSize(chunkSize).build();
84+
.chunkSize(chunkSize)
85+
.build();
8386
}
8487

8588
private void flush() {
@@ -164,7 +167,6 @@ static class StateImpl implements RestorableState<BlobWriteChannel>, Serializabl
164167
private final String uploadId;
165168
private final int position;
166169
private final byte[] buffer;
167-
private final int limit;
168170
private final boolean isOpen;
169171
private final int chunkSize;
170172

@@ -174,7 +176,6 @@ static class StateImpl implements RestorableState<BlobWriteChannel>, Serializabl
174176
this.uploadId = builder.uploadId;
175177
this.position = builder.position;
176178
this.buffer = builder.buffer;
177-
this.limit = this.buffer.length;
178179
this.isOpen = builder.isOpen;
179180
this.chunkSize = builder.chunkSize;
180181
}
@@ -185,7 +186,6 @@ static class Builder {
185186
private final String uploadId;
186187
private int position;
187188
private byte[] buffer;
188-
private int limit;
189189
private boolean isOpen;
190190
private int chunkSize;
191191

@@ -229,15 +229,15 @@ public BlobWriteChannel restore() {
229229
BlobWriteChannelImpl channel = new BlobWriteChannelImpl(serviceOptions, blobInfo, uploadId);
230230
channel.position = position;
231231
channel.buffer = buffer.clone();
232-
channel.limit = limit;
232+
channel.limit = buffer.length;
233233
channel.isOpen = isOpen;
234234
channel.chunkSize = chunkSize;
235235
return channel;
236236
}
237237

238238
@Override
239239
public int hashCode() {
240-
return Objects.hash(serviceOptions, blobInfo, uploadId, position, limit, isOpen, chunkSize,
240+
return Objects.hash(serviceOptions, blobInfo, uploadId, position, isOpen, chunkSize,
241241
Arrays.hashCode(buffer));
242242
}
243243

@@ -250,14 +250,13 @@ public boolean equals(Object obj) {
250250
return false;
251251
}
252252
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;
261260
}
262261

263262
@Override

0 commit comments

Comments
 (0)