Results 1 to 2 of 2
  1. #1
    joe131 is offline Member
    Join Date
    May 2010
    Posts
    1
    Rep Power
    0

    Default Session Variable corruption example..

    Hi All,

    While developing my application, I discovered a case where
    The Session variables are somehow getting "corrupted"
    after I make a JNI call:


    tempAddr = (long[])session.getAttribute("WMIAddrSave");
    if ( Util.DEBUG )
    {
    if ( tempAddr != null )
    {
    System.out.println("\n(Before)(WMIAddrSave)");
    System.out.println("[0]: "+Integer.toHexString((int)tempAddr[0])+
    " [1]: "+Integer.toHexString((int)tempAddr[1])+
    " [2]: "+Integer.toHexString((int)tempAddr[2]));
    }
    else
    System.out.println("tempAddr null");
    }



    ret = wmi.connect(
    Util.checkNull(connectNetworkResource),
    Util.checkNull(connectDomain),
    Util.checkNull(username),
    Util.checkNull(password),
    wmiAddrs,
    Util.checkNull(useWinRM),
    inDomain, retArray);




    if ( Util.DEBUG )
    {
    System.out.println();
    System.out.println("(wmiAddrs)After connect()");
    if ( wmiAddrs != null )
    {
    System.out.println("[0]: "+Integer.toHexString((int)wmiAddrs[0])+
    " [1]: "+Integer.toHexString((int)wmiAddrs[1])+
    " [2]: "+Integer.toHexString((int)wmiAddrs[2]));
    }
    else
    System.out.println("wmiAddrs null");
    }



    tempAddr = (long[])session.getAttribute("WMIAddrSave");
    if ( Util.DEBUG )
    {
    if ( tempAddr != null )
    {
    System.out.println("\n(After)F(WMIAddrSave)");
    System.out.println("[0]: "+Integer.toHexString((int)tempAddr[0])+
    " [1]: "+Integer.toHexString((int)tempAddr[1])+
    " [2]: "+Integer.toHexString((int)tempAddr[2]));
    }
    else
    System.out.println("tempAddr null");
    }

    ================================================== ==========================

    Debug output:


    (Before)(WMIAddrSave)
    [0]: 1a90ffd8 [1]: 1a8901d4 [2]: 0
    ===== connect() =====


    wcpServerName: 'WIN-F5C5780353'
    wcpDomain: ''
    wcpUserName: ''
    wcpPassword: ''
    wcpUseWinRM: 'HTTP'
    ======= IN WinRM =======
    At Connect_Exit..
    bSuccess: TRUE

    (wmiAddrs)After connect()
    [0]: 1aa516ac [1]: 0 [2]: 1aa546ac

    (After)F(WMIAddrSave)
    [0]: 1aa516ac [1]: 0 [2]: 1aa546ac




    You can see that the 'WMIAddrSave' Session variable contained:
    [0]: 1a90ffd8 [1]: 1a8901d4 [2]: 0

    before the call, and when the call returned it contained:
    [0]: 1aa516ac [1]: 0 [2]: 1aa546ac



    'wmiAddrs' is defined as:

    long[] wmiAddrs = new long[] {0, 0, 0};

    wmi.connect() makes C/C++ WMI and IDispatch calls.

    java version "1.5.0_11"


    I "got around it" by converting the long[] decimal values to ASCII
    back and forth. I know it sounds crazy, but without doing that, the Session variables would "switch", or get "corrupted" in other ways, values right after that function call.


    Thanks

  2. #2
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    12,097
    Rep Power
    20

Similar Threads

  1. how to use user name as a session variable in jsp
    By mudit222 in forum JavaServer Pages (JSP) and JSTL
    Replies: 4
    Last Post: 05-05-2010, 09:09 AM
  2. Replies: 1
    Last Post: 04-21-2009, 11:20 PM
  3. Replies: 1
    Last Post: 03-10-2009, 01:12 PM
  4. Replies: 2
    Last Post: 12-23-2008, 06:35 PM
  5. how to use session variable in my problem
    By Arif Baig in forum JavaServer Pages (JSP) and JSTL
    Replies: 1
    Last Post: 03-27-2008, 07:23 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •