Archived

This forum has been archived. Please start a new discussion on GitHub.

Problem with ice_invoke_async on java

Hi All,

Am having trouble getting the ice_invoke_async function to work in java.

I don't seem to see any existing example for this function, so I've modified the Client.java file in the examples to perform what ( to my mind) should be an asyncronous equivalent of the synchronous printString example. ( Option '0' has been added').

I've verified the synchronous version works. But when I try to call the asynchronous version an assertion is thrown.

Am I calling the function in the right way? Also just to understand how assertions are used in the code, to my mind an assertion should never be called in working library code and if they're called it always signifies a bug, is this the right way of thinking about them, or are there occasions when a user can cause an assertion to be raised? I'd normally expect all user mistakes to raise exceptions instead.

Any help appreciated!

A.


Using Ice-3.3.1....

Output
=========================
(Assertions enabled)

usage:
0: async pring string
1: print string
2: print string sequence
3: print dictionary
4: print enum
5: print struct
6: print struct sequence
7: print class
8: get values
9: throw exception
s: shutdown server
x: exit
?: help

==> 1 ( Here server outputs "Printing string `The streaming API works!'" as expected).
==> 0
==> Exception in thread "Ice.ThreadPool.Client-0" java.lang.AssertionError
at IceInternal.BasicStream.getReadEncapsSize(BasicStream.java:506)
at Ice.AMI_Object_ice_invoke.__response(AMI_Object_ice_invoke.java:40)
at IceInternal.OutgoingAsync.__finished(OutgoingAsync.java:201)
at Ice.ConnectionI.message(ConnectionI.java:964)
at IceInternal.ThreadPool.run(ThreadPool.java:577)
at IceInternal.ThreadPool.access$100(ThreadPool.java:12)
at IceInternal.ThreadPool$EventHandlerThread.run(ThreadPool.java:971)


( Without Assertions enabled)
==> 0
==> 14/08/09 09:34:08:569 warning: Ice.ThreadPool.Client-0: exception raised by AMI callback:
java.lang.NullPointerException
at IceInternal.BasicStream.getReadEncapsSize(BasicStream.java:507)
at Ice.AMI_Object_ice_invoke.__response(AMI_Object_ice_invoke.java:40)
at IceInternal.OutgoingAsync.__finished(OutgoingAsync.java:201)
at Ice.ConnectionI.message(ConnectionI.java:964)
at IceInternal.ThreadPool.run(ThreadPool.java:577)
at IceInternal.ThreadPool.access$100(ThreadPool.java:12)
at IceInternal.ThreadPool$EventHandlerThread.run(ThreadPool.java:971)



$ java -version
java version "1.6.0_13"
Java(TM) SE Runtime Environment (build 1.6.0_13-b03)
Java HotSpot(TM) Client VM (build 11.3-b02, mixed mode, sharing)

Comments

  • dwayne
    dwayne St. John's, Newfoundland
    Thanks for the report, this is a bug in Ice and not an issue with your code. I have uploaded a source distribution patch here that fixes the problem.

    One other note. In your sample code you check the return code of ice_invoke_async and print "Unknown user execption" if it returns false. For ice_invoke_async the return code does not indicate whether a exception occurred, but instead whether or not the operation was invoked synchronously.
  • Hi,

    Thanks a lot for fixing so quickly!

    I think my return value checking is a copy/paste error from the synchronous example :-( . (Thanks for pointing that out as well!)

    A.
  • Hi Again,

    Just to confirm I've rebuild ice with the patch and the bug is gone. Thanks again!
    A.