On Thu, 2008-11-06 at 23:58 +0530, hemant wrote:
> On Thu, Nov 6, 2008 at 7:19 PM, Oleg Kalnichevski <[EMAIL PROTECTED]> wrote:
> >
> > One needs to differentiate two types of exceptions:
> >
> > (1) I/O and HTTP protocol exceptions that occur in the context of one
> > particular connection, which usually result in termination of that
> > connection but do not affect other connections and the I/O reactor
> > itself
> >
> > (2) Runtime and I/O connections that are fatal and usually result in
> > termination of the I/O reactor along with all active connections.
> >
> > What kind of exception are you referring to?
>
> Okay, following method is from class CustomRequestHandler, which
> subclasses NHttpRequestExecutionHandler :
>
> def responseEntity(response: HttpResponse,context: HttpContext):
> ConsumingNHttpEntity = {
> val requestAttachment =
> context.getAttribute("request_attachment").asInstanceOf[RequestAttachment[GenericAmtdRequest]]
> val entity = response.getEntity()
> Log.log("Status is : " + response.getStatusLine())
> val length = entity.getContentLength()
> Log.log("Length of entity is : " + length)
> new CustomEntity(requestAttachment)
> }
>
> And this is my CustomEntity class:
>
> class CustomEntity(request: RequestAttachment[GenericAmtdRequest])
> extends ConsumingNHttpEntity {
> val parser = new NewsParser(request.request.sessionId)
>
> def consumeContent(decoder: ContentDecoder,ioctrl: IOControl): Unit = {
> Log.log("Calling Consuming content")
> var allRead = false
>
> while(!allRead) {
> val t = ByteBuffer.allocate(8*1024)
> val count = decoder.read(t)
> if(count <= 0) allRead = true
> else {
> Log.log("****** Number of Bytes read is : " + count)
> parser.add(t)
> }
> }
> }
>
> def finish() = {
> Log.log("Finished reading data")
> }
>
> def consumeContent() = { }
>
> def getContent() = null
> def getContentEncoding() = null
> def getContentLength() = -1
> def getContentType() = null
> def isChunked() = false
> def isStreaming() = false
> def isRepeatable() = false
> def writeTo(in: OutputStream) = { }
> }
>
>
> NewsParser is a state machine parser, which parses incoming bytes and
> creates News objects (which is not relevant to our discussion I
> think).
>
> So, I am talking about Exception thats thrown inside NewsParser class
> because I had few runtime problems with my code that does parsing in
> #add method(nothing todo with any IOException and all). Unhandled
> exceptions inside that class is being ignored and thats my problem (I
> am yet to test if those exceptions are being captured by EventListener
> properly, because since then, I have fixed those unhandled exceptions,
> and I am not getting them anymore).
>
Any RuntimeException should result in a shutdown of the I/O reactor
unless there is a custom exception handler that discards
RuntimeExceptions as non fatal.
For details see
http://wiki.apache.org/HttpComponents/HttpCoreTutorial#head-ce211cb56b752e6b4db8f5dceca775d3a16fee66
I'll try to put together a test case to reproduce the scenario and will
add to the project's test suite.
Oleg
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]