Re: If a Java function seems to never return, how do I test?

2015-11-04 Thread Colin Jones
Any chance the thing being thrown was not an Exception, but still a Throwable? 
e.g. AssertionError would behave in the way you've described here, unless I'm 
missing some detail - 
https://docs.oracle.com/javase/7/docs/api/java/lang/AssertionError.html

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: If a Java function seems to never return, how do I test?

2015-11-04 Thread Lawrence Krubner

> flush twice, oracle is far far away? 

Are you saying this is so obvious I should be able to easily look it up? It 
might be obvious to you, but it is not obvious to me. That's why I'm asking.






On Monday, November 2, 2015 at 3:25:36 PM UTC-5, raould wrote:
>
> flush twice, oracle is far far away? 
>

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: If a Java function seems to never return, how do I test?

2015-11-04 Thread Lawrence Krubner

Possible. I have not dug into the Java app, but I will look for that. 


On Monday, November 2, 2015 at 4:48:38 PM UTC-5, Rob Lally wrote:
>
> Is it possible that the exception is being thrown in a different thread? 
> If that’s the case, you can use:
>
>
> https://docs.oracle.com/javase/7/docs/api/java/lang/Thread.UncaughtExceptionHandler.html
>
> to capture it.
>
>
> Rob.
>
>
> On 2 Nov 2015, at 12:22, Lawrence Krubner  > wrote:
>
>
> Now there is a new error. 
>
> Somehow, when the exception happens in our Java library, even though we, 
> in theory, write to System.out.println(), I never see the Exception in the 
> logs. 
>
> All I can think is that somewhere in the Java library there is an 
> exception that we catch but we forget to do System.out.println(). Can 
> anyone think of another explanation? 
>
>
>
>
> On Sunday, November 1, 2015 at 5:10:19 PM UTC-5, Lawrence Krubner wrote:
>>
>> So, we eventually fixed this. There were 2 bugs that worked together to 
>> make this a mystery. I had to guess at what the problems were, and fix them 
>> blind, since I could not see the Exceptions. I am curious about why I was 
>> not able to see the Exceptions. 
>>
>> About this:
>>
>> > Exceptions are ALWAYS visible, the only way they get lost is 
>> > the try/catch blocks you added in your code which effectively 
>> > swallow and ignore them.
>>
>> But the Exceptions I dealt with were invisible. We have the Clojure app 
>> set up to run via Supervisord and the conf has these lines:
>>
>> stderr_logfile=/var/log/nlph_stderr.log
>> stdout_logfile=/var/log/nlph_stdout.log
>>
>> So in 2 terminal windows I would:
>>
>> cd /var/log
>>
>> tail -f nlph_stdout.log
>>
>> And the same for nlph_stderr.log.
>>
>> So I was looking at the output in my terminal window. And I could see all 
>> of our logging statements appear. And the code clearly got to the line 
>> where the exception happens, but then the Exception never appeared in the 
>> terminal. It was invisible. I assume the output of this: 
>>
>> System.out.println(e.getMessage());
>>
>> would appear in one of the files that I was tailing. But it never did. 
>>
>> So I am wondering why the Exceptions were invisible? Why didn't the print 
>> statements make it to the terminal? 
>>
>>
>>
>>
>> On Saturday, October 31, 2015 at 6:56:23 AM UTC-4, Thomas Heller wrote:
>>>
>>>
 What could we do to make the Exception visible, assuming there is one? 


>>> Exceptions are ALWAYS visible, the only way they get lost is the 
>>> try/catch blocks you added in your code which effectively swallow and 
>>> ignore them. The JVM will not randomly lose an Exception, it is always code 
>>> you write that decided to handle them in some way. If you do not know how 
>>> to handle an exception do not catch it, printing its stacktrace and 
>>> ignoring it is never a good idea.
>>>
>>> In your case since you say that the function never returns I'd put my 
>>> guess on an infinite loop. There is no exception that gets lost, your code 
>>> is just still running. If your JVM is running locally you can attach to it 
>>> via jvisualvm [1] and get a quick overview of what the JVM is doing. If you 
>>> look at the thread information you'll see if something is still running or 
>>> dead-locked somehow.
>>>
>>> You can also use a debugger and step through the java code step by step.
>>>
>>> Also, consider coding against interfaces in java (eg. java.util.List and 
>>> java.util.Map instead of java.util.Collection), it will save you tons of 
>>> conversion calls.
>>>
>>> HTH
>>> /thomas
>>>
>>> [1] https://visualvm.java.net/
>>>
>>
> -- 
> You received this message because you are subscribed to the Google
> Groups "Clojure" group.
> To post to this group, send email to clo...@googlegroups.com 
> Note that posts from new members are moderated - please be patient with 
> your first post.
> To unsubscribe from this group, send email to
> clojure+u...@googlegroups.com 
> For more options, visit this group at
> http://groups.google.com/group/clojure?hl=en
> --- 
> You received this message because you are subscribed to the Google Groups 
> "Clojure" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to clojure+u...@googlegroups.com .
> For more options, visit https://groups.google.com/d/optout.
>
>
>

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to 

