Ticket #131 (new defect)

Opened 1 month ago

Last modified 1 month ago

NullPointerException sending message with EmReactor

Reported by: uwe@kubosch.no Assigned to:
Priority: critical Milestone:
Keywords: Cc:

Description

Hi!

I am using tmm1-amqp-0.6.4 and EventMachine 0.12.10 to send model updates from ActiveRecord? with JRuby 1.4.0. This runs fine for a while, 5-50 minutes, then fails with a NullPointerException? in EventableSocketChannel?:

java.lang.NullPointerException?: null com/rubyeventmachine/EventableSocketChannel.java:206:in `writeOutboundData' com/rubyeventmachine/EmReactor.java:275:in `isWritable' com/rubyeventmachine/EmReactor.java:200:in `processIO' com/rubyeventmachine/EmReactor.java:110:in `run' /Users/uwe/workspace/aifudis/aifudis.admin/platform/jruby-1.4.0RC3/lib/ruby/gems/1.8/gems/eventmachine-0.12.10-java/lib/jeventmachine.rb:112:in `run_machine' /Users/uwe/workspace/aifudis/aifudis.admin/platform/jruby-1.4.0RC3/lib/ruby/gems/1.8/gems/eventmachine-0.12.10-java/lib/eventmachine.rb:261:in `run'

It seems LinkedList?<ByteBuffer?> outboundQ.getFirst() returns NULL, and this is not handled. Maybe a threading issue?

Change History

11/10/09 04:05:48 changed by uwe@kubosch.no

I have been looking at the code for EventableSocketChannel? and as far as I can see, the use of outboundQ is not thread safe. When I wrap the LinkedList? outboundQ with Collections.synchronizedList(...), and replace getFirst() with get(0), and addLast() with add(), everyting works fine.

Is there a reason for EventableSocketChannel? not to be thread safe? Should it be synchronized externall by EmReactor??