Skip to content

Commit 5b2519a

Browse files
committed
Fixed potential NPE.
1 parent df1bee3 commit 5b2519a

1 file changed

Lines changed: 4 additions & 3 deletions

File tree

modules/org.restlet/src/org/restlet/service/ConverterService.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -310,7 +310,7 @@ public Representation toRepresentation(Object source, Variant target)
310310
public Representation toRepresentation(Object source, Variant target,
311311
Resource resource) throws IOException {
312312
Representation result = null;
313-
boolean loggable = (resource == null) ? true : resource.isLoggable();
313+
boolean loggable = (resource == null) || resource.isLoggable();
314314
ConverterHelper ch = ConverterUtils.getBestHelper(source, target,
315315
resource);
316316

@@ -334,10 +334,11 @@ public Representation toRepresentation(Object source, Variant target,
334334
} else {
335335
target = variants.get(0);
336336
}
337-
} else {
338-
target = new Variant();
339337
}
340338
}
339+
if (target == null) {
340+
target = new Variant();
341+
}
341342

342343
result = ch.toRepresentation(source, target, resource);
343344

0 commit comments

Comments
 (0)