Re: If a Java function seems to never return, how do I test?

2015-11-04 Thread Lawrence Krubner

> It is possible to rebind System.out to something else inside Java, so the 
> library could be redirecting it from your view. Not saying that's 
> happening, but it's possible. 

Thanks for this. Now that you mention it, I recall some conversation about 
this over the summer. I will investigate this. 






On Monday, November 2, 2015 at 3:26:15 PM UTC-5, Alex Miller wrote:
>
> It is possible to rebind System.out to something else inside Java, so the 
> library could be redirecting it from your view. Not saying that's 
> happening, but it's possible. 
>
> If you you can connect with a debugger, you can set breakpoints based on 
> any thrown exception.
>
> On Monday, November 2, 2015 at 2:22:30 PM UTC-6, Lawrence Krubner wrote:
>>
>>
>> Now there is a new error. 
>>
>> Somehow, when the exception happens in our Java library, even though we, 
>> in theory, write to System.out.println(), I never see the Exception in the 
>> logs. 
>>
>> All I can think is that somewhere in the Java library there is an 
>> exception that we catch but we forget to do System.out.println(). Can 
>> anyone think of another explanation? 
>>
>>
>>
>>
>> On Sunday, November 1, 2015 at 5:10:19 PM UTC-5, Lawrence Krubner wrote:
>>>
>>> So, we eventually fixed this. There were 2 bugs that worked together to 
>>> make this a mystery. I had to guess at what the problems were, and fix them 
>>> blind, since I could not see the Exceptions. I am curious about why I was 
>>> not able to see the Exceptions. 
>>>
>>> About this:
>>>
>>> > Exceptions are ALWAYS visible, the only way they get lost is 
>>> > the try/catch blocks you added in your code which effectively 
>>> > swallow and ignore them.
>>>
>>> But the Exceptions I dealt with were invisible. We have the Clojure app 
>>> set up to run via Supervisord and the conf has these lines:
>>>
>>> stderr_logfile=/var/log/nlph_stderr.log
>>> stdout_logfile=/var/log/nlph_stdout.log
>>>
>>> So in 2 terminal windows I would:
>>>
>>> cd /var/log
>>>
>>> tail -f nlph_stdout.log
>>>
>>> And the same for nlph_stderr.log.
>>>
>>> So I was looking at the output in my terminal window. And I could see 
>>> all of our logging statements appear. And the code clearly got to the line 
>>> where the exception happens, but then the Exception never appeared in the 
>>> terminal. It was invisible. I assume the output of this: 
>>>
>>> System.out.println(e.getMessage());
>>>
>>> would appear in one of the files that I was tailing. But it never did. 
>>>
>>> So I am wondering why the Exceptions were invisible? Why didn't the 
>>> print statements make it to the terminal? 
>>>
>>>
>>>
>>>
>>> On Saturday, October 31, 2015 at 6:56:23 AM UTC-4, Thomas Heller wrote:


> What could we do to make the Exception visible, assuming there is one? 
>
>
 Exceptions are ALWAYS visible, the only way they get lost is the 
 try/catch blocks you added in your code which effectively swallow and 
 ignore them. The JVM will not randomly lose an Exception, it is always 
 code 
 you write that decided to handle them in some way. If you do not know how 
 to handle an exception do not catch it, printing its stacktrace and 
 ignoring it is never a good idea.

 In your case since you say that the function never returns I'd put my 
 guess on an infinite loop. There is no exception that gets lost, your code 
 is just still running. If your JVM is running locally you can attach to it 
 via jvisualvm [1] and get a quick overview of what the JVM is doing. If 
 you 
 look at the thread information you'll see if something is still running or 
 dead-locked somehow.

 You can also use a debugger and step through the java code step by step.

 Also, consider coding against interfaces in java (eg. java.util.List 
 and java.util.Map instead of java.util.Collection), it will save you tons 
 of conversion calls.

 HTH
 /thomas

 [1] https://visualvm.java.net/

>>>

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: If a Java function seems to never return, how do I test?

2015-11-02 Thread Alex Miller
It is possible to rebind System.out to something else inside Java, so the 
library could be redirecting it from your view. Not saying that's 
happening, but it's possible. 

If you you can connect with a debugger, you can set breakpoints based on 
any thrown exception.

On Monday, November 2, 2015 at 2:22:30 PM UTC-6, Lawrence Krubner wrote:
>
>
> Now there is a new error. 
>
> Somehow, when the exception happens in our Java library, even though we, 
> in theory, write to System.out.println(), I never see the Exception in the 
> logs. 
>
> All I can think is that somewhere in the Java library there is an 
> exception that we catch but we forget to do System.out.println(). Can 
> anyone think of another explanation? 
>
>
>
>
> On Sunday, November 1, 2015 at 5:10:19 PM UTC-5, Lawrence Krubner wrote:
>>
>> So, we eventually fixed this. There were 2 bugs that worked together to 
>> make this a mystery. I had to guess at what the problems were, and fix them 
>> blind, since I could not see the Exceptions. I am curious about why I was 
>> not able to see the Exceptions. 
>>
>> About this:
>>
>> > Exceptions are ALWAYS visible, the only way they get lost is 
>> > the try/catch blocks you added in your code which effectively 
>> > swallow and ignore them.
>>
>> But the Exceptions I dealt with were invisible. We have the Clojure app 
>> set up to run via Supervisord and the conf has these lines:
>>
>> stderr_logfile=/var/log/nlph_stderr.log
>> stdout_logfile=/var/log/nlph_stdout.log
>>
>> So in 2 terminal windows I would:
>>
>> cd /var/log
>>
>> tail -f nlph_stdout.log
>>
>> And the same for nlph_stderr.log.
>>
>> So I was looking at the output in my terminal window. And I could see all 
>> of our logging statements appear. And the code clearly got to the line 
>> where the exception happens, but then the Exception never appeared in the 
>> terminal. It was invisible. I assume the output of this: 
>>
>> System.out.println(e.getMessage());
>>
>> would appear in one of the files that I was tailing. But it never did. 
>>
>> So I am wondering why the Exceptions were invisible? Why didn't the print 
>> statements make it to the terminal? 
>>
>>
>>
>>
>> On Saturday, October 31, 2015 at 6:56:23 AM UTC-4, Thomas Heller wrote:
>>>
>>>
 What could we do to make the Exception visible, assuming there is one? 


>>> Exceptions are ALWAYS visible, the only way they get lost is the 
>>> try/catch blocks you added in your code which effectively swallow and 
>>> ignore them. The JVM will not randomly lose an Exception, it is always code 
>>> you write that decided to handle them in some way. If you do not know how 
>>> to handle an exception do not catch it, printing its stacktrace and 
>>> ignoring it is never a good idea.
>>>
>>> In your case since you say that the function never returns I'd put my 
>>> guess on an infinite loop. There is no exception that gets lost, your code 
>>> is just still running. If your JVM is running locally you can attach to it 
>>> via jvisualvm [1] and get a quick overview of what the JVM is doing. If you 
>>> look at the thread information you'll see if something is still running or 
>>> dead-locked somehow.
>>>
>>> You can also use a debugger and step through the java code step by step.
>>>
>>> Also, consider coding against interfaces in java (eg. java.util.List and 
>>> java.util.Map instead of java.util.Collection), it will save you tons of 
>>> conversion calls.
>>>
>>> HTH
>>> /thomas
>>>
>>> [1] https://visualvm.java.net/
>>>
>>

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: If a Java function seems to never return, how do I test?

2015-11-02 Thread Raoul Duke
flush twice, oracle is far far away?

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: If a Java function seems to never return, how do I test?

2015-11-02 Thread Lawrence Krubner

Now there is a new error. 

Somehow, when the exception happens in our Java library, even though we, in 
theory, write to System.out.println(), I never see the Exception in the 
logs. 

All I can think is that somewhere in the Java library there is an exception 
that we catch but we forget to do System.out.println(). Can anyone think of 
another explanation? 




