mirror of
https://github.com/open-metadata/OpenMetadata
synced 2026-05-24 09:39:11 +00:00
NoOpAssetService: never return null from generateDownloadUrlWithExpiry
In review round 4 I changed this method to return asset.getUrl() when the asset is non-null. But Asset.url is optional in the schema, so asset.getUrl() itself can be null — which breaks the implied "never returns null" contract downstream callers rely on (AttachmentResource only null-checks defensively). Normalize null and blank URLs to an empty string so the method's non-null, non-blank contract holds even when storage is disabled and the asset was never populated with a URL.
This commit is contained in:
parent
4e171d0edb
commit
a4a2dcc91d
1 changed files with 11 additions and 4 deletions
|
|
@ -22,12 +22,19 @@ public class NoOpAssetService implements AssetService {
|
|||
}
|
||||
|
||||
/**
|
||||
* Return the asset's own URL (which is empty when object storage is disabled) instead
|
||||
* of a synthetic CDN URL. Returning a fake URL would let clients issue downloads that
|
||||
* can never succeed and would mask the misconfiguration.
|
||||
* Return the asset's own URL when present, otherwise an empty string. We deliberately
|
||||
* avoid returning a synthetic CDN URL here — a fake URL would let clients issue
|
||||
* downloads that can never succeed and would mask the "storage disabled"
|
||||
* misconfiguration. {@link org.openmetadata.schema.attachments.Asset#getUrl()} is
|
||||
* optional in the schema, so normalize null/blank to "" to preserve the non-null
|
||||
* contract callers rely on.
|
||||
*/
|
||||
@Override
|
||||
public String generateDownloadUrlWithExpiry(Asset asset, Duration expiry) {
|
||||
return asset == null ? "" : asset.getUrl();
|
||||
if (asset == null) {
|
||||
return "";
|
||||
}
|
||||
String url = asset.getUrl();
|
||||
return url == null || url.isBlank() ? "" : url;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue