public Object extractValue(String strVal, HttpRequest request)
{
Object value = extractValue(strVal);
if (strVal != null && value == null)
{
MediaType mediaType = request.getHttpHeaders().getMediaType();
if (mediaType == null)
{
mediaType = MediaType.WILDCARD_TYPE;
}
if (mediaType.isCompatible(MediaType.APPLICATION_JSON_TYPE))
{
if (this.reader == null)
{
lock.lock();
try
{
if (this.reader == null)
{
this.reader = JsonUtil.createReader(type);
}
}
finally
{
lock.unlock();
}
}
try
{
if (strVal == null || strVal.length()==0)
{
strVal = defaultValue;
}
value = this.reader.readValue(strVal);
}
catch (Exception e)
{
throw new BadRequestException("Can not read request body for path: " + request.getUri().getPath(), e);
}
}
else
{
throw new UnsupportedMediaTypeException("Media type not supported: " + mediaType.toString());
}
}
return value;
}