-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix fake storage extend #1935
Fix fake storage extend #1935
Conversation
Could I please get a review? |
@neozwu could you review this? |
ping.. it's been 10 days. Review please? The fix here is simple, it shouldn't be too hard to review. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A couple nits
} | ||
off += delta; | ||
} | ||
assertWithMessage("Wrong bytes from input stream at repeat " + i).that(new String(buf, UTF_8)).isEqualTo(ALONE); |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
} | ||
off += read; | ||
} | ||
assertWithMessage("Wrong bytes from channel at repeat " + i).that(new String(buf.array(), UTF_8)).isEqualTo(ALONE); |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
|
||
try (InputStream is = Files.newInputStream(p)) { | ||
byte[] buf = new byte[bytes.length]; | ||
for (int i=0; i < repeat; i++) { |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
|
||
try (SeekableByteChannel chan = Files.newByteChannel(p, StandardOpenOption.READ)) { | ||
ByteBuffer buf = ByteBuffer.allocate(bytes.length); | ||
for (int i=0; i < repeat; i++) { |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
private Path fillFile(FileSystem fs, byte[] bytes, int repeat) throws IOException { | ||
Path p = fs.getPath("/alone"); | ||
try (OutputStream os = Files.newOutputStream(p)) { | ||
for (int i=0; i<repeat; i++) { |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
+ "The Heart-ache, and the thousand Natural shocks\n" | ||
+ "That Flesh is heir to? 'Tis a consummation\n"; | ||
|
||
// large enough value that we write more than one "chunk", for interesting behavior. |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
Thank you. This should cover all of them. |
LGTM after resolving conflicts and tests |
@@ -0,0 +1,138 @@ | |||
/* | |||
* Copyright 2016 Google Inc. All Rights Reserved. |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
break; | ||
} | ||
off += delta; | ||
} |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
There was a bug when appending to a large file: the initial bytes would be lost. This PR adds a test that reproduces the problem, and a fix.
ad3cbe5
to
a9eb54b
Compare
LGTM after tests pass |
Tests pass, we can merge. Someone with write access will have to do it for me though, GitHub isn't letting me merge (!) @garrettjonesgoogle perhaps? |
Thank you! |
There was a bug when appending to a large file: the initial bytes would
be lost. This PR adds a test that reproduces the problem, and a fix.