Skip to content
This repository was archived by the owner on Apr 19, 2026. It is now read-only.

Commit a920a67

Browse files
authored
Fix NullPointerException for HTTP requests with no method override. (#56)
getRequestMethodOverride() returns null when "x-http-method-override" header is not set. The output of this method cannot be directly used to query API operation registry.
1 parent 20e50ce commit a920a67

1 file changed

Lines changed: 3 additions & 2 deletions

File tree

endpoints-control/src/main/java/com/google/api/control/ConfigFilter.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -114,8 +114,9 @@ public void doFilter(ServletRequest request, ServletResponse response, FilterCha
114114

115115
// Determine if service control is required
116116
String uri = httpRequest.getRequestURI();
117-
String method = getRequestMethodOverride(httpRequest);
118-
httpRequest.setAttribute(HTTP_METHOD_OVERRIDE_ATTRIBUTE, method);
117+
String methodOverride = getRequestMethodOverride(httpRequest);
118+
httpRequest.setAttribute(HTTP_METHOD_OVERRIDE_ATTRIBUTE, methodOverride);
119+
String method = methodOverride != null ? methodOverride : httpRequest.getMethod();
119120
Info info = registry.lookup(method, uri);
120121
if (info != null) {
121122
httpRequest.setAttribute(METHOD_INFO_ATTRIBUTE, info);

0 commit comments

Comments
 (0)