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

Test case that fails due to NullPointerException #1346

Closed
wants to merge 3 commits into from

Conversation

suztomo
Copy link
Member

@suztomo suztomo commented Apr 15, 2021

Investigating the reason for apache/beam#14527 (comment)

@suztomo suztomo requested a review from a team as a code owner April 15, 2021 15:32
@google-cla google-cla bot added the cla: yes This human has signed the Contributor License Agreement. label Apr 15, 2021
Copy link
Contributor

@elharo elharo left a comment

Choose a reason for hiding this comment

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

The mocking makes it hard to figure out whether there's a bug in the model code or just a bad mock setup. See #1345 for a test that uses a real HTTP server instead of a mock.

Copy link
Contributor

@elharo elharo left a comment

Choose a reason for hiding this comment

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

Possibly BatchUnparsedResponse needs to handle empty input better

@suztomo
Copy link
Member Author

suztomo commented Apr 15, 2021

I agree that this test case is not clear which one is the problem. I'll try to simplify this further.

@suztomo suztomo marked this pull request as draft April 15, 2021 16:58
}

@Test
public void testErrorContentRead_NoRetry() throws IOException {
Copy link
Member Author

Choose a reason for hiding this comment

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

This succeeds. Maybe problem in retry?

Copy link
Contributor

@elharo elharo left a comment

Choose a reason for hiding this comment

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

I don't think this test demonstrates a bug or an issue with the http client. The NullPointerException here occurs in google-api-java-client. The code there looks very suspicious to me.

If there is an issue here it should be able to be demonstrated with classes already in this repository.

}
}
};
try (FakeServer server = new FakeServer(handler)) {
Copy link
Member Author

Choose a reason for hiding this comment

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

With the fake server, this test succeeds. This implies that the mock setup in Beam is not enough (at least for this test case).

@suztomo
Copy link
Member Author

suztomo commented Apr 15, 2021

The FakeServer in #1345 worked. Thank you. Now I'm feeling something is lacking in the mock setup.

If there is an issue here it should be able to be demonstrated with classes already in this repository

Right. I haven't been able to isolate the problem in a class yet.

@suztomo
Copy link
Member Author

suztomo commented Apr 15, 2021

Next step: investigate why mock fails and fake server succeeds.

With FakeServer

With FakeServer, BatchRequest line 262 gets a buffer with 137 bytes with position 0.

Screen Shot 2021-04-15 at 14 51 17

With Mock

Screen Shot 2021-04-15 at 14 53 22

With mock, BatchRequest line 262 gets a buffer with 17 bytes with position 0.

It seems that since this change https://github.com/googleapis/google-http-java-client/pull/986/files#diff-f8b4bfc64923817722aee3aebebae240783e193ebbd305c2e3291d2cfddd5c31R1015, lowLevelHttpResponse , lowLevelHttpResponse.getStatusCode() is called 1 more time per 1 response. The mock's assumption about 1 getStatusCode() per 1 request is wrong.

@suztomo suztomo closed this Apr 15, 2021
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.

2 participants