Hi Alejandro,

 

I believe we have now fixed the remaining issues causing a potential block. 
Upgrading to version 2.0.1 should really help.

 

However, I’ve just implemented the timeout idea suggested by Tim for extra 
safety. In case the response doesn’t arrive after 1 minute, the calling thread 
unblocks and sets the response status to CONNECTOR_ERROR_INTERNAL with a proper 
description.

 

This has been checked in both SVN trunk and 2.0 branch.

 

Best regards,
Jerome
--
Restlet ~ Founder and Technical Lead ~  <http://www.restlet.org/> 
http://www.restlet.o​rg
Noelios Technologies ~  <http://www.noelios.com/> http://www.noelios.com

 

 

 

 

De : [email protected] [mailto:[email protected]] De la part de Tim Peierls
Envoyé : jeudi 8 juillet 2010 15:44
À : [email protected]
Objet : Re: ClientResource not propagating exceptions and becoming unusable

 

Can't answer the questions in the original post, just responding to the 
question about the blocked thread stack trace.

 

This is BaseClientHelper.handle blocking indefinitely on a CountDownLatch.I've 
already expressed concern about this method. It feels as though there are too 
many failure modes to be able to guarantee that the handling thread will 
unblock. And it's important to ensure that it *is* eventually unblocked -- you 
don't want to lose threads this way.

 

Since I don't really understand what's going on in BaseClientHelper and 
friends, I don't know how to fix it, but maybe consider making this a timed 
wait? And treat a timeout as a sign that something is seriously wrong.

 

--tim

On Wed, Jul 7, 2010 at 2:07 PM, Alejandro Raiczyk <[email protected]> wrote:

I've found where the client locks, do you know is this?

2010/7/7 Alejandro Raiczyk <[email protected]>

 

Hi all, 

I'm using a ClientResource like this:

TracesService service = ClientResource.create(this.url, TracesService.class);

where 

/**
* 
*/
package net.technisys.monitoring.services;

import net.technisys.monitoring.data.restlet.ServerResourceResponse;
import net.technisys.monitoring.data.restlet.TracesPostRequest;

import org.restlet.resource.Get;
import org.restlet.resource.Post;

/**
* @author alejandro
* 
*/
public interface TracesService {

@Post("json")
public ServerResourceResponse store(TracesPostRequest request);

@Get("json")
public ServerResourceResponse list();

}



I just use one service instance in a synchronized fashion. Everything works 
fine until an error in the communication between client and server occurs, i.e. 
server shutdown or even a 404 response.

Then the client sends this kind of exceptions to the log:

07/07/2010 00:22:34 org.restlet.engine.http.connector.Connection writeMessage
ADVERTENCIA: Exception while writing the message body.
java.net.SocketException: Broken pipe
at java.net.SocketOutputStream.socketWrite0(Native Method)
at java.net.SocketOutputStream.socketWrite(SocketOutputStream.java:92)
at java.net.SocketOutputStream.write(SocketOutputStream.java:136)
at java.io.BufferedOutputStream.flushBuffer(BufferedOutputStream.java:65)
at java.io.BufferedOutputStream.flush(BufferedOutputStream.java:123)
at 
org.restlet.engine.http.io.ChunkedOutputStream.flush(ChunkedOutputStream.java:116)
at sun.nio.cs.StreamEncoder$CharsetSE.implFlush(StreamEncoder.java:410)
at sun.nio.cs.StreamEncoder.flush(StreamEncoder.java:152)
at java.io.OutputStreamWriter.flush(OutputStreamWriter.java:213)
at 
org.codehaus.jackson.impl.WriterBasedGenerator.close(WriterBasedGenerator.java:712)
at 
org.codehaus.jackson.map.ObjectMapper._configAndWriteValue(ObjectMapper.java:1208)
at org.codehaus.jackson.map.ObjectMapper.writeValue(ObjectMapper.java:1015)
at 
org.restlet.ext.jackson.JacksonRepresentation.write(JacksonRepresentation.java:205)
at 
org.restlet.representation.WriterRepresentation.write(WriterRepresentation.java:104)
at 
org.restlet.engine.http.connector.Connection.writeMessageBody(Connection.java:888)
at 
org.restlet.engine.http.connector.Connection.writeMessage(Connection.java:832)
at 
org.restlet.engine.http.connector.ClientConnection.writeMessage(ClientConnection.java:297)
at 
org.restlet.engine.http.connector.Connection.writeMessages(Connection.java:969)
at org.restlet.engine.http.connector.Controller$1.run(Controller.java:80)
at 
java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:651)
at 
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:676)
at java.lang.Thread.run(Thread.java:595)
07/07/2010 00:22:34 org.restlet.engine.http.connector.ClientConnection 
writeMessage
INFO: An exception occured writing the request
java.net.SocketException: Broken pipe
at java.net.SocketOutputStream.socketWrite0(Native Method)
at java.net.SocketOutputStream.socketWrite(SocketOutputStream.java:92)
at java.net.SocketOutputStream.write(SocketOutputStream.java:136)
at java.io.BufferedOutputStream.flushBuffer(BufferedOutputStream.java:65)
at java.io.BufferedOutputStream.flush(BufferedOutputStream.java:123)
at 
org.restlet.engine.http.io.ChunkedOutputStream.flush(ChunkedOutputStream.java:116)
at sun.nio.cs.StreamEncoder$CharsetSE.implFlush(StreamEncoder.java:410)
at sun.nio.cs.StreamEncoder.flush(StreamEncoder.java:152)
...
...

and then, that client doesn't send messages to the server anymore.

Questions:

1) Why does the ClientResource itself handle the exception and output it to the 
log instead of throwing an exception so the programmer can handle it and do 
whatever it takes? If this is the expected behavior, how can I know when an 
exception occurs? is there an error code or something like that?
2) Why does the service instance became unusable? How can I avoid this? 

What I want is to always have the same service instance, know when there is an 
error when a method is being called on it, and that the instance is always 
available, by available I mean working. I'm new to restlet so maybe I'm missing 
something.

Thanks in advance.

Alejandro

-- 
Alejandro DamiᮠRaiczyk




-- 
Alejandro DamiᮠRaiczyk

------------------------------------------------------
http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=2664335

Reply via email to