Source:
<code>public Response getEndpointDefinition(String registryId, String entryId, MessageContext messageContext) { String tenantDomain = RestApiUtil.getLoggedInUserTenantDomain(); String contentType = StringUtils.EMPTY; EndpointRegistry registryProvider = new EndpointRegistryImpl(); InputStream endpointDefinition = null; try { EndpointRegistryInfo endpointRegistry = registryProvider.getEndpointRegistryByUUID(registryId, tenantDomain); if (endpointRegistry == null) { RestApiUtil.handleResourceNotFoundError("Endpoint registry with the id: " + registryId + " is not found", log); } EndpointRegistryEntry registryEntry = registryProvider.getEndpointRegistryEntryByUUID(registryId, entryId); if (registryEntry == null) { RestApiUtil.handleResourceNotFoundError("Endpoint registry entry with the id: " + entryId + " is not found", log); } String type = registryEntry.getDefinitionType(); if (RegistryEntryDTO.DefinitionTypeEnum.OAS.equals(RegistryEntryDTO.DefinitionTypeEnum.fromValue(type)) || RegistryEntryDTO.DefinitionTypeEnum.GQL_SDL.equals(RegistryEntryDTO.DefinitionTypeEnum .fromValue(type))) { contentType = MediaType.APPLICATION_JSON; } else if (RegistryEntryDTO.DefinitionTypeEnum.WSDL1.equals(RegistryEntryDTO.DefinitionTypeEnum .fromValue(type)) || RegistryEntryDTO.DefinitionTypeEnum.WSDL2.equals(RegistryEntryDTO .DefinitionTypeEnum.fromValue(type))) { contentType = MediaType.TEXT_XML; } endpointDefinition = registryEntry.getEndpointDefinition(); } catch (APIManagementException e) { RestApiUtil.handleInternalServerError("Error while retrieving the endpoint definition of registry " + "entry with id: " + entryId, e, log); } <START> return Response.ok(endpointDefinition).type(contentType).build(); <END> }</code><technical_language>endpointDefinition == null, need throw error response right</technical_language>

Target:
public Response getEndpointDefinition(String registryId, String entryId, MessageContext messageContext) { String tenantDomain = RestApiUtil.getLoggedInUserTenantDomain(); String contentType = StringUtils.EMPTY; EndpointRegistry registryProvider = new EndpointRegistryImpl(); InputStream endpointDefinition = null; try { EndpointRegistryInfo endpointRegistry = registryProvider.getEndpointRegistryByUUID(registryId, tenantDomain); if (endpointRegistry == null) { RestApiUtil.handleResourceNotFoundError("Endpoint registry with the id: " + registryId + " is not found", log); } EndpointRegistryEntry registryEntry = registryProvider.getEndpointRegistryEntryByUUID(registryId, entryId); if (registryEntry == null) { RestApiUtil.handleResourceNotFoundError("Endpoint registry entry with the id: " + entryId + " is not found", log); } String type = registryEntry.getDefinitionType(); if (RegistryEntryDTO.DefinitionTypeEnum.OAS.equals(RegistryEntryDTO.DefinitionTypeEnum.fromValue(type)) || RegistryEntryDTO.DefinitionTypeEnum.GQL_SDL.equals(RegistryEntryDTO.DefinitionTypeEnum .fromValue(type))) { contentType = MediaType.APPLICATION_JSON; } else if (RegistryEntryDTO.DefinitionTypeEnum.WSDL1.equals(RegistryEntryDTO.DefinitionTypeEnum .fromValue(type)) || RegistryEntryDTO.DefinitionTypeEnum.WSDL2.equals(RegistryEntryDTO .DefinitionTypeEnum.fromValue(type))) { contentType = MediaType.TEXT_XML; } endpointDefinition = registryEntry.getEndpointDefinition(); } catch (APIManagementException e) { RestApiUtil.handleInternalServerError("Error while retrieving the endpoint definition of registry " + "entry with id: " + entryId, e, log); } if (endpointDefinition == null) { RestApiUtil.handleResourceNotFoundError("Endpoint definition not found for entry with ID: " + entryId, log); } return Response.ok(endpointDefinition).type(contentType).build(); }