Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/375.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Spring RestTemplate-获取java.io.EOFException:null,执行简单GET请求时解析HTTP请求头时出错_Java_Spring_Spring Boot_Resttemplate - Fatal编程技术网

Spring RestTemplate-获取java.io.EOFException:null,执行简单GET请求时解析HTTP请求头时出错

Spring RestTemplate-获取java.io.EOFException:null,执行简单GET请求时解析HTTP请求头时出错,java,spring,spring-boot,resttemplate,Java,Spring,Spring Boot,Resttemplate,我想使用restemplate在我自己的应用程序中执行一个直通端点,但当我这样做时,我得到了以下错误/异常: o.apache.coyote.http11.Http11Processor:解析HTTP请求头时出错 java.io.EOFException:null 在org.apache.tomcat.util.net.niodendpoint$NioSocketWrapper.fillReadBuffer(niodendpoint.java:1229)~[tomcat-embed-core-9

我想使用restemplate在我自己的应用程序中执行一个直通端点,但当我这样做时,我得到了以下错误/异常:

o.apache.coyote.http11.Http11Processor:解析HTTP请求头时出错
java.io.EOFException:null
在org.apache.tomcat.util.net.niodendpoint$NioSocketWrapper.fillReadBuffer(niodendpoint.java:1229)~[tomcat-embed-core-9.0.27.jar:9.0.27]
这是我的端点类:

@RequestMapping(“/wakeup”)
@RestController
公共类唤醒资源{
私有记录器Logger=LoggerFactory.getLogger(ApplicationWakeUpScheduller.class);
@GetMapping
public@ResponseBody字符串唤醒(){
返回“我醒了!”;
}
}
这是我的应用程序类,其中端点被调用:


@SpringBoot应用程序
公共类NovaVidaBudgetApplication实现CommandLineRunner{
公共静态void main(字符串[]args){
run(NovaVidaBudgetApplication.class,args);
}
@凌驾
公共无效运行(字符串…参数)引发异常{
唤醒应用程序();
}
公共无效唤醒应用程序(){
HttpHeaders=getHttpHeaders();
最终RestTemplate RestTemplate=新RestTemplate();
最终字符串url=”http://localhost:8080/wakeup";
HttpEntity requestEntity=新的HttpEntity(标头);
交换(url,HttpMethod.GET,requestEntity,String.class);
}
私有HttpHeaders getHttpHeaders(){
HttpHeaders=新的HttpHeaders();
headers.setContentType(MediaType.TEXT\u PLAIN);
返回标题;
}
}
当我立即执行此应用程序时,端点被调用,我得到一个200状态响应,但这种恼人的
EOFEException
也会发生。以下是包含异常的完整日志:

2019-11-17 18:47:34.294信息27233---[nio-8080-exec-1]o.s.web.servlet.DispatcherServlet:在10毫秒内完成初始化
2019-11-17 18:47:34.305调试27233---[nio-8080-exec-1]org.apache.tomcat.util.http.Parameters:将编码设置为UTF-8
2019-11-17 18:47:34.305调试27233---[nio-8080-exec-1]o.s.web.servlet.DispatcherServlet:GET“/api/v1/wakeup”,参数={}
2019-11-17 18:47:34.308调试27233---[nio-8080-exec-1]pertySourceRequestMappingHandlerMapping:查找处理程序的路径:/wakeup
2019-11-17 18:47:34.311调试27233---[nio-8080-exec-1]s.w.s.m.m.a.RequestMappingHandlerMapping:映射到com.codeonblue.novavidabudget.resources.WakeUpResource#wakeup()
2019-11-17 18:47:34.322调试27233---[nio-8080-exec-1]c.c.n.s.ApplicationWakeUpScheduller:唤醒应用程序
2019-11-17 18:47:34.331调试27233---[nio-8080-exec-1]m.m.a.RequestResponseBodyMethodProcessor:使用“text/plain”,给定[text/plain,application/json,application/*+json,*/*]并支持[text/plain,*/*,application/json,application/*+json]
2019-11-17 18:47:34.331调试27233---[nio-8080-exec-1]m.m.a.RequestResponseBodyMethodProcessor:编写[“我醒了!”]
2019-11-17 18:47:34.342调试27233---[restartedMain]s.n.www.protocol.http.HttpURLConnection:sun.net.www。MessageHeader@8adddc44成对:{null:HTTP/1.1200}{Content Type:text/plain;charset=ISO-8859-1}{Content Length:11}{Date:Sun,2019年11月17日20:47:34 GMT}
2019-11-17 18:47:34.343调试27233---[restartedMain]o.s.web.client.RestTemplate:响应200 OK
2019-11-17 18:47:34.343调试27233---[nio-8080-exec-1]o.s.web.servlet.DispatcherServlet:完成200 OK
2019-11-17 18:47:34.349调试27233---[restartedMain]o.s.web.client.RestTemplate:读取[java.lang.String]为“text/plain;charset=ISO-8859-1”
2019-11-17 18:47:34.354调试27233---[restartedMain]c.c.n.s.ApplicationWakeUpScheduler:结束http调用。
2019-11-17 18:47:34.354调试27233---[restartedMain]o.s.boot.devtools.restart.Restarter:为线程[main,5,main]创建新的重新启动程序
2019-11-17 18:47:34.354调试27233---[restartedMain]o.s.boot.devtools.restart.Restarter:立即重新启动应用程序
2019-11-17 18:47:34.354调试27233---[restartedMain]o.s.boot.devtools.restart.Restarter:创建了RestartClassLoader org.springframework.boot.devtools.restart.classloader。RestartClassLoader@4d595ac5
2019-11-17 18:47:34.354调试27233---[restartedMain]o.s.boot.devtools.restart.Restarter:使用URL启动应用程序com.codeonblue.novavidabudget.NovaVidaBudgetApplication[文件:/home/james/appz/1-current-projects/springboot/novavidabudget/target/classes/]
2019-11-17 18:47:34.358调试27233---[nio-8080-exec-1]o.a.tomcat.util.net.socketTrapperbase:Socket:[org.apache.tomcat.util.net.niodendpoint$NioSocketWrapper@4330282d:org.apache.tomcat.util.net。NioChannel@1d148f25:java.nio.channels.SocketChannel[connected local=/127.0.0.1:8080 remote=/127.0.0.1:40364]],从缓冲区读取:[0]
2019-11-17 18:47:34.358调试27233---[nio-8080-exec-1]org.apache.tomcat.util.net.NioEndpoint:Socket:[org.apache.tomcat.util.net.NioEndpoint$NioSocketWrapper@4330282d:org.apache.tomcat.util.net。NioChannel@1d148f25:java.nio.channels.SocketChannel[connected local=/127.0.0.1:8080 remote=/127.0.0.1:40364]],直接从套接字读取:[0]
2019-11-17 18:47:34.358调试27233---[nio-8080-exec-1]o.apache.coyote.http11.http11处理器:套接字:[org.apache.tomcat.util.net.niodendpoint$NioSocketWrapper@4330282d:org.apache.tomcat.util.net。NioChannel@1d148f25:java.nio.channels.SocketChannel[connected local=/127.0.0.1:8080 remote=/127.0.0.1:40364]],状态为[OPEN_READ],状态为:[公开]
2019-11-17 18:47:39.356调试27233---[nio-8080-exec-2]o.a.tomcat.util.net.socketTrapperbase:Socket:[org.apache.tomcat.util.net.niodendpoint$NioSocketWrapper@43