Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Agile forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

get "java.net.SocketException: socket closed", even if i am using HTTP connection

 
Dupont Girard
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, I encountered an exception by executing this code:





The line of code that make this exception is: "int taille = input.read(mot);", if i copy it into the Servlet part, it works well, but i think that the Servlet shall not be in charge of these.

The exception is:
"java.net.SocketException: socket closed" even if i am not using Sockets, but HTTP.
I think that the "input" in RequestStatement's method contains no value "null"

Help me



 
Chris Beckey
Ranch Hand
Posts: 116
Eclipse IDE Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I believe that what is happening is that the RequestStatement thread is not finishing by the time the HTTP thread, which the servlet code is running on is finishing and closing the connection.
In this case I don't see a reason to start the second thread because you would have to synchronize and wait for it to complete before returning from the servlets doXXX method anyway. It will also complicate error handling, redirection and including content should that ever become necessary.
 
Dupont Girard
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Chris of your answer. You're right, i just put a join() on my thread and it works
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic