diff --git a/src/community/ogcapi/ogcapi-core/src/main/java/org/geoserver/api/APIRequestInfo.java b/src/community/ogcapi/ogcapi-core/src/main/java/org/geoserver/api/APIRequestInfo.java index f83ea0c36b4..58caf5dee00 100644 --- a/src/community/ogcapi/ogcapi-core/src/main/java/org/geoserver/api/APIRequestInfo.java +++ b/src/community/ogcapi/ogcapi-core/src/main/java/org/geoserver/api/APIRequestInfo.java @@ -76,7 +76,10 @@ String buildURI(String base, String path) { return ResponseUtils.buildURL(baseURL, path, null, URLMangler.URLType.SERVICE); } - /** Returns the APIRequestInfo from the current {@link RequestContextHolder} */ + /** + * Returns the APIRequestInfo from the current {@link RequestContextHolder}, or {@code null} + * indicating there's no OGC API request bound to the calling thread + */ public static APIRequestInfo get() { RequestAttributes requestAttributes = RequestContextHolder.getRequestAttributes(); if (requestAttributes == null) return null; diff --git a/src/community/ogcapi/ogcapi-features/src/main/java/org/geoserver/api/features/RFCGeoJSONFeaturesResponse.java b/src/community/ogcapi/ogcapi-features/src/main/java/org/geoserver/api/features/RFCGeoJSONFeaturesResponse.java index d3d06562a1f..5a83f38ac16 100644 --- a/src/community/ogcapi/ogcapi-features/src/main/java/org/geoserver/api/features/RFCGeoJSONFeaturesResponse.java +++ b/src/community/ogcapi/ogcapi-features/src/main/java/org/geoserver/api/features/RFCGeoJSONFeaturesResponse.java @@ -111,6 +111,10 @@ private void writeLinks( GeoJSONBuilder jw, String featureId) { APIRequestInfo requestInfo = APIRequestInfo.get(); + if (null == requestInfo) { + // request comes from WFS, not from ogcapi + return; + } GetFeatureRequest request = GetFeatureRequest.adapt(operation.getParameters()[0]); FeatureTypeInfo featureType = getFeatureType(request); String baseUrl = request.getBaseUrl();