Skip to content
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

Merged
merged 2 commits into from
May 8, 2017

Conversation

jean-philippe-martin
Copy link

@jean-philippe-martin jean-philippe-martin commented Apr 18, 2017

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.

@googlebot googlebot added the cla: yes This human has signed the Contributor License Agreement. label Apr 18, 2017
@coveralls
Copy link

Coverage Status

Coverage increased (+0.01%) to 80.954% when pulling dffec6e on jean-philippe-martin:fake_storage_extend into b6a87b0 on GoogleCloudPlatform:master.

@coveralls
Copy link

Coverage Status

Coverage increased (+0.005%) to 80.946% when pulling fd709eb on jean-philippe-martin:fake_storage_extend into b6a87b0 on GoogleCloudPlatform:master.

@coveralls
Copy link

Coverage Status

Coverage increased (+0.005%) to 80.946% when pulling c62ddf1 on jean-philippe-martin:fake_storage_extend into b6a87b0 on GoogleCloudPlatform:master.

@jean-philippe-martin
Copy link
Author

Could I please get a review?

@garrettjonesgoogle
Copy link
Member

@neozwu could you review this?

@jean-philippe-martin
Copy link
Author

ping.. it's been 10 days. Review please? The fix here is simple, it shouldn't be too hard to review.

@garrettjonesgoogle
Copy link
Member

@garrettjonesgoogle garrettjonesgoogle requested review from shinfan and removed request for neozwu May 8, 2017 16:51
Copy link
Contributor

@shinfan shinfan left a 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.

}
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.


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.


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.

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.

+ "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.

@jean-philippe-martin
Copy link
Author

Thank you. This should cover all of them.

@shinfan
Copy link
Contributor

shinfan commented May 8, 2017

LGTM after resolving conflicts and tests

@@ -0,0 +1,138 @@
/*
* Copyright 2016 Google Inc. All Rights Reserved.

This comment was marked as spam.

break;
}
off += delta;
}

This comment was marked as spam.

This comment was marked as spam.

This comment was marked as spam.

This comment was marked as spam.

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.
@garrettjonesgoogle
Copy link
Member

LGTM after tests pass

@coveralls
Copy link

Coverage Status

Coverage increased (+0.02%) to 80.897% when pulling a551265 on jean-philippe-martin:fake_storage_extend into d70f696 on GoogleCloudPlatform:master.

@coveralls
Copy link

Coverage Status

Coverage increased (+0.02%) to 80.897% when pulling a551265 on jean-philippe-martin:fake_storage_extend into d70f696 on GoogleCloudPlatform:master.

@jean-philippe-martin
Copy link
Author

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?

@shinfan shinfan merged commit 8293249 into googleapis:master May 8, 2017
@jean-philippe-martin
Copy link
Author

Thank you!

@jean-philippe-martin jean-philippe-martin deleted the fake_storage_extend branch May 8, 2017 19:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cla: yes This human has signed the Contributor License Agreement.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants