[MGNLTEST-161] NPE ImageResponse.dimension() when target image not exist Created: 22/Apr/21  Updated: 01/Jun/21  Resolved: 06/May/21

Status: Closed
Project: Magnolia Test Framework
Component/s: None
Affects Version/s: 1.1.0
Fix Version/s: 1.2.0

Type: Bug Priority: Neutral
Reporter: Evzen Fochr Assignee: Christoph Meier
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: 3h
Original Estimate: Not Specified

Template:
Acceptance criteria:
Empty
Task DoD:
[X]* Doc/release notes changes? Comment present?
[X]* Downstream builds green?
[X]* Solution information and context easily available?
[X]* Tests
[X]* FixVersion filled and not yet released
[ ]  Architecture Decision Record (ADR)
Bug DoR:
[X]* Steps to reproduce, expected, and actual results filled
[X]* Affected version filled
Date of First Response:

 Description   

Steps to reproduce

  1. https://git.magnolia-cms.com/projects/PLATFORM/repos/test-framework/browse/docs/ui-tests-how-to-m6.md
  2. HttpClientSupport
  3. set wrong path to not existing image
  4.  assert on imageResponse.dimension()
  5.  

.. Logs, screenshots, gifs...

Expected results

get null

.. Justify non-trivial expectations with a link to a doc or a relevant discussion.

Actual results

NPE is thrown

Workaround

Development notes



 Comments   
Comment by Christoph Meier [ 06/May/21 ]

I cannot reproduce the NPE on my local setup.

The line where Evzen encountered the NPE was this:

String responseType = response.body().contentType().type();

But even when using HTTP HEAD response.body() is never null.

Anyhow I have improved to make it NPE safe. 
One could imagine a situation where the connection was broken before anything was written to the response stream.
(But even in that case I'm not sure whether response.body() would be null.)

So the PR will contain an improvement making the code more NPE safe, plus some more tests.

Generated at Mon Feb 12 07:46:10 CET 2024 using Jira 9.4.2#940002-sha1:46d1a51de284217efdcb32434eab47a99af2938b.