fix(manager-api): add isBlank check to `definitionUrl`
Avoid unnecessary `MalformedURLException`s by checking the string first.
Closes:
@@ -485,13 +485,14 @@ public class ApiService implements DataAccessUtilMixin {
storage.createApiVersion(newVersion);
- if (bean.getDefinitionUrl() != null) {
+ String definitionUrl = bean.getDefinitionUrl();
+ if (definitionUrl != null && !definitionUrl.trim().isBlank()) {
InputStream definition = null;
try {
- definition = new URL(bean.getDefinitionUrl()).openStream();
+ definition = new URL(definitionUrl).openStream();
storage.updateApiDefinition(newVersion, definition);
} catch (Exception e) {
- LOGGER.error("Unable to store API definition from: " + bean.getDefinitionUrl(), e); //$NON-NLS-1$
+ LOGGER.error(e, "Unable to store API definition from: {0}", definitionUrl); //$NON-NLS-1$
// Set definition type silently to None
newVersion.setDefinitionType(ApiDefinitionType.None);
storage.updateApiVersion(newVersion);
