sonatype/nexus-oss — pull request #8 by cstamas (2013-05-23 12:54:22+00:00)
Title: NEXUS-5704: NPE with if-none-match GET

Restlet 1.1 is very picky (and have a bug) how it handles
ETags: it requires "by the book" how HTTP request formats
ETags, they must be quoted. In other case, the header
presence is detected (condition list is non-empty), but
unexpected null value is returned for tag value (the
condition list will have one element, which is null).
This causes NPE in Nexus code.

"Vanilla" Nexus (even without this change) works properly
for HTTP conditional GETs using if-modified-since headers,
as shown in the linked issue. Still, with unquoted ETag
NPE does happens in Nexus codebase, and this pull fixes it.

This pull merely fixes that single point of NPE by adding
nullcheck, and also simplifies the renderStorageFileItem()
method, but DOES NOT fix the Restlet library in this
manner. After this change, badly formatted ETags
will continue to cause 500 Internal Server Error
responses in Restlet code (where also Tag inspection
is tried, without nullchecks around it).

Even with this change, users will still have to
properly (by RFC, quote their valie) format ETags.

Fixes issue
https://issues.sonatype.org/browse/NEXUS-5704

Ported from:
https://github.com/sonatype/nexus/pull/858