@@ -381,37 +381,36 @@ public void preventUpperDirectoryAccess() {
381
381
protected Representation get () throws ResourceException {
382
382
// Content negotiation has been disabled
383
383
// The variant that may need to meet the request conditions
384
- Representation result = null ;
385
384
386
385
List <Variant > variants = getVariants (Method .GET );
387
386
if ((variants == null ) || (variants .isEmpty ())) {
388
387
// Resource not found
389
- getResponse ().setStatus (Status .CLIENT_ERROR_NOT_FOUND );
390
- } else if (variants .size () == 1 ) {
391
- result = (Representation ) variants .get (0 );
392
- } else {
393
- ReferenceList variantRefs = new ReferenceList ();
388
+ throw new ResourceException (Status .CLIENT_ERROR_NOT_FOUND );
389
+ }
394
390
395
- for (Variant variant : variants ) {
396
- if (variant .getLocationRef () != null ) {
397
- variantRefs .add (variant .getLocationRef ());
398
- } else {
399
- getLogger ()
400
- .warning (
401
- "A resource with multiple variants should provide a location for each variant when content negotiation is turned off" );
402
- }
403
- }
391
+ if (variants .size () == 1 ) {
392
+ return (Representation ) variants .get (0 );
393
+ }
394
+
395
+ ReferenceList variantRefs = new ReferenceList ();
404
396
405
- if (!variantRefs .isEmpty ()) {
406
- // Return the list of variants
407
- setStatus (Status .REDIRECTION_MULTIPLE_CHOICES );
408
- result = variantRefs .getTextRepresentation ();
397
+ for (Variant variant : variants ) {
398
+ if (variant .getLocationRef () != null ) {
399
+ variantRefs .add (variant .getLocationRef ());
409
400
} else {
410
- setStatus (Status .CLIENT_ERROR_NOT_FOUND );
401
+ getLogger ()
402
+ .warning (
403
+ "A resource with multiple variants should provide a location for each variant when content negotiation is turned off" );
411
404
}
412
405
}
413
406
414
- return result ;
407
+ if (!variantRefs .isEmpty ()) {
408
+ // Return the list of variants
409
+ setStatus (Status .REDIRECTION_MULTIPLE_CHOICES );
410
+ return variantRefs .getTextRepresentation ();
411
+ }
412
+
413
+ throw new ResourceException (Status .CLIENT_ERROR_NOT_FOUND );
415
414
}
416
415
417
416
/**
0 commit comments