History | Log In     View a printable version of the current page.  
Issue Details (XML | Word | Printable)

Key: JRUBY-1417
Type: Bug Bug
Status: Closed Closed
Resolution: Fixed
Priority: Critical Critical
Assignee: Charles Oliver Nutter
Reporter: ruivaldo neto
Votes: 0
Watchers: 1
Operations

If you were logged in you would be able to see more operations.
JRuby

Wrong var name inside thread dosent popup exception. With -d optino enabled.

Created: 11/Oct/07 08:36 AM   Updated: 22/Dec/07 06:28 AM
Component/s: Interpreter
Affects Version/s: JRuby 1.0.1
Fix Version/s: JRuby 1.1b1, JRuby 1.0.2

Time Tracking:
Not Specified

Environment: Debian Linux, Java 6.

Testcase included: yes


 Description  « Hide
This method, when used with MRI pop upīs a exception:

##

  1. Executar reenvio
  2. Pega o primeiro item da lista de reenvio a cada uma hora
  3. E tenta enviar. Se conseguir, remove-o da lista.
    def executar_reenvio()
    while true
    item_reenvio = proximo_reenvio()

#$log.debug(item_reenvio.inspect)
unless item_reenvio.nil? || item_reenvio.empty?
#$log.info("Reenviando: #{item_reenvio[:endereco]} #{item_reenvio[:parametros].inspect}")

resposta = self.reenvio(item_reenvio[:endereco], item_reenvio[:parametros])
if resposta == 200

    1. This line is bogus, look: item_reeEnvio
      $log.info("Reenviado com exito: #{item_reeenvio[:endereco]} - #{item_reenvio[:parametros].inspect}")
    2. prosseguir_lista_reenvio()
      $log.debug(carregar_lista_reenvio())
      else
      #$log.info("Falha ao reenviar: #{item_reenvio[:endereco]} - #{item_reenvio[:parametros].inspect.inspect}")
      end

else
#$log.info("Nao ha items setados para reenvio")
end

sleep_minutos(10) # Dorme por uma hora
end
end

00S00:/home/ruivaldo/Codes/Ruby/ColetorSisope# ruby -d sisope.rb
I, 10:39:10#3299 INFO – : Iniciando coletor
Exception `NameError' at sisope.rb:150 - undefined local variable or method `item_reeenvio' for #<Coletor:0xa7be99a0>
sisope.rb:150:in `executar_reenvio': undefined local variable or method `item_reeenvio' for #<Coletor:0xa7be99a0> (NameError)
from sisope.rb:250:in `iniciar_coleta'
from sisope.rb:250:in `initialize'
from sisope.rb:250:in `new'
from sisope.rb:250:in `iniciar_coleta'
from sisope.rb:264
00S00:/home/ruivaldo/Codes/Ruby/ColetorSisope#

But with jruby 1.0.1, with -d enable, it just kills the thread and keeps executing:

00S00:/home/ruivaldo/Codes/Ruby/ColetorSisope# ./jruby/bin/jruby -v
ruby 1.8.5 (2007-08-23 rev 4201) [i386-jruby1.0.1]

00S00:/home/ruivaldo/Codes/Ruby/ColetorSisope# ./jruby/bin/jruby -d sisope.rb
/home/ruivaldo/jruby/lib/ruby/1.8/net/http.rb:280 warning: global variable `$;' not initialized
file:/home/ruivaldo/jruby/lib/jruby.jar!/builtin/javasupport/proxy/concrete.rb:5 warning: `*' interpreted as argument prefix
file:/home/ruivaldo/jruby/lib/jruby.jar!/builtin/javasupport/proxy/interface.rb:7 warning: `&' interpreted as argument prefix
I, 10:39:49#22591049 INFO – : Iniciando coletor
<script>:0 warning: Useless use of a literal in void context.
<script>:0 warning: Useless use of a literal in void context.

The complete source code is disponible into:

http://pastebin.com/f6f72ce90



 All   Comments   Work Log   Change History      Sort Order: Ascending order - Click to sort in descending order
ruivaldo neto - 11/Oct/07 01:16 PM
It can be reproduced with this snippet:

ruivaldo@00S00:~$ ruby -d -e "Thread.new {raise}"
Exception `RuntimeError' at -e:1 -
-e:1: unhandled exception
from -e:1:in `initialize'
from -e:1:in `new'
from -e:1
ruivaldo@00S00:~$ jruby -d -e "Thread.new {raise}"
ruivaldo@00S00:~$

Snnipet made by Headius.


Charles Oliver Nutter - 11/Oct/07 01:55 PM
Fixed on both trunk and 1.0 branch. Note that because JRuby starts up ruby threads as daemon threads, some simple cases of a thread causing an error may be masked by the main thread exiting early. This is by design; if the threads are not started as daemon, they end up keeping the process running. A separate bug can be filed for the current behavior if it is a problem.