On Sunday, November 1, 2015 at 5:10:19 PM UTC-5, Lawrence Krubner wrote:
>
> So, we eventually fixed this. There were 2 bugs that worked together to 
> make this a mystery. I had to guess at what the problems were, and fix them 
> blind, since I could not see the Exceptions. I am curious about why I was 
> not able to see the Exceptions. 
>
> About this:
>
> > Exceptions are ALWAYS visible, the only way they get lost is 
> > the try/catch blocks you added in your code which effectively 
> > swallow and ignore them.
>
> But the Exceptions I dealt with were invisible. We have the Clojure app 
> set up to run via Supervisord and the conf has these lines:
>
> stderr_logfile=/var/log/nlph_stderr.log
> stdout_logfile=/var/log/nlph_stdout.log
>
> So in 2 terminal windows I would:
>
> cd /var/log
>
> tail -f nlph_stdout.log
>
> And the same for nlph_stderr.log.
>
> So I was looking at the output in my terminal window. And I could see all 
> of our logging statements appear. And the code clearly got to the line 
> where the exception happens, but then the Exception never appeared in the 
> terminal. It was invisible. I assume the output of this: 
>
> System.out.println(e.getMessage());
>
> would appear in one of the files that I was tailing. But it never did. 
>
> So I am wondering why the Exceptions were invisible? Why didn't the print 
> statements make it to the terminal? 
>
>
>
>
> On Saturday, October 31, 2015 at 6:56:23 AM UTC-4, Thomas Heller wrote:
>>
>>
>>> What could we do to make the Exception visible, assuming there is one? 
>>>
>>>
>> Exceptions are ALWAYS visible, the only way they get lost is the 
>> try/catch blocks you added in your code which effectively swallow and 
>> ignore them. The JVM will not randomly lose an Exception, it is always code 
>> you write that decided to handle them in some way. If you do not know how 
>> to handle an exception do not catch it, printing its stacktrace and 
>> ignoring it is never a good idea.
>>
>> In your case since you say that the function never returns I'd put my 
>> guess on an infinite loop. There is no exception that gets lost, your code 
>> is just still running. If your JVM is running locally you can attach to it 
>> via jvisualvm [1] and get a quick overview of what the JVM is doing. If you 
>> look at the thread information you'll see if something is still running or 
>> dead-locked somehow.
>>
>> You can also use a debugger and step through the java code step by step.
>>
>> Also, consider coding against interfaces in java (eg. java.util.List and 
>> java.util.Map instead of java.util.Collection), it will save you tons of 
>> conversion calls.
>>
>> HTH
>> /thomas
>>
>> [1] https://visualvm.java.net/
>>
>

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: If a Java function seems to never return, how do I test?

2015-11-02 Thread Rob Lally
Is it possible that the exception is being thrown in a different thread? If 
that’s the case, you can use:

https://docs.oracle.com/javase/7/docs/api/java/lang/Thread.UncaughtExceptionHandler.html
 


to capture it.


Rob.


