Skip to content

Commit

Permalink
Use super.getVariants() rather than super.getVariants(GET)
Browse files Browse the repository at this point in the history
This was a regression introduced in the upgrade to Restlet 2. I
encountered a NullPointerException here when upgrading and misunderstood
the cause of it. Since PUT and DELETE return no content they are
actually supposed to return null.
  • Loading branch information
ato committed Aug 27, 2019
1 parent a5c03d9 commit 5612fa2
Showing 1 changed file with 10 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,11 @@ public class EnhDirectoryResource extends DirectoryServerResource {
*/
@Override
public List<Variant> getVariants() {
List<Variant> variants = new LinkedList<>(super.getVariants(Method.GET));
List<Variant> superVariants = super.getVariants();
if (superVariants == null) {
return null; // PUT and DELETE return no content
}
List<Variant> variants = new LinkedList<>(superVariants);
Form f = getRequest().getResourceRef().getQueryAsForm();
String format = f.getFirstValue("format");
if("textedit".equals(format)) {
Expand All @@ -64,7 +68,11 @@ public List<Variant> getVariants() {
} catch (Exception e) {
throw new RuntimeException(e);
}
variants = new LinkedList<>(super.getVariants(Method.GET));
superVariants = super.getVariants();
if (superVariants == null) {
return null;
}
variants = new LinkedList<>(superVariants);
}
// wrap FileRepresentations in EditRepresentations
ListIterator<Variant> iter = variants.listIterator();
Expand Down

0 comments on commit 5612fa2

Please sign in to comment.