-
Notifications
You must be signed in to change notification settings - Fork 28
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
(#42) HtHead can be broken. #69
Conversation
Job #69 is now in scope, role is |
This pull request #69 is assigned to @victornoel/z, here is why; the budget is 15 minutes, see §4; please, read §27 and when you decide to accept the changes, inform @llorllale/z (the architect) right in this ticket; if you decide that this PR should not be accepted ever, also inform the architect; this blog post will help you understand what is expected from a code reviewer; there will be no monetary reward for this job |
Codecov Report
@@ Coverage Diff @@
## master #69 +/- ##
===========================================
- Coverage 96.9% 96.51% -0.4%
+ Complexity 67 61 -6
===========================================
Files 17 17
Lines 194 172 -22
Branches 15 9 -6
===========================================
- Hits 188 166 -22
Misses 4 4
Partials 2 2
Continue to review full report at Codecov.
|
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.
@ilyakharlamov see my comments :) it's a nice solution!
*/ | ||
private static final int LENGTH = 16384; | ||
private static final String DELIMITER = "\r\n"; |
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.
@ilyakharlamov it would be more elegant if the constructor took this information instead of making it fixed like this. There should be a secondary constructor that set it to \r\n
then.
This is more of an architectural choice so @llorllale should confirm first I think :)
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.
@ilyakharlamov @llorllale let's forget about this, the delimiter is strongly related to the behaviour of this class, no need to introduce an extra parameter
Matchers.allOf( | ||
Matchers.startsWith("HTTP"), | ||
Matchers.containsString("OK\r\nReferer"), | ||
Matchers.endsWith("text/plain") |
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.
@ilyakharlamov please use the OO version of the matchers (instantiate them with new XXX intead of the static method), and if possible use those available from cactoos-matchers
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.
What would be the replacement for Matchers.allOf ?
I guess that supposed to be
new AllOf<>( new IterableOf<>( new StringStartsWith("HTTP"), new StringContains("OK\r\nReferer"), new StringEndsWith("text/plain") ) )
However that throws a compilation warning "unchecked generic array creation for varargs".
Please advise what to replace static Matchers.allOf with.
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.
@ilyakharlamov you are right, it is too much with new AllOf
, let' keep the static only for allOf
then and see if @llorllale is good with it.
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.
@ilyakharlamov also use cactoos-matchers StartsWith, TextHasString and EndsWith
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.
@victornoel As far as I understand StartsWith, TextHasString and EndsWith are coming in cactoos-matchers 0.13 which has not been released yet, so it's not available in maven, so can't use it yet.
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.
@ilyakharlamov it's happening: llorllale/cactoos-matchers#18 (comment) :)
); | ||
MatcherAssert.assertThat( | ||
block.length(), | ||
new IsEqual<>( |
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.
@ilyakharlamov please use cactoos-matchers' TextIs
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.
Here I am constructing a block and making sure it has the exact length of the block.
How TextIs can help to verify that the string is of a certain size?
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.
@ilyakharlamov you are right yes. I think this test is too complex to be easily understandable.
Why are you checking the block length? You are not testing HtHead
here, so I don't think you should be asserting anything. I would advise to remove this assertion.
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.
@victornoel In order to reproduce the issue, I need to have a header of the exact size of the block (16384 bytes)
So it's way too easy to miss one character, like one extra space and the block will be 16383 or 16385 and the test will yield a false-positive result. So here I am checking the length to make sure that the constructed header is exactly 16384 bytes before running the actual test.
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.
@ilyakharlamov ok, it's good for me then, thank you for the explanation
this.scanner.next() | ||
); | ||
if (this.hasMoreElements()) { | ||
builder.append(HtHead.DELIMITER); |
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.
@ilyakharlamov can you double check that we want to include the delimiter in the resulting InputStream
? In the original code I see this line if (found) { tail = tail - end.length + 1; }
which let me think it should not be included
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.
I've checked against the previous commit 487af7 and
Matchers.containsString("OK\r\nReferer") passes .
Which makes sense. Since the goal is to separate the HTTP header from the body so the separator between the headers needs to be kept.
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.
@ilyakharlamov ok yes, i better understand, thank you for confirming :)
"", | ||
"text here" | ||
new TextOf(""), | ||
new TextOf("body here") |
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.
@ilyakharlamov in this case I wouldn't have bothered to use TextOf
, it is a bit too much I think :)
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.
@victornoel done in c7a5980
new StringStartsWith("HTTP"), | ||
new StringContains("OK\r\nReferer"), | ||
new StringEndsWith("text/plain") | ||
) |
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.
@ilyakharlamov when cactoos-matches is released, please use directly allOf
with Text based matchers (instead of using TextIs
which makes all of this akward :)
@@ -102,8 +110,54 @@ public void largeText() throws IOException { | |||
) | |||
) | |||
).asString(), | |||
Matchers.endsWith("text/plain") | |||
new StringEndsWith("text/plain") |
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.
@ilyakharlamov please replace this with cactoos-matchers EndsWith
(and don't call asString()
on the Text
)
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.
@victornoel Not sure I understand. I have a Text
, and a EndsWith
. EndsWith
is basically a Matcher<String>
. How do I assert them between each other without using asString()?
new Assertion<>("description", Text, Matcher<String>)
is obviously not compilable.
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.
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.
@victornoel thank you, I was very confused, there are so many matchers in the classpath with similar names that do similar things but incompatible. fixed in 8915ec4
@ilyakharlamov I've added a few comments, we are almost there :) |
@ilyakharlamov thank you for your patience, I think it's all good now :) |
@ilyakharlamov I cringed when I saw |
@llorllale That can be possible after cactoos#1035. |
@ilyakharlamov apparenty yegor256/cactoos#1038 that solves yegor256/cactoos#1035 has been merged a few days ago, I suppose you can continue the work here? |
@victornoel Even though the yegor256/cactoos#1038 is merged, it is not released (will be cactoos 0.39). I am not responsible for cactoos-releases, it may be a few month before we have 0.39. |
@ilyakharlamov you should ask ARC in the issue you are interested in to make a new release |
@ilyakharlamov cactoos 0.39 has been released (see yegor256/cactoos#1035) |
@ilyakharlamov it has already been released... and also it is useless to tell 0crat to wait in a PR |
@ilyakharlamov just update the dependency and fix the PR |
@ilyakharlamov It's a code review job #69, can't put it on hold |
@victornoel Cactoos 0.39 introduces a few signature changes. |
@ilyakharlamov yes, you are right, thanks for the explanation |
@ilyakharlamov cactoos-http now uses cactoos 0.39, I believe we can continue here now :) |
7858809
to
89c7a77
Compare
@ilyakharlamov thanks for your patience, it looks real nice now :) |
@victornoel @ilyakharlamov I just want to mention that @dgroup's hamcrest PR to add |
@rultor merge |
@llorllale OK, I'll try to merge now. You can check the progress of the merge here |
@llorllale Done! FYI, the full log is here (took me 12min) |
Code review was too long (39 days), architects (@llorllale) were penalized, see §55 |
The job #69 is now out of scope |
Order was finished: +15 point(s) just awarded to @victornoel/z |
Payment to |
( #42 ) HtHead can be broken