From d9b165d70ccb213100f752a7dbf4b76c61ed27a4 Mon Sep 17 00:00:00 2001 From: Roy Teeuwen Date: Fri, 13 Oct 2017 21:33:09 +0200 Subject: [PATCH] Make request nullable because in the unit/integration tests it might not be available --- .../mapper/impl/processor/RequestAttributeProcessor.java | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/slice-mapper/src/main/java/com/cognifide/slice/mapper/impl/processor/RequestAttributeProcessor.java b/slice-mapper/src/main/java/com/cognifide/slice/mapper/impl/processor/RequestAttributeProcessor.java index 571f07f0..00e5c2ec 100644 --- a/slice-mapper/src/main/java/com/cognifide/slice/mapper/impl/processor/RequestAttributeProcessor.java +++ b/slice-mapper/src/main/java/com/cognifide/slice/mapper/impl/processor/RequestAttributeProcessor.java @@ -19,6 +19,7 @@ */ package com.cognifide.slice.mapper.impl.processor; +import com.cognifide.slice.api.qualifier.Nullable; import com.cognifide.slice.mapper.annotation.RequestAttribute; import com.cognifide.slice.mapper.api.processor.FieldProcessor; import com.google.inject.Inject; @@ -32,6 +33,7 @@ public class RequestAttributeProcessor implements FieldProcessor { @Inject + @Nullable private ServletRequest servletRequest; @Override @@ -41,8 +43,11 @@ public boolean accepts(final Resource resource, final Field field) { @Override public Object mapResourceToField(Resource resource, ValueMap valueMap, Field field, String propertyName) { - String attributeName = getAttributeName(field); - return servletRequest.getAttribute(attributeName); + if (servletRequest != null) { + String attributeName = getAttributeName(field); + return servletRequest.getAttribute(attributeName); + } + return null; } private String getAttributeName(Field field) {