mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-07-24 17:32:48 +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);
|
||||
writer.writeContents(generator, objectMapper);
|
||||
}
|
||||
catch (JsonMappingException error)
|
||||
catch (JsonMappingException | JsonGenerationException error)
|
||||
{
|
||||
logger.error("Failed to write Json output", error);
|
||||
}
|
||||
catch (JsonGenerationException generror)
|
||||
{
|
||||
logger.error("Failed to write Json output", generror);
|
||||
throw new IOException("Failed to write Json output", error);
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -262,13 +262,15 @@ public class ExecutionTests extends AbstractContextTest implements ResponseWrite
|
||||
{
|
||||
AbstractResourceWebScript executor = getExecutor();
|
||||
Map<String, String> templateVars = new HashMap();
|
||||
|
||||
WebScriptResponse response = mockResponse();
|
||||
templateVars.put("apiScope", "private");
|
||||
templateVars.put("apiVersion", "1");
|
||||
templateVars.put("apiName", "alfrescomock");
|
||||
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");
|
||||
executor.execute(api, mockRequest(templateVars,new HashMap<String, List<String>>(1)), response);
|
||||
//throws a runtime exception so INTERNAL_SERVER_ERROR
|
||||
|
Reference in New Issue
Block a user