mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-07-31 17:39:05 +00:00
MNT-23927 Handle JsonMappingException and JsonGenerationException (#2289)
* Throw JSON exceptions as IO exceptions to be properly handled * Log null prop keys * Fix test to have the mocked response different than null
This commit is contained in:
@@ -104,13 +104,9 @@ public class JacksonHelper implements InitializingBean
|
|||||||
JsonGenerator generator = objectMapper.getFactory().createGenerator(outStream, encoding);
|
JsonGenerator generator = objectMapper.getFactory().createGenerator(outStream, encoding);
|
||||||
writer.writeContents(generator, objectMapper);
|
writer.writeContents(generator, objectMapper);
|
||||||
}
|
}
|
||||||
catch (JsonMappingException error)
|
catch (JsonMappingException | JsonGenerationException error)
|
||||||
{
|
{
|
||||||
logger.error("Failed to write Json output", error);
|
throw new IOException("Failed to write Json output", error);
|
||||||
}
|
|
||||||
catch (JsonGenerationException generror)
|
|
||||||
{
|
|
||||||
logger.error("Failed to write Json output", generror);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -262,13 +262,15 @@ public class ExecutionTests extends AbstractContextTest implements ResponseWrite
|
|||||||
{
|
{
|
||||||
AbstractResourceWebScript executor = getExecutor();
|
AbstractResourceWebScript executor = getExecutor();
|
||||||
Map<String, String> templateVars = new HashMap();
|
Map<String, String> templateVars = new HashMap();
|
||||||
|
|
||||||
|
WebScriptResponse response = mockResponse();
|
||||||
templateVars.put("apiScope", "private");
|
templateVars.put("apiScope", "private");
|
||||||
templateVars.put("apiVersion", "1");
|
templateVars.put("apiVersion", "1");
|
||||||
templateVars.put("apiName", "alfrescomock");
|
templateVars.put("apiName", "alfrescomock");
|
||||||
templateVars.put(ResourceLocator.COLLECTION_RESOURCE, "sheep");
|
templateVars.put(ResourceLocator.COLLECTION_RESOURCE, "sheep");
|
||||||
executor.execute(ApiAssistant.determineApi(templateVars), mockRequest(templateVars,new HashMap<String, List<String>>(1)), mock(WebScriptResponse.class));
|
executor.execute(ApiAssistant.determineApi(templateVars), mockRequest(templateVars,new HashMap<String, List<String>>(1)), response);
|
||||||
|
|
||||||
WebScriptResponse response = mockResponse();
|
response = mockResponse();
|
||||||
templateVars.put(ResourceLocator.COLLECTION_RESOURCE, "bad");
|
templateVars.put(ResourceLocator.COLLECTION_RESOURCE, "bad");
|
||||||
executor.execute(api, mockRequest(templateVars,new HashMap<String, List<String>>(1)), response);
|
executor.execute(api, mockRequest(templateVars,new HashMap<String, List<String>>(1)), response);
|
||||||
//throws a runtime exception so INTERNAL_SERVER_ERROR
|
//throws a runtime exception so INTERNAL_SERVER_ERROR
|
||||||
|
@@ -1614,6 +1614,10 @@ public abstract class AbstractPropertyValueDAOImpl implements PropertyValueDAO
|
|||||||
{
|
{
|
||||||
Map<Serializable, Serializable> map = (Map<Serializable, Serializable>) container;
|
Map<Serializable, Serializable> map = (Map<Serializable, Serializable>) container;
|
||||||
Serializable mapKey = getPropertyValueById(keyPropId).getSecond();
|
Serializable mapKey = getPropertyValueById(keyPropId).getSecond();
|
||||||
|
if(mapKey == null)
|
||||||
|
{
|
||||||
|
logger.error("Found null key for id " + keyPropId + " with value " + value);
|
||||||
|
}
|
||||||
map.put(mapKey, value);
|
map.put(mapKey, value);
|
||||||
}
|
}
|
||||||
else if (container instanceof Collection<?>)
|
else if (container instanceof Collection<?>)
|
||||||
|
Reference in New Issue
Block a user