Hannes,

Firstly, I really, really wouldn't write your code like that...

Things of note:
- two defs inside defs... you usually wouldnt do this without a good reason 
(like SHtml.submit(whatever _))
- dont use while loops. period. you have a List[T], use foreach if you have a 
unit operation

def joinAll(orders: List[LimitOrder]): Unit = 
  orders.foreach(order => {
    // your logic here
  })

You should look to remove a lot of that boiler plate... its looks very javaish 
and mutable. Generally speaking, scala programmers avoid mutable state like one 
would avoid bubonic plague.

Before worrying about the errors, id change your code, then take another 
look... its almost certainly this bad organisation causing the issues.

Cheers, Tim



On 29 Nov 2009, at 15:24, Hannes wrote:

> Hey Lifters,
> 
> I've some really strange things going on here. Please consider this 
> method definition. I've put alot of print "debug" statements between 
> other statements. There's a while-loop that only starts, when the given 
> list (orders) is not empty. It stops when "done" is set to true. So far, 
> so good. Than, have a look at the Lift output. I put in a comment, 
> pointing out where the program runs into the while loop.
> 
> What really shocks me, are these print statements :
> 
> before done=false                                                             
>                                   
> after done=true                                                               
>                                   
> i += 1                                                                        
>                                   
> outside while                                                                 
>                                   
> INFO - Service request (GET) / took 121 Milliseconds                          
>                                   
> start of joinAll!                                                             
>   
> 
> 
> The loop ends with "outside while" and than the method gets called again 
> immediately! But who calls it? I don't....
> 
> Any ideas?
> 
> thanks.
> 
> 
> 
> ---------------------------- method definition 
> --------------------------------------------------------------------------
> 
> def joinOtherOrders: Unit = {
> 
>        def joinAll(orders: List[LimitOrder]) = {
> 
>            println("start of joinAll!")
> 
>            var done = false
> 
>            var i = 0
> 
>            while (!orders.isEmpty && !done) {
> 
>                println("i=" + i + ", " + "orders.isEmpty=" + orders.isEmpty + 
> ", " + "done=" + done)
> 
>                if (this.lots.is == orders(i).lots.is){
> 
>                    println("case-1")
> 
>                    println("this=" + this + ", orders(i)=" + orders(i))
> 
>                    this.open(orders(i))
> 
>                    done = true
> 
>                }
> 
>                if (this.lots.is < orders(i).lots.is){
> 
>                    println("case-2")
> 
>                    println("this=" + this + ", orders(i)=" + orders(i))
> 
>                    orders(i).reduceLots(this.lots.is)
> 
>                    val newOrder = orders(i).cloneWith(this.lots.is)
> 
>                    newOrder.save
> 
>                    this.open(newOrder)
> 
>                    println("before done=" + done)
> 
>                    done = true
> 
>                    println("after done=" + done)
> 
>                }
> 
>                if (this.lots.is > orders(i).lots.is){
> 
>                    println("case-3")
> 
>                    println("this=" + this + ", orders(i)=" + orders(i))
> 
>                    this.reduceLots(orders(i).lots.is)
> 
>                    val newOrder = this.cloneWith(orders(i).lots.is)
> 
>                    newOrder.save
> 
>                    newOrder.open(orders(i))
> 
>                }
> 
>                i += 1
> 
>                println("i += 1")
> 
>            }
> 
>            println("outside while")
> 
>        }
> 
>        def findLimitOrdersById: List[LimitOrder]  =
> 
>            this.findCandidates.map(x => LimitOrderMetaObj.findAll(
> 
>                    By(LimitOrderMetaObj.id, x)).head)
> 
>        joinAll(findLimitOrdersById)
> 
>    }
> 
> 
> ---------- Lift Output 
> -------------------------------------------------------------------------------
> 
> 
> [INFO] Started Jetty Server                                                   
>                                   
> [INFO] Starting scanner at interval of 5 seconds.                             
>                                   
> INFO - Service request (GET) /comet_request/54834680365/y7kybsmuyv1g took 64 
> Milliseconds                       
> INFO - Service request (GET) /comet_request/85319966940/y7kybsmuyv1g took 23 
> Milliseconds                       
> INFO - Service request (GET) /favicon.ico took 86 Milliseconds                
>                                   
> INFO - Service request (GET) /comet_request/41521581405/y7kybsmuyv1g took 48 
> Milliseconds                       
> INFO - Service request (GET) /comet_request/93176242746/y7kybsmuyv1g took 7 
> Milliseconds                        
> INFO - Service request (GET) /favicon.ico took 38 Milliseconds                
>                                   
> INFO - Service request (GET) /favicon.ico took 5 Milliseconds                 
>                                   
> INFO - Service request (GET) / took 551 Milliseconds                          
>                                   
> INFO - Service request (GET) /comet_request/81361316835/y7kybsmuyv1g took 9 
> Milliseconds                        
> INFO - Service request (GET) /favicon.ico took 16 Milliseconds                
>                                   
> INFO - Service request (GET) / took 61 Milliseconds                           
>                                   
> INFO - Service request (GET) /comet_request/76898140873/y7kybsmuyv1g took 30 
> Milliseconds                       
> INFO - Service request (GET) /comet_request/e8jesgmo10oq/cometAjax.js took 14 
> Milliseconds                      
> INFO - Service request (GET) / took 354 Milliseconds                          
>                                   
> INFO - Service request (GET) / took 734 Milliseconds                          
>                                   
> INFO - Service request (GET) / took 484 Milliseconds                          
>                                   
> INFO - Service request (GET) /images/ajax-loader.gif took 7 Milliseconds      
>                                   
> INFO - Service request (GET) /favicon.ico took 4 Milliseconds                 
>                                   
> INFO - Service request (GET) /comet_request/78026241833/e8jesgmo10oq took 55 
> Milliseconds                       
> INFO - Service request (GET) /comet_request/28225538857/e8jesgmo10oq took 600 
> Milliseconds                      
> INFO - Service request (GET) /user_mgt/sign_up took 711 Milliseconds          
>                                   
> INFO - Service request (GET) /images/ajax-loader.gif took 2 Milliseconds      
>                                   
> INFO - Service request (GET) /user_mgt/login took 38 Milliseconds             
>                                   
> INFO - Service request (GET) /images/ajax-loader.gif took 2 Milliseconds      
>                                   
> INFO - Service request (POST) /user_mgt/login took 122 Milliseconds           
>                                   
> INFO - Service request (GET) / took 93 Milliseconds                           
>                                   
> INFO - Service request (GET) /images/ajax-loader.gif took 1 Milliseconds      
>                                   
> INFO - Service request (GET) /comet_request/42818301584/e8jesgmo10oq took 
> 1144 Milliseconds                     
> INFO - Service request (GET) /limitorder/list took 99 Milliseconds            
>                                   
> INFO - Service request (GET) /images/ajax-loader.gif took 1 Milliseconds      
>                                   
> INFO - Service request (GET) /limitorder/create took 77 Milliseconds          
>                                   
> INFO - Service request (GET) /images/ajax-loader.gif took 2 Milliseconds      
>                                   
> INFO - Service request (POST) /limitorder/create took 134 Milliseconds        
>                                   
> start of joinAll!                                                             
>                                   
> outside while                                                                 
>                                   
> INFO - Service request (GET) /limitorder/list took 270 Milliseconds           
>                                   
> INFO - Service request (GET) /images/ajax-loader.gif took 2 Milliseconds      
>                                   
> INFO - Service request (GET) /limitorder/create took 51 Milliseconds          
>                                   
> INFO - Service request (GET) /images/ajax-loader.gif took 2 Milliseconds      
>                                   
> INFO - Service request (POST) /limitorder/create took 11 Milliseconds         
>                                   
> start of joinAll!                                                             
>                                   
> outside while                                                                 
>                                   
> INFO - Service request (GET) /limitorder/list took 56 Milliseconds            
>                                   
> INFO - Service request (GET) /images/ajax-loader.gif took 1 Milliseconds      
>                                   
> INFO - Service request (GET) /user_mgt/logout took 21 Milliseconds            
>                                   
> INFO - The CometActor org.tobster.comet.mar...@c595bcd Received Shutdown      
>                                   
> INFO - Service request (GET) / took 82 Milliseconds                           
>                                   
> INFO - Service request (GET) /images/ajax-loader.gif took 1 Milliseconds      
>                                   
> INFO - Service request (GET) /comet_request/16awv92sf1zgl/cometAjax.js took 2 
> Milliseconds                      
> INFO - Service request (GET) /comet_request/21077236431/16awv92sf1zgl took 41 
> Milliseconds                      
> INFO - Service request (GET) /comet_request/89548874922/16awv92sf1zgl took 
> 817 Milliseconds                     
> INFO - Service request (GET) /user_mgt/sign_up took 325 Milliseconds          
>                                   
> INFO - Service request (GET) /images/ajax-loader.gif took 1 Milliseconds      
>                                   
> INFO - Service request (POST) /user_mgt/sign_up took 69 Milliseconds          
>                                   
> INFO - Service request (GET) / took 21 Milliseconds                           
>                                   
> INFO - Service request (GET) /images/ajax-loader.gif took 1 Milliseconds      
>                                   
> INFO - Service request (GET) /comet_request/33304915285/16awv92sf1zgl took 
> 2485 Milliseconds                    
> INFO - Service request (GET) /limitorder/create took 102 Milliseconds         
>                                   
> INFO - Service request (GET) /images/ajax-loader.gif took 2 Milliseconds      
>                                   
> INFO - Service request (POST) /limitorder/create took 33 Milliseconds         
>                                   
> start of joinAll!                                                             
>                                   
> outside while                                                                 
>                                   
> INFO - Service request (GET) / took 42 Milliseconds                           
>                                   
> INFO - Service request (GET) /images/ajax-loader.gif took 2 Milliseconds      
>                                   
> INFO - Service request (GET) /comet_request/43041247578/16awv92sf1zgl took 
> 1270 Milliseconds                    
> INFO - Service request (GET) /limitorder/create took 72 Milliseconds          
>                                   
> INFO - Service request (GET) /images/ajax-loader.gif took 2 Milliseconds      
>                                   
> INFO - Service request (POST) /limitorder/create took 34 Milliseconds         
>                                   
> start of joinAll!                                                             
>                                   
> outside while                                                                 
>                                   
> INFO - Service request (GET) / took 28 Milliseconds                           
>                                   
> INFO - Service request (GET) /images/ajax-loader.gif took 1 Milliseconds      
>                                   
> INFO - Service request (GET) /comet_request/94649970499/16awv92sf1zgl took 
> 2455 Milliseconds                    
> INFO - Service request (GET) /limitorder/create took 25 Milliseconds          
>                                   
> INFO - Service request (GET) /images/ajax-loader.gif took 1 Milliseconds      
>                                   
> INFO - Service request (POST) /limitorder/create took 10 Milliseconds         
>                                   
> 
> ####### Interesting things start here #####################################
> 
> start of joinAll!                                                             
>                                   
> i=0, orders.isEmpty=false, done=false                                         
>                                   
> case-3                                                                        
>                                   
> this={ owner=2, type=, lots=2, market= }, orders(i)={ owner=1, type=SELL, 
> lots=1, market=Beginner }             
> computeAndSetMarketValue                                                      
>                                   
> computeNewMarketValue                                                         
>                                   
> setMarketValue from ID=1 to: 10001                                            
>                                   
> findAndCloseOpenOrder: found=0                                                
>                                   
> findAndCloseOpenOrder: found=0                                                
>                                   
> i += 1                                                                        
>                                   
> i=1, orders.isEmpty=false, done=false                                         
>                                   
> case-2                                                                        
>                                   
> this={ owner=2, type=, lots=1, market= }, orders(i)={ owner=1, type=SELL, 
> lots=2, market=Beginner }             
> computeAndSetMarketValue                                                      
>                                   
> computeNewMarketValue                                                         
>                                   
> setMarketValue from ID=1 to: 10001                                            
>                                   
> findAndCloseOpenOrder: found=0                                                
>                                   
> findAndCloseOpenOrder: found=0                                                
>                                   
> before done=false                                                             
>                                   
> after done=true                                                               
>                                   
> i += 1                                                                        
>                                   
> outside while                                                                 
>                                   
> INFO - Service request (GET) / took 121 Milliseconds                          
>                                   
> start of joinAll!                                                             
>                                   
> i=0, orders.isEmpty=false, done=false                                         
>                                   
> case-1                                                                        
>                                   
> this={ owner=2, type=BUY, lots=1, market=Beginner }, orders(i)={ owner=1, 
> type=SELL, lots=1, market=Beginner }  
> computeAndSetMarketValue
> computeNewMarketValue
> setMarketValue from ID=1 to: 10001
> findAndCloseOpenOrder: found=0
> findAndCloseOpenOrder: found=0
> i += 1
> outside while
> start of joinAll!
> outside while
> INFO - Service request (GET) /images/ajax-loader.gif took 1 Milliseconds
> 
> --
> 
> You received this message because you are subscribed to the Google Groups 
> "Lift" group.
> To post to this group, send email to lift...@googlegroups.com.
> To unsubscribe from this group, send email to 
> liftweb+unsubscr...@googlegroups.com.
> For more options, visit this group at 
> http://groups.google.com/group/liftweb?hl=en.
> 
> 
> 

--

You received this message because you are subscribed to the Google Groups 
"Lift" group.
To post to this group, send email to lift...@googlegroups.com.
To unsubscribe from this group, send email to 
liftweb+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/liftweb?hl=en.


Reply via email to