Read only archive ; use for new issues

Bug 1048

Summary: struct with a forward declaration throws CORBA.BAD_INV_ORDER in JacORB notification service
Product: JacORB Reporter: Alessandro Caproni <acaproni>
Component: Notification ServiceAssignee: Alphonse Bendt <pho.lst>
Status: NEW ---    
Severity: enhancement    
Priority: P5    
Version: 3.6.1   
Hardware: PC   
OS: Linux   
Attachments: A module to reproduce the bug

Description Alessandro Caproni 2016-09-20 08:16:17 CEST
This issue seems a different incarnation of Bug 430.

Given the following IDL:

  struct First;
  typedef sequence<First> FirstSeq;
  struct First {
	unsigned long id;
	FirstSeq firsts;
  struct Second {
	unsigned long identifier;
	FirstSeq items;

While it is possible to send objects of type Second through IDL calls between servers and clients, the publishing of a struct of type Second fails with a CORBA.BAD_INV_ORDER when published in a notification channel.
It is instead possible to published objects of type First.
ACE/TAO and omniORB successfully publishes object of type Second.

Workaround: rewrite the IDL as follows

  struct First;
  typedef sequence<First> FirstSeq;
  struct First {
	unsigned long id;
	FirstSeq firsts;

  typedef sequence<First> FirstSeq2;
  struct Second {
	unsigned long identifier;
	FirstSeq2 items;

i.e. redefine the type sequence<First> just before the definition of the type Second, avoiding the forward declaration.

The bug has been found with JacORB 3.6.1 but is still present in v3.8.
Comment 1 Alessandro Caproni 2016-09-20 08:17:54 CEST
The following snippet (hacking the code in Bug 430) trigger the error:

public class FwdDeclTester {

	public static void main(String[] args) {
		if (args.length != 1) {
			System.out.println("\nUSAGE: FwdDeclTester NotifyServiceCorbaloc\n");
		System.out.println("Initializing the ORB");
		ORB orb = ORB.init(args, null);

		try {
			// get service reference
			org.omg.CORBA.Object service = orb.string_to_object(args[0]);

			// it is actually the factory
			org.omg.CosNotifyChannelAdmin.EventChannelFactory factory = org.omg.CosNotifyChannelAdmin.EventChannelFactoryHelper

			// list all channels from the factory
			int[] ids = factory.get_all_channels();
			if (ids.length == 0) {
				// no channel exists.
				System.out.println("pls create a channel");

			// get the first channel
			org.omg.CosNotifyChannelAdmin.EventChannel channel = factory.get_event_channel(ids[0]);

			// get its default supplier admin
			org.omg.CosNotifyChannelAdmin.SupplierAdmin admin = channel.default_supplier_admin();

			// create a proxy
			org.omg.CORBA.IntHolder proxy_id = new org.omg.CORBA.IntHolder();
			org.omg.CosNotifyChannelAdmin.ProxyConsumer proxy = admin
					.obtain_notification_push_consumer(org.omg.CosNotifyChannelAdmin.ClientType.ANY_EVENT, proxy_id);

			org.omg.CosNotifyChannelAdmin.ProxyPushConsumer consumer = org.omg.CosNotifyChannelAdmin.ProxyPushConsumerHelper

			// connect to it (optional)
			// Build the struct to publish
			Second s = new Second();
			s.items = new First[0];

			// push events
			org.omg.CORBA.Any event = orb.create_any();
			SecondHelper.insert(event, s);

			System.out.println("push 1 any event: "+s);


			// disconnect from the channel
		} catch (Exception ex) {

		System.out.println("Shutting down the ORB");

Comment 2 Alessandro Caproni 2016-09-20 08:24:35 CEST
Created attachment 477 [details]
A module to reproduce the bug

A module to trigger the error

1 From the src folder, build the jars with ant build
2 run the notify service: ntfy -printCorbaloc
3 run the test: "java -cp "$JACORB_HOME/lib/*:../lib/*" -Dorg.omg.CORBA.ORBClass=org.jacorb.orb.ORB -Dorg.omg.CORBA.ORBSingletonClass=org.jacorb.orb.ORBSingleton org.eso.FwdDeclTester notifyServiceCorbaloc"