Marc Palmer | 2 Jan 2006 16:32
Picon
Gravatar

Argh going round in circles - what is this error?


Hiya,

Happy new year to all.

I'm trying to run some Groovy unit tests in IntelliJ IDEA using the  
plugin, and this used to work... but now no matter what test case I  
run I get:

Caught: UNCAUGHT EXCEPTION: null

That's all it says in the output. Not very helpful. No trace :(

I can run scripts OK, its just test cases -that rely on another  
class- that won't. Even if I empty out those other classes used by  
the test, so there is only a trivial static test { println "test" }  
method in them, it still has this error. Its some weird classloader/ 
path problem :(

Any ideas?

~ ~ ~
Marc Palmer (marc@...)
Consultant/Analyst
AnyWare Ltd.
http://www.anyware.co.uk/

Marc Palmer | 2 Jan 2006 17:37
Picon
Gravatar

IllegalMonitorState exception with synchronized


Hi,

Am I doing something wrong? I get IllegalMonitorStateException in  
this code:

class PollSubmissionHandler extends EmailSubmissionHandler
{
     private static Map pollCache = new HashMap()

     static List getCachedPollResults( DataSource ds, String pollID)
     {
         synchronized (pollCache)
         {
             def cache = pollCache[pollID]
             if (cache == null)
             {
                 def results = Polls.getPollResults( ds, pollID)
                 if (results != null)
                 {
                     cache = results
                     pollCache[pollID] = results
                 }
             }
             return cache // Throws exception here according to trace
         }
     }
}

If I remove the synchronized block this code works fine. I'm not sure  
(Continue reading)

Alan Green | 3 Jan 2006 00:40
Picon

Hello and thanks


Hi Marc,

I'm one of the many people reading your posts on groovy-user. Just 
wanted to say thanks for reporting problems as you go and for raising 
detailed bug reports in JIRA. Groovy has a long way to go, but users 
like you are making sure it gets there faster.

Alan.

PS: wangjammer5? Ouch!

Marc Palmer | 3 Jan 2006 00:50
Picon
Gravatar

Re: Hello and thanks


On 2 Jan 2006, at 23:40, Alan Green wrote:

>
>
> Hi Marc,
>
> I'm one of the many people reading your posts on groovy-user. Just  
> wanted to say thanks for reporting problems as you go and for  
> raising detailed bug reports in JIRA. Groovy has a long way to go,  
> but users like you are making sure it gets there faster.
>

That's decent of you but really... its the developers who deserve  
thanks. Without it I would have no bugs to report, and no cool  
scripting language!

Debugging scripts is however extremely painful at the moment. I've  
just had a very tough day chasing mysterious messages.

The GREAT news is that this project is finally launching tomorrow,  
the first working day of 2006. TIP: Never let a client talk you into  
a product launch at the start of the new year, it wrecks your  
holidays :(

Once it is live I will provide the URL. It's nothing that impressive  
but it is quite a high profile UK food product's web site built with  
Groovy, so that has to be good!

> PS: wangjammer5? Ouch!
(Continue reading)

Scott Hickey | 3 Jan 2006 15:57
Picon
Favicon

switch and if/then give unexpected results with BigDecimal

  Testing for 1 == 1.0 and BigDecimal("1") == BigDecimal("1.0") produce
different results in the if statement versus the case statement. I'm not sure
what the intended behavior is. My gut reaction is that for scripting language, 1
== 1.0 and 1.0 == 1.00 should always be true.

Below is a script that illustrates the behavior. In either case, I
think most users would expect the switch and if statements to behave the same. Any
thoughts on this?

import java.math.BigDecimal

def oneBD = new BigDecimal("1") // 1 with scale zero

[1, oneBD, 1.0].each {x ->
[1,1.0].each {y ->
println "testing comparison of ${x.dump()} to ${y.dump()}"

msg = (x == y) ? "true": "false"
println "ternary operator for ${x} == ${y}: ${msg}"

if (x == y)
msg = "true"
else msg = "false"
println "if statement for ${x} == ${y}: ${msg}"

switch (x) {
case y:
msg = "true"
break
default:
msg = "false"
}
println "switch stmt for ${x} == ${y}: ${msg}\n"
}
}

Yahoo! Photos
Ring in the New Year with Photo Calendars. Add photos, events, holidays, whatever.
Jochen Theodorou | 3 Jan 2006 16:11
Picon
Gravatar

Re: switch and if/then give unexpected results with BigDecimal

Scott Hickey schrieb:

>  
> 
> Testing for 1 == 1.0 and BigDecimal("1") == BigDecimal("1.0") produce 
> different results in the if statement versus the case statement. I'm not sure 
> what the intended behavior is. My gut reaction is that for scripting language, 1 
> == 1.0 and 1.0 == 1.00 should always be true.
> 
> Below is a script that illustrates the behavior. In either case, I 
> think most users would expect the switch and if statements to behave the same. Any 
> thoughts on this?

currently only the equals method of BigDecimal is used. But in terms of 
this equals methode, 1.0 and 1.00 are not equal. This means we have to 
write our own equals-method here. Any suggestions?

bye blackdrag

John Wilson | 3 Jan 2006 16:34
Picon

Re: switch and if/then give unexpected results with BigDecimal


On 3 Jan 2006, at 14:57, Scott Hickey wrote:

> Testing for 1 == 1.0 and BigDecimal("1") == BigDecimal("1.0") produce
> different results in the if statement versus the case statement.  
> I'm not sure
> what the intended behavior is. My gut reaction is that for  
> scripting language, 1
> == 1.0 and 1.0 == 1.00 should always be true.
>
> Below is a script that illustrates the behavior. In either case, I
> think most users would expect the switch and if statements to  
> behave the same. Any
> thoughts on this?

We appear to be using compareTo in conditionals and equals in  
switches. This doesn't make any difference for most things but  
produces the behaviour you observe for BigDecimal.

import java.math.BigDecimal

def oneBD = new BigDecimal("1") // 1 with scale zero

println oneBD.equals(1)
println oneBD.equals(1.0)
println oneBD.compareTo(1)
println oneBD.compareTo(1.0)

produces

false
false
0
0

I'm not a BD expert but it looks like a bug to me.

John Wilson
The Wilson Partnership
http://www.wilson.co.uk

Scott Hickey | 3 Jan 2006 17:09
Picon
Favicon

Re: switch and if/then give unexpected results with BigDecimal

So compare must also be what's used in the following as well?

Version: 1.0-jsr-04-SNAPSHOT JVM: 1.4.2_08-b03
Type 'exit' to terminate the shell
Type 'help' for command help
Type 'go' to execute the statements

groovy> println 1.0 == 1.00
groovy> go
true


John Wilson <tug-GwqJ/HqVibzQXOPxS62xeg@public.gmane.org> wrote:

On 3 Jan 2006, at 14:57, Scott Hickey wrote:

> Testing for 1 == 1.0 and BigDecimal("1") == BigDecimal("1.0") produce
> different results in the if statement versus the case statement.
> I'm not sure
> what the intended behavior is. My gut reaction is that for
> scripting language, 1
> == 1.0 and 1.0 == 1.00 should always be true.
>> Below is a script that illustrates the behavior. In either case, I
> think most users would expect the switch and if statements to
> behave the same. Any
> thoughts on this?


We appear to be using compareTo in conditionals and equals in
switches. This doesn't make any difference for most things but
produces the behaviour you observe for BigDecimal.

import java.math.BigDecimal

def oneBD = new BigDecimal("1") // 1 with scale zero

println oneBD.equals(1)
println oneBD.equals(1.0)
println oneBD.compareTo(1)
println oneBD.compareTo(1.0)

produces

false
false
0
0

I'm not a BD expert but it looks like a bug to me.


John Wilson
The Wilson Partnership
http://www.wilson.co.uk



Yahoo! Photos
Ring in the New Year with Photo Calendars. Add photos, events, holidays, whatever.
John Wilson | 3 Jan 2006 17:31
Picon

Re: switch and if/then give unexpected results with BigDecimal


On 3 Jan 2006, at 16:09, Scott Hickey wrote:

> So compare must also be what's used in the following as well?
>
> Version: 1.0-jsr-04-SNAPSHOT JVM: 1.4.2_08-b03
> Type 'exit' to terminate the shell
> Type 'help' for command help
> Type 'go' to execute the statements
>
> groovy> println 1.0 == 1.00
> groovy> go
> true

Yes, compareTo is used fro ==. <, >, => etc

John Wilson
The Wilson Partnership
http://www.wilson.co.uk

Salvador Ledezma | 3 Jan 2006 23:05
Picon
Favicon

ResultSet from stored procedure call() method


Hello,

Using the groovy.sql API, I noticed that I can call a database stored procedure, but I don't have access to its ResultSet.

I would like to operate on the return ResultSet of a stored procedure in the same way I can operate on the ResultSet returned by the eachRow() method.

How can I do this?  If this is not supported, will it be in a future Groovy release?

Thanks,

-Salvador.


Salvador Ledezma
IBM Silicon Valley Laboratory
Phone: 408-463-4312  Tie Line: 8-543-4312
Email: ledezma-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org

Gmane