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: use random UUID for multipart boundary delimiter #916

Merged

Conversation

dmitry-fa
Copy link
Contributor

@dmitry-fa dmitry-fa commented Dec 16, 2019

@dmitry-fa dmitry-fa requested a review from as a code owner Dec 16, 2019
@googlebot
Copy link

@googlebot googlebot commented Dec 16, 2019

Thanks for your pull request. It looks like this may be your first contribution to a Google open source project (if not, look below for help). Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

📝 Please visit https://cla.developers.google.com/ to sign.

Once you've signed (or fixed any issues), please reply here with @googlebot I signed it! and we'll verify it.


What to do if you already signed the CLA

Individual signers
Corporate signers

ℹ️ Googlers: Go here for more info.

@googlebot googlebot added the cla: no label Dec 16, 2019
@dmitry-fa dmitry-fa force-pushed the df67450/google-http-java-client branch from d4b8f7d to 787b159 Compare Dec 16, 2019
@googlebot
Copy link

@googlebot googlebot commented Dec 16, 2019

CLAs look good, thanks!

ℹ️ Googlers: Go here for more info.

@googlebot googlebot added cla: yes and removed cla: no labels Dec 16, 2019
@dmitry-fa dmitry-fa force-pushed the df67450/google-http-java-client branch from 787b159 to 9971579 Compare Dec 16, 2019
@athakor athakor added the kokoro:force-run label Dec 16, 2019
@kokoro-team kokoro-team removed the kokoro:force-run label Dec 16, 2019
@dmitry-fa dmitry-fa changed the title Fixes #909 Use random UUID string as boundary instead of hardcoded '__END_OF_PART__' Fixes #909 and closes googleapis/google-cloud-java/#6386 Dec 16, 2019
@dmitry-fa dmitry-fa changed the title Fixes #909 and closes googleapis/google-cloud-java/#6386 Fixes #909 and closes googleapis/google-cloud-java#6386 Dec 16, 2019

public MultipartContent() {
super(new HttpMediaType("multipart/related").setParameter("boundary", "__END_OF_PART__"));
this("__END_OF_PART__" + java.util.UUID.randomUUID().toString() + "__");
Copy link
Collaborator

@elharo elharo Dec 30, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a reason not to import java.util.UUID? e.g a conflict with a similarly named class?

Copy link
Contributor Author

@dmitry-fa dmitry-fa Dec 30, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed.

{"<xml>Hi</xml>", "application/xml"},
{"{x:1,y:2}", "application/json"}
};
StringBuilder expectedContentSB = new StringBuilder();
Copy link
Collaborator

@elharo elharo Dec 30, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no abbreviations per google style, but simply "expectedContent" or even just expected is fine.

Copy link
Contributor Author

@dmitry-fa dmitry-fa Dec 30, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

expectedContent is used later. renamed to expectedStringBuilder

ByteArrayOutputStream out = new ByteArrayOutputStream();
content.writeTo(out);
String expectedContent = expectedContentSB.toString();
assertEquals(expectedContent, out.toString());
Copy link
Collaborator

@elharo elharo Dec 30, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

out.toString needs to specify a locale

Copy link
Contributor Author

@dmitry-fa dmitry-fa Dec 30, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed in two places. Thanks for catching that.

@chingor13 chingor13 changed the title Fixes #909 and closes googleapis/google-cloud-java#6386 fix: use random UUID for multipart boundary delimiter Dec 30, 2019
@chingor13 chingor13 added the kokoro:force-run label Dec 30, 2019
@kokoro-team kokoro-team removed the kokoro:force-run label Dec 30, 2019
elharo
elharo approved these changes Dec 30, 2019
@chingor13 chingor13 merged commit 91c20a3 into googleapis:master Dec 30, 2019
9 checks passed
@dmitry-fa dmitry-fa deleted the df67450/google-http-java-client branch Jan 15, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cla: yes
Projects
None yet
6 participants