> On 2 Nov 2015, at 12:22, Lawrence Krubner  wrote:
> 
> 
> Now there is a new error. 
> 
> Somehow, when the exception happens in our Java library, even though we, in 
> theory, write to System.out.println(), I never see the Exception in the logs. 
> 
> All I can think is that somewhere in the Java library there is an exception 
> that we catch but we forget to do System.out.println(). Can anyone think of 
> another explanation? 
> 
> 
> 
> 
> On Sunday, November 1, 2015 at 5:10:19 PM UTC-5, Lawrence Krubner wrote:
> So, we eventually fixed this. There were 2 bugs that worked together to make 
> this a mystery. I had to guess at what the problems were, and fix them blind, 
> since I could not see the Exceptions. I am curious about why I was not able 
> to see the Exceptions. 
> 
> About this:
> 
> > Exceptions are ALWAYS visible, the only way they get lost is 
> > the try/catch blocks you added in your code which effectively 
> > swallow and ignore them.
> 
> But the Exceptions I dealt with were invisible. We have the Clojure app set 
> up to run via Supervisord and the conf has these lines:
> 
> stderr_logfile=/var/log/nlph_stderr.log
> stdout_logfile=/var/log/nlph_stdout.log
> 
> So in 2 terminal windows I would:
> 
> cd /var/log
> 
> tail -f nlph_stdout.log
> 
> And the same for nlph_stderr.log.
> 
> So I was looking at the output in my terminal window. And I could see all of 
> our logging statements appear. And the code clearly got to the line where the 
> exception happens, but then the Exception never appeared in the terminal. It 
> was invisible. I assume the output of this: 
> 
> System.out.println(e.getMessage());
> 
> would appear in one of the files that I was tailing. But it never did. 
> 
> So I am wondering why the Exceptions were invisible? Why didn't the print 
> statements make it to the terminal? 
> 
> 
> 
> 
> On Saturday, October 31, 2015 at 6:56:23 AM UTC-4, Thomas Heller wrote:
> 
> What could we do to make the Exception visible, assuming there is one? 
> 
> 
> Exceptions are ALWAYS visible, the only way they get lost is the try/catch 
> blocks you added in your code which effectively swallow and ignore them. The 
> JVM will not randomly lose an Exception, it is always code you write that 
> decided to handle them in some way. If you do not know how to handle an 
> exception do not catch it, printing its stacktrace and ignoring it is never a 
> good idea.
> 
> In your case since you say that the function never returns I'd put my guess 
> on an infinite loop. There is no exception that gets lost, your code is just 
> still running. If your JVM is running locally you can attach to it via 
> jvisualvm [1] and get a quick overview of what the JVM is doing. If you look 
> at the thread information you'll see if something is still running or 
> dead-locked somehow.
> 
> You can also use a debugger and step through the java code step by step.
> 
> Also, consider coding against interfaces in java (eg. java.util.List and 
> java.util.Map instead of java.util.Collection), it will save you tons of 
> conversion calls.
> 
> HTH
> /thomas
> 
> [1] https://visualvm.java.net/ 
> 
> -- 
> You received this message because you are subscribed to the Google
> Groups "Clojure" group.
> To post to this group, send email to clojure@googlegroups.com
> Note that posts from new members are moderated - please be patient with your 
> first post.
> To unsubscribe from this group, send email to
> clojure+unsubscr...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/clojure?hl=en 
> 
> --- 
> You received this message because you are subscribed to the Google Groups 
> "Clojure" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to clojure+unsubscr...@googlegroups.com 
> .
> For more options, visit https://groups.google.com/d/optout 
> .

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to 

Re: If a Java function seems to never return, how do I test?

2015-11-01 Thread Lawrence Krubner
So, we eventually fixed this. There were 2 bugs that worked together to 
make this a mystery. I had to guess at what the problems were, and fix them 
blind, since I could not see the Exceptions. I am curious about why I was 
not able to see the Exceptions. 

About this:

> Exceptions are ALWAYS visible, the only way they get lost is 
> the try/catch blocks you added in your code which effectively 
> swallow and ignore them.

But the Exceptions I dealt with were invisible. We have the Clojure app set 
up to run via Supervisord and the conf has these lines:

stderr_logfile=/var/log/nlph_stderr.log
stdout_logfile=/var/log/nlph_stdout.log

So in 2 terminal windows I would:

cd /var/log

tail -f nlph_stdout.log

And the same for nlph_stderr.log.

So I was looking at the output in my terminal window. And I could see all 
of our logging statements appear. And the code clearly got to the line 
where the exception happens, but then the Exception never appeared in the 
terminal. It was invisible. I assume the output of this: 

System.out.println(e.getMessage());

would appear in one of the files that I was tailing. But it never did. 

So I am wondering why the Exceptions were invisible? Why didn't the print 
statements make it to the terminal? 




On Saturday, October 31, 2015 at 6:56:23 AM UTC-4, Thomas Heller wrote:
>
>
>> What could we do to make the Exception visible, assuming there is one? 
>>
>>
> Exceptions are ALWAYS visible, the only way they get lost is the try/catch 
> blocks you added in your code which effectively swallow and ignore them. 
> The JVM will not randomly lose an Exception, it is always code you write 
> that decided to handle them in some way. If you do not know how to handle 
> an exception do not catch it, printing its stacktrace and ignoring it is 
> never a good idea.
>
> In your case since you say that the function never returns I'd put my 
> guess on an infinite loop. There is no exception that gets lost, your code 
> is just still running. If your JVM is running locally you can attach to it 
> via jvisualvm [1] and get a quick overview of what the JVM is doing. If you 
> look at the thread information you'll see if something is still running or 
> dead-locked somehow.
>
> You can also use a debugger and step through the java code step by step.
>
> Also, consider coding against interfaces in java (eg. java.util.List and 
> java.util.Map instead of java.util.Collection), it will save you tons of 
> conversion calls.
>
> HTH
> /thomas
>
> [1] https://visualvm.java.net/
>

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: If a Java function seems to never return, how do I test?

2015-10-31 Thread Thomas Heller

