Fix NullPointerException when call "ReactiveRequestHolder.getHeaders" (#6651)

This commit is contained in:
Alvin 2021-03-31 07:11:30 +08:00 committed by GitHub
parent 523944a59f
commit 9a3e8357cc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 1 deletions

View File

@ -27,6 +27,7 @@ Release Notes.
* Replace hbase-1.x-plugin with hbase-1.x-2.x-plugin to adapt hbase client 2.x
* Remove the close_before_method and close_after_method parameters of custom-enhance-plugin to avoid memory leaks.
* Fix bug that springmvn-annotation-4.x-plugin, witness class does not exist in some versions.
* Fix NullPointerException with `ReactiveRequestHolder.getHeaders`.
#### OAP-Backend
* Allow user-defined `JAVA_OPTS` in the startup script.

View File

@ -20,6 +20,7 @@ package org.apache.skywalking.apm.plugin.spring.mvc.commons;
import java.util.Collections;
import java.util.Enumeration;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.springframework.http.server.reactive.ServerHttpRequest;
@ -37,7 +38,11 @@ public class ReactiveRequestHolder implements RequestHolder {
@Override
public Enumeration<String> getHeaders(final String headerName) {
return Collections.enumeration(this.serverHttpRequest.getHeaders().get(headerName));
List<String> values = this.serverHttpRequest.getHeaders().get(headerName);
if (values == null) {
return Collections.enumeration(Collections.EMPTY_LIST);
}
return Collections.enumeration(values);
}
@Override