<?xml version="1.0" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "https://www.jacorb.org/bugzilla/page.cgi?id=bugzilla.dtd">

<bugzilla version="5.2"
          urlbase="https://www.jacorb.org/bugzilla/"
          
          maintainer="jacorb@goots.org"
>

    <bug>
          <bug_id>943</bug_id>
          
          <creation_ts>2013-02-15 14:52:02 +0000</creation_ts>
          <short_desc>Misbehaviour in ORB.getRootPOA() when socket could not be created</short_desc>
          <delta_ts>2013-06-17 06:28:41 +0000</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>JacORB</product>
          <component>ORB</component>
          <version>3.1</version>
          <rep_platform>PC</rep_platform>
          <op_sys>Windows NT</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>FIXED</resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords></keywords>
          <priority>P2</priority>
          <bug_severity>normal</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Christian Bindseil">christian.bindseil</reporter>
          <assigned_to name="Mailinglist to track bugs">jacorb-bugs</assigned_to>
          <cc>jacorb</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>2978</commentid>
    <comment_count>0</comment_count>
    <who name="Christian Bindseil">christian.bindseil</who>
    <bug_when>2013-02-15 14:52:02 +0000</bug_when>
    <thetext>We have to work with fixed TCP-ports, configured with the OASSLPort property. The start of the first instance of our software works correctly. If you try to start another instance on the same machine, the socket can&apos;t be created - that&apos;s ok because the first instance already owns this port. You get an exception. But if you try again to get the RootPOA, then you get a RootPOA (which isn&apos;t working) instead of an exception as with the first attempt. Afterwards the System does not see the difference between a working POA and a POA without proper Socket, so every request on the specified port reaches the first instance of our software, while the second instance doesn&apos;t know that it can&apos;t be called. 

The reason can be found in ORB.getRootPOA(). The whole content of the method will be executed only when rootpoa-classmember is null. Then the member is assigned and in a try-catch-block the creation of the socket is tried. If it fails, the exception is catched and another exception is thrown - but the member contains already the POA which isn&apos;t configured yet. 
If you catch the thrown exception and call the method getRootPOA() again, then the if-statement evaluates to false and the unconfigured POA is returned. The calling code works with it assuming it is reachable on the socket, but it isn&apos;t.

In my opinion the method shouldn&apos;t deliver non-working POAs. It should throw an exception every time I try to get an POA on an port, which isn&apos;t free. Every time, not only the first time.

Perhaps there is a correllation to bug 886 which is about a problem reaching the second client on the same machine.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2979</commentid>
    <comment_count>1</comment_count>
    <who name="Nick Cross">jacorb</who>
    <bug_when>2013-02-15 15:59:54 +0000</bug_when>
    <thetext>Can you provide a test case please?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2980</commentid>
    <comment_count>2</comment_count>
    <who name="Christian Bindseil">christian.bindseil</who>
    <bug_when>2013-02-15 16:23:03 +0000</bug_when>
    <thetext>I don&apos;t have an explicit testcase, because I debugged our application. But what we do is the following:

1) When our client starts, it has to provide a SSL-socket for the appserver to allow it to call the client actively, so the client does:

2) Calling ORB.init(...) to obtain an ORB-instance

3) Calling resolve_initial_references(&quot;root.poa&quot;) on that ORB

4) If we get an exception from that method, we display an error-popup to the user

5) The user can click ok and try again to log in 

=&gt; step 3 is performed again on the same ORB-instance from first attempt
=&gt; now the exception isn&apos;t thrown and we get a POA on which we work
=&gt; The user gets logged in, but the client has an uninitialized POA without socket. The client isn&apos;t reachable, the application doesn&apos;t work correctly.
</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2981</commentid>
    <comment_count>3</comment_count>
    <who name="Nick Cross">jacorb</who>
    <bug_when>2013-02-15 16:45:44 +0000</bug_when>
    <thetext>If you could provide a test case by adapting one of the existing test cases or by adapting the JacORB demo code that would be really helpful :-)</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2982</commentid>
    <comment_count>4</comment_count>
    <who name="Christian Bindseil">christian.bindseil</who>
    <bug_when>2013-02-18 10:02:37 +0000</bug_when>
    <thetext>Ok, I modified the SSL-Demo-Code. I will attach the new Server.java here. But some instructions first:

1) Replace the Server.java with my version.
2) We do not need a client, deactivate it bei adding System.exit(0) as first line of the Main-method in Client.java
3) Make a copy of the whole SSL-demo directory, because we need two servers
4) open a console in each of the directories
5) run the demo in the first console
6) if &quot;now waiting&quot; appears, start the demo from second console

The first instance is not interesting for us, it does what it has to do. The second instance will struggle in its first attempt to get the socket, because I configured both instances to use the same port (7777). Thats right. But then it tries again on the same ORB-object to get the rootPOA - but now we don&apos;t get an exception, but a poa which has not socket. The rest of the program works on it without realizing, the poa is dead.

Hint: the logged Stacktrace is sometimes printed out at the wrong place. Simply look at the line numbers. The exception corresponds to the first attempt.

</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2983</commentid>
    <comment_count>5</comment_count>
      <attachid>408</attachid>
    <who name="Christian Bindseil">christian.bindseil</who>
    <bug_when>2013-02-18 10:03:51 +0000</bug_when>
    <thetext>Created attachment 408
