You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@skywalking.apache.org by GitBox <gi...@apache.org> on 2021/03/29 12:56:15 UTC

[GitHub] [skywalking] mm23504570 opened a new issue #6648: NullPointerException with nonexistent Header when call "ReactiveRequestHolder.getHeaders"

mm23504570 opened a new issue #6648:
URL: https://github.com/apache/skywalking/issues/6648


   Please answer these questions before submitting your issue.
   
   - Why do you submit this issue?
   - [ ] Question or discussion
   - [ * ] Bug
   - [ ] Requirement
   - [ ] Feature or performance improvement
   ___
   ### Bug
   - Which version of SkyWalking, OS, and JRE?
   8.4.0
   - Which company or project?
   
   - What happened?
   If possible, provide a way to reproduce the error. e.g. demo application, component version.
   
   - What do you want to know?
   code
   ```
   public class ReactiveRequestHolder implements RequestHolder {
   @Override
       public Enumeration<String> getHeaders(final String headerName) {
           return Collections.enumeration(this.serverHttpRequest.getHeaders().get(headerName));
       }
   }
   ```
   
   ```
   java.lang.NullPointerException: null
       at java.util.Collections$3.<init>(Collections.java:5314)
       at java.util.Collections.enumeration(Collections.java:5313)
       at org.apache.skywalking.apm.plugin.spring.mvc.commons.ReactiveRequestHolder.getHeaders(ReactiveRequestHolder.java:40)
       at org.apache.skywalking.apm.plugin.spring.mvc.commons.interceptor.AbstractMethodInterceptor.lambda$collectHttpHeaders$0(AbstractMethodInterceptor.java:257)
       at java.util.stream.ReferencePipeline$2$1.accept(ReferencePipeline.java:176)
       at java.util.Spliterators$ArraySpliterator.forEachRemaining(Spliterators.java:948)
       at java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:484)
       at java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:474)
       at java.util.stream.ForEachOps$ForEachOp.evaluateSequential(ForEachOps.java:150)
       at java.util.stream.ForEachOps$ForEachOp$OfRef.evaluateSequential(ForEachOps.java:173)
       at java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
       at java.util.stream.ReferencePipeline.forEach(ReferencePipeline.java:497)
       at org.apache.skywalking.apm.plugin.spring.mvc.commons.interceptor.AbstractMethodInterceptor.collectHttpHeaders(AbstractMethodInterceptor.java:258)
       at org.apache.skywalking.apm.plugin.spring.mvc.commons.interceptor.AbstractMethodInterceptor.beforeMethod(AbstractMethodInterceptor.java:134)
   ```
   ___
   ### Requirement or improvement
   We can change this to 
   ```
   @Override
       public Enumeration<String> getHeaders(final String headerName) {
           List<String> values = this.serverHttpRequest.getHeaders().get(headerName);
           if (CollectionUtil.isEmpty(values)) {
               return Collections.enumeration(Collections.EMPTY_LIST);
           }
           return Collections.enumeration(this.serverHttpRequest.getHeaders().get(headerName));
       }
   ```


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [skywalking] wu-sheng closed issue #6648: NullPointerException with nonexistent Header when call "ReactiveRequestHolder.getHeaders"

Posted by GitBox <gi...@apache.org>.
wu-sheng closed issue #6648:
URL: https://github.com/apache/skywalking/issues/6648


   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [skywalking] mm23504570 commented on issue #6648: NullPointerException with nonexistent Header when call "ReactiveRequestHolder.getHeaders"

Posted by GitBox <gi...@apache.org>.
mm23504570 commented on issue #6648:
URL: https://github.com/apache/skywalking/issues/6648#issuecomment-809426231


   I configed SpringMVCPluginConfig.Plugin.Http.INCLUDE_HTTP_HEADERS to collect header use WebFlex. 
   If Headers does not exist in ServerHttpRequest cause `Collections.enumeration` throw NullPointerException. Because `Collections.enumeration` need not null param.
   
   https://github.com/apache/skywalking/blob/7c69ea889ee7a24c0049ffface3a04409b415af4/apm-sniffer/apm-sdk-plugin/spring-plugins/mvc-annotation-commons/src/main/java/org/apache/skywalking/apm/plugin/spring/mvc/commons/interceptor/AbstractMethodInterceptor.java#L225


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [skywalking] wu-sheng commented on issue #6648: NullPointerException with nonexistent Header when call "ReactiveRequestHolder.getHeaders"

Posted by GitBox <gi...@apache.org>.
wu-sheng commented on issue #6648:
URL: https://github.com/apache/skywalking/issues/6648#issuecomment-809407833


   Seems version or usage unsupported. You could check our plugin tests in https://github.com/apache/skywalking/tree/master/test/plugin/scenarios
   You may find some clues.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [skywalking] wu-sheng closed issue #6648: NullPointerException with nonexistent Header when call "ReactiveRequestHolder.getHeaders"

Posted by GitBox <gi...@apache.org>.
wu-sheng closed issue #6648:
URL: https://github.com/apache/skywalking/issues/6648


   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [skywalking] wu-sheng commented on issue #6648: NullPointerException with nonexistent Header when call "ReactiveRequestHolder.getHeaders"

Posted by GitBox <gi...@apache.org>.
wu-sheng commented on issue #6648:
URL: https://github.com/apache/skywalking/issues/6648#issuecomment-809437255


   Oh, if you mean to change lines of codes to avoid a NPE, you could submit a pull request, which would be more clear.
   Reporting a NPE issue usually is hard to follow.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org