>
>
> What could we do to make the Exception visible, assuming there is one? 
>
>
Exceptions are ALWAYS visible, the only way they get lost is the try/catch 
blocks you added in your code which effectively swallow and ignore them. 
The JVM will not randomly lose an Exception, it is always code you write 
that decided to handle them in some way. If you do not know how to handle 
an exception do not catch it, printing its stacktrace and ignoring it is 
never a good idea.

In your case since you say that the function never returns I'd put my guess 
on an infinite loop. There is no exception that gets lost, your code is 
just still running. If your JVM is running locally you can attach to it via 
jvisualvm [1] and get a quick overview of what the JVM is doing. If you 
look at the thread information you'll see if something is still running or 
dead-locked somehow.

You can also use a debugger and step through the java code step by step.

Also, consider coding against interfaces in java (eg. java.util.List and 
java.util.Map instead of java.util.Collection), it will save you tons of 
conversion calls.

HTH
/thomas

[1] https://visualvm.java.net/

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


If a Java function seems to never return, how do I test?

2015-10-30 Thread Lawrence Krubner

I am trying to figure out where this code might die, and why we don't se 
the Exception, if there is an Exception. 

Inside of a try/catch block, we have this, when calls a library written in 
Java: 


(timbre/log :trace " in parse-sentence fields-and-labels is: " 
fields-and-labels)

(let [
  instance-of-sentence-parser @nlp-engine
  sentence-parse-response-map (.init instance-of-sentence-parser
 (:incoming-message 
this-users-conversation)
 organization
 accounts
 contacts
 required-fields
 fields-and-labels)
  ]

(timbre/log :trace " in parse-sentence sentence-parse-response-map is: " 
sentence-parse-response-map)


We get to the first of these log statements, but not the second. The Java 
function we call looks like this: 


public HashMap init(String debrief,String companyName, 
Collection contacts, Collection accounts, Collection requiredFields, Map 
fieldLabelMap) {
try {
System.out.println("The house is inside the nlp init.");
ArrayList ct = new 
ArrayList(Arrays.asList(contacts.toArray(new String[0])));
ArrayList ac = new 
ArrayList(Arrays.asList(accounts.toArray(new String[0])));
ArrayList rq = new 
ArrayList(Arrays.asList(requiredFields.toArray(new String[0])));
HashMap flMap = new HashMap<>(fieldLabelMap);
System.out.println("init method has ended.");
return transformer.transform(debrief, companyName, 
tecClassifier, rollioClassifier, caseClassifier, caselessClassifier, 
customClassifier, pipeline, parser, props, firstNames, lastNames, ac, ct, 
rq, flMap);
} catch (Exception e) {
System.out.println("Top level Exception in Main::main" + 
e.getMessage());
e.printStackTrace();
}
return null;
}


And it gets as far as :

System.out.println("init method has ended.");

The transform function looks like: 

public HashMap transform(String debrief, String 
companyName, AbstractSequenceClassifier tecClassifier, 
AbstractSequenceClassifier 
amaranClassifier,AbstractSequenceClassifier 
caseClassifier,AbstractSequenceClassifier caselessClassifier, 
AbstractSequenceClassifier customClassifier,StanfordCoreNLP 
pipeline, Parser parser, Properties props,String[] firstNames, String[] 
lastNames, ArrayList acctMp, ArrayList contactMap, 
ArrayList requiredFields, HashMap fieldLabelMap) {
try {
if (companyName.equals("Amaran")) {
AmaranSFInfoExtractor sfInfoExtractor = new 
AmaranSFInfoExtractor(debrief, pipeline, parser, amaranClassifier, 
caseClassifier, caselessClassifier, customClassifier, props, firstNames, 
lastNames, acctMp, contactMap, requiredFields, fieldLabelMap);
sfInfoExtractor.extract();
return deNestMap(sfInfoExtractor.tagMap);
} if (companyName.equals("TEC")) {
TECSFInfoExtractor sfInfoExtractor = new 
TECSFInfoExtractor(debrief, pipeline, parser, tecClassifier, 
caseClassifier, caselessClassifier, customClassifier, props, firstNames, 
lastNames, acctMp, contactMap, requiredFields, fieldLabelMap);
sfInfoExtractor.extract();
return deNestMap(sfInfoExtractor.tecTagMap);
}
} catch (Exception e) {
System.out.println(e.getMessage());
e.printStackTrace();
}
return new HashMap<>();
}


Where does this die? And why don't we see the Exception? 

What could we do to make the Exception visible, assuming there is one? 





-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.