Modified Server.java to demonstrate the problem</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2984</commentid>
    <comment_count>6</comment_count>
    <who name="Nick Cross">jacorb</who>
    <bug_when>2013-02-18 11:16:00 +0000</bug_when>
    <thetext>Thank you for the test case. Reproduced ; I&apos;ll get the fix in for the next release.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>3021</commentid>
    <comment_count>7</comment_count>
    <who name="Nick Cross">jacorb</who>
    <bug_when>2013-06-17 06:28:41 +0000</bug_when>
    <thetext>Fixed with https://github.com/JacORB/JacORB/pull/54</thetext>
  </long_desc>
      
          <attachment
              isobsolete="0"
              ispatch="0"
              isprivate="0"
          >
            <attachid>408</attachid>
            <date>2013-02-18 10:03:51 +0000</date>
            <delta_ts>2013-02-18 10:03:51 +0000</delta_ts>
            <desc>Modified Server.java to demonstrate the problem</desc>
            <filename>Server.java</filename>
            <type>application/octet-stream</type>
            <size>2184</size>
            <attacher name="Christian Bindseil">christian.bindseil</attacher>
            
              <data encoding="base64">cGFja2FnZSBkZW1vLnNzbDsKCmltcG9ydCBqYXZhLmlvLkZpbGU7CmltcG9ydCBqYXZhLmlvLkZp
bGVXcml0ZXI7CmltcG9ydCBqYXZhLmlvLlByaW50V3JpdGVyOwoKaW1wb3J0IG9yZy5vbWcuQ09S
QkEuT1JCOwppbXBvcnQgb3JnLm9tZy5Qb3J0YWJsZVNlcnZlci5QT0E7CgovKioKICogVGhpcyBp
cyB0aGUgc2VydmVyIHBhcnQgb2YgdGhlIHNzbCBkZW1vLgogKgogKiBAYXV0aG9yIE5pY29sYXMg
Tm9mZmtlCiAqLwoKcHVibGljIGNsYXNzIFNlcnZlcgogICAgZXh0ZW5kcyBTU0xEZW1vUE9BCnsK
ICAgIC8qKgogICAgICogVGhpcyBtZXRob2QgaXMgZnJvbSB0aGUgSURMLS1pbnRlcmZhY2UuIEl0
IHByaW50cyBvdXQgdGhlCiAgICAgKiByZWNlaXZlZCBjbGllbnQgY2VydCAoaWYgYXZhaWxhYmxl
KS4KICAgICAqLwogICAgcHVibGljIHZvaWQgcHJpbnRDZXJ0KCkKICAgIHsKICAgICAgICBTeXN0
ZW0ub3V0LnByaW50bG4oIltTZXJ2ZXJdIGludm9rZWQgcHJpbnRDZXJ0KCkiKTsKICAgIH0KCgog
ICAgcHVibGljIHN0YXRpYyB2b2lkIG1haW4oIFN0cmluZ1tdIGFyZ3MgKSB0aHJvd3MgRXhjZXB0
aW9uCiAgICB7CiAgICAgICAgaWYoIGFyZ3MubGVuZ3RoICE9IDEgJiYgYXJncy5sZW5ndGggIT0g
MikKICAgICAgICB7CiAgICAgICAgICAgIFN5c3RlbS5vdXQucHJpbnRsbiggIlVzYWdlOiBqYXZh
IGRlbW8uc3NsLlNlcnZlciA8aW9yX2ZpbGU+IDxraWxsZmlsZT4iICk7CiAgICAgICAgICAgIFN5
c3RlbS5leGl0KCAtMSApOwogICAgICAgIH0KCQkKCQlTeXN0ZW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CVRocmVhZC5zbGVlcCgxMDAwMCk7IC8vIEpV
U1QgVE8gTEVUIFRIRSBTWVNURU0gV0FJVCBGT1IgVVMgVE8gU1RBUlQgVEhFIFNFQ09ORCBTRVJW
RVIKCQkKICAgICAgICBQcmludFdyaXRlciBwdyA9IG5ldyBQcmludFdyaXRlciggbmV3IEZpbGVX
cml0ZXIoIGFyZ3NbIDAgXSApKTsKCiAgICAgICAgLy8gcHJpbnQgc3RyaW5naWZpZWQgb2JqZWN0
IHJlZmVyZW5jZSB0byBmaWxlCiAgICAgICAgcHcucHJpbnRsbiggb3JiLm9iamVjdF90b19zdHJp
bmcoIGRlbW8gKSk7CgogICAgICAgIHB3LmZsdXNoKCk7CiAgICAgICAgcHcuY2xvc2UoKTsKCiAg
ICAgICAgaWYgKGFyZ3MubGVuZ3RoID09IDIpCiAgICAgICAgewogICAgICAgICAgICBGaWxlIGtp
bGxGaWxlID0gbmV3IEZpbGUoYXJnc1sxXSk7CiAgICAgICAgICAgIHdoaWxlKCFraWxsRmlsZS5l
eGlzdHMoKSkKICAgICAgICAgICAgewogICAgICAgICAgICAgICAgVGhyZWFkLnNsZWVwKDEwMDAp
OwogICAgICAgICAgICB9CiAgICAgICAgICAgIG9yYi5zaHV0ZG93bih0cnVlKTsKICAgICAgICB9
CiAgICAgICAgZWxzZQogICAgICAgIHsKICAgICAgICAgICAgb3JiLnJ1bigpOwogICAgICAgIH0K
ICAgIH0KfSAvLyBTZXJ2ZXIK
</data>

          </attachment>
      

    </bug>

</bugzilla>