Seeing a problem adding two numbers together (or I've lost my mind)

I have a resource adapter that provides support for an implementation of the (RDP) Reliable Datagram Protocol (RFC 908/1151) that I wrote. I'm having a problem when this is deployed to a SunFire V480 with 4 CPUs running Glassfish 9.1u2 with JDK 1.6.0_05.
Basically what I am seeing is that when I add 1 to a number sometimes it works and sometimes it does not. So I am losing my mind and I am hoping someone here can help me see the errors in my ways.
The protocol uses sequence numbers similar to TCP. So in my code, when I receive a RDP message it need to check to see that the sequence number matches what is expected. Basically an instance of a class that represents a connection maintains the last sequence number seen and the message coming in had better have this sequence number plus 1.
Here is the code that I'm having a problem with:
+if (__LOGPROTO.isLoggable(Level.FINER)) {+
__LOGPROTO.finer("receiveMessage inmsg.seq = " inmsg.getSequenceNumber() + " __rcvcur = " + __rcvcur + " SEQ_PLUS = " + SEQ_PLUS(__rcvcur, 1) + "this = " + this);+
+}+
+if (inmsg.getSequenceNumber() == SEQ_PLUS(__rcvcur, 1)) {+
+if (inmsg.getDataLength() > 0) {+
+// Save the data+
ackMsg = new RDPAckMessage(inmsg);
__rcvdList.add(ackMsg);
+if (__LOGPROTO.isLoggable(Level.FINER)) {+
__LOGPROTO.finer("receiveMessage message queued to user " this);+
+}+
notifyReceivable = true;
+// Signal that there is data available+
__signal.setValue(true);
+}+
__rcvcur = inmsg.getSequenceNumber();
+// Now see if we have any out of order segments that can+
+// be queued to the user+
for (i = 0; i < __rcvrcvdseqno.length; i+) {+
+if (__rcvrcvdseqno != null) {+
if (__rcvrcvdseqno != null && SEQ_EQ(__rcvrcvdseqno.getSequenceNumber(),
+SEQ_PLUS(__rcvcur, 1))) {+
+__rcvcur = __rcvrcvdseqno] 0) {+
+// Move over to the received list+
ackMsg = new RDPAckMessage(__rcvrcvdseqno);
+if (__LOGPROTO.isLoggable(Level.FINER)) {+
__LOGPROTO.finer("receiveMessage ood message queued to user " this);+
+}+
__rcvdList.add(ackMsg);
notifyReceivable = true;
+// Signal that there is data available+
__signal.setValue(true);
+}+
__rcvrcvdseqno = null;
+}+
+}+
+}+
+} else {+
+if (__LOGPROTO.isLoggable(Level.FINER)) {+
__LOGPROTO.finer("xxx receiveMessage inmsg.seq = " inmsg.getSequenceNumber() + " __rcvcur = " + __rcvcur + " SEQ_PLUS = " + SEQ_PLUS(__rcvcur, 1) + "this = " + this);+
+}+
I have a couple of log messages that I put in to help try to figure out what in the heck is going on. The first prints out the message sequence number, the last sequence number that was known (__rcvcur), and the result of a method called SEQ_PLUS which passes in "__rcvcur" and '1".
Here is the SEQ_PLUS code:
+private long SEQ_PLUS(+
+long x,+
+long y) {+
+long z = (x + y) % 0x100000000L;+
+return z;+
+}+
Basically what I am seeing is that SEQ_PLUS is correctly adding 1 to "__rcvcur" on one call and then not adding 1 in the next.
Here is the log messages that occur. Note that "this" is the same in all of the log messages, that the thread is the same in all log messages, but in one instance SEQ_PLUS works and another it does not.
+[#|2008-09-23T11:04:49.580-0400|FINER|sun-appserver9.1|com.canoga.lib.io.rdp.RDPConnection.msg|_ThreadID=30;_ThreadName=RDPConnectionEngineUDP;ClassName=com.can+
+oga.java.io.rdp.RDPConnection;MethodName=receiveMessage;_RequestID=e6876cf2-0fb9-4de3-938a-484eee9a2b7a;|receving msg[<ACK> from=1024 to=1787 datalen=5 seq=16839 ack=1355376372] by RDPConnection(com.canoga.java.io.rdp.RDPConnection@125f069):/172.16.142.16|#]+
+[#|2008-09-23T11:04:49.581-0400|FINER|sun-appserver9.1|com.canoga.lib.io.rdp.RDPConnection.proto|_ThreadID=30;_ThreadName=RDPConnectionEngineUDP;ClassName=com.c+
+anoga.java.io.rdp.RDPConnection;MethodName=receiveMessage;_RequestID=e6876cf2-0fb9-4de3-938a-484eee9a2b7a;|receiveMessage inmsg.seq = 16839 __rcvcur = 16838 SEQ_PLUS = 16839this = RDPConnection(com.canoga.java.io.rdp.RDPConnection@125f069):/172.16.142.16|#]+
+[#|2008-09-23T11:04:49.581-0400|FINER|sun-appserver9.1|com.canoga.lib.io.rdp.RDPConnection.proto|_ThreadID=30;_ThreadName=RDPConnectionEngineUDP;ClassName=com.c+
+anoga.java.io.rdp.RDPConnection;MethodName=receiveMessage;_RequestID=e6876cf2-0fb9-4de3-938a-484eee9a2b7a;|xxx receiveMessage inmsg.seq = 16839 __rcvcur = 16838 SEQ_PLUS = 16838this = RDPConnection(com.canoga.java.io.rdp.RDPConnection@125f069):/172.16.142.16|#]+
I am at a loss as to how this could occur. I'm hoping some bright mind can see what I cannot.
Any help will be greatly appreciated.
Brett

Actually the nested code in the follow up is a SCCE:
                            if (__LOGPROTO.isLoggable(Level.FINER)) {
                                __LOGPROTO.finer("xxx receiveMessage inmsg.seq = " + inmsg.getSequenceNumber() + " __rcvcur = " + __rcvcur + " SEQ_PLUS = " + SEQ_PLUS(__rcvcur, 1L) + "this = " + this);
                                long x = __rcvcur;
                                long y = 1;
                                long z = (x + y) % 0x100000000L;
                                __LOGPROTO.finer("xxx x is " + x + " y is " + y + " z is " + z);
                            }There is nothing in this snippet that should allow "y" to be anything other than the value '1" which it is initialized to, no matter how many threads, cpu's, etc there may be since "x, y, and z" are stack local variables and "y' is never assigned to after it is initialized. The output of the log message shows however that sometimes it is different:
[#|2008-09-23T12:15:38.505-0400|FINER|sun-appserver9.1|com.canoga.lib.io.rdp.RDPConnection.proto|_ThreadID=28;_ThreadName=RDPConnectionEngineUDP;ClassName=com.c
anoga.java.io.rdp.RDPConnection;MethodName=receiveMessage;_RequestID=77189b23-d5ff-49c3-8194-662f468bbe66;|xxx x is 16838   is 4294967296 z is 16838|#]This code is within a very large Java EE application running under the Glassfish application server. The problem manifests itself about
about 1 of every 4 starts of the application server and I have only seen it occur on Solaris on my V480 server.
So if someone can explain how "y" becomes "4294967296" I would very thankful.

Similar Messages

  • Adding two sums together

    Post Author: nickyboyc
    CA Forum: Formula
    Hi guys, I'm very new to Crystal reports and having what I'm sure is a simple problem. I'm getting data from a Oracle Database via ODBC and I've created some summaries and groups and the final piece in my jigsaw is I want to add two sums together and for the life of me I can't find out how to do it. I've tried and tried and I just can't get it to work.They are in a group and the 2 sums are :
    Sum ({WMLocnHandlingMediaConf.QtyStor}
    and
    Sum ({WMLocnHandlingMediaConf.QtyIn}Many thanks in advance Nick

    Post Author: yangster
    CA Forum: Formula
    just create a formula with your 2 sums in there@sum
    Sum ({WMLocnHandlingMediaConf.QtyStor}+
    Sum ({WMLocnHandlingMediaConf.QtyIn}

  • Adding two BufferedImages together?

    Is there anyway to "for lack of a better word add two bufferedImages together?
    For example if I have a JLabel with an ImageIcon thats a red square 32 x 32 pixels and another JLabel with an ImageIocn thats a green square also 32 x 32 pixels. Can I create a new ImageIcon thats 64 x 32 pixels that is the red square and green square together?
    Something like new BufferedImage(image1, image2,  concanate_xaxis);Thanks,
    Cathal.
    cathal87

    Ive tryed to impliment your above suggestion camickr, but all I can seem to get as output is a black image.
    Heres some code that demonstrates my problem.
    Once the following code is compiled and run an image is created using all of the JLabels ImageIcons from the JFrame and its saved into a file at "C:/Image.png". Obviously this would have to be changed for testing purposes depending on ones OS and Drive letter preferences.
    import javax.swing.*;
    import javax.swing.event.*;
    import java.awt.*;
    import java.awt.event.*;
    import java.awt.image.BufferedImage;
    import java.io.*;
    import javax.imageio.*;
    public class Example2
           static JFrame frame;
           static JLayeredPane layeredPane;
           public static void main(String[] args)
                  frame = new JFrame("Example");
                  frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
                  frame.setResizable(false);
                  frame.setSize(320, 320);
                  frame.setLocationRelativeTo(null);
                  frame.getContentPane().setLayout(null);
                  layeredPane = new JLayeredPane();
                  layeredPane.setOpaque(true);
                  layeredPane.setLayout(null);
                  layeredPane.setBounds(0, 0, 320, 320);
                  frame.setContentPane(layeredPane);
                  for(int i = 0; i < 32; i ++)
                          for(int j = 0; j < 32; j ++)
                               JLabel label = new JLabel(new ImageIcon("images/grass.gif"));
                               layeredPane.add(label, new Integer(0));
                               label.setBounds(i * 32, j * 32, 32, 32);
                  frame.setVisible(true);
                  createAndSaveImage();
           public static void createAndSaveImage()
                  BufferedImage image = new BufferedImage(320, 320, BufferedImage.TYPE_INT_RGB);
                  Component[] components = layeredPane.getComponentsInLayer(0);
                  int count = 0;
                  for(int i = 0; i < 32; i ++)
                          for(int j = 0; j < 32; j ++)
                                  JLabel label = (JLabel)components[count];
                                  label.getGraphics().drawImage(image, i, j, 32, 32, null);
                                  count ++;
                  try
                        ImageIO.write(image, "png", new File("C:/Image.png"));
                  catch(Exception exexe)
    }

  • Adding two arrays together

    I am trying to add two arrays together, it does not seem as if the arrays are broken up into more than one index. I have attached my code. If the array is broken up into indexes I would like to add each corresponding index, but I think the array is all in just one index and if so I was wondering how would I break it into indexes. Thanks
    Attachments:
    SimpleTest x1.vi ‏336 KB

    Since you are "transposing" and later work with 1D array, I assume you want to read the first column of the file.
    Why do you need a sequence stacked 5 frames deep, local variables, 5 instances of the same boolean diagram constant and 5 path conststants of which some are identical??? None of this is needed!
    All you need is probably something along the lines of the following picture, which probably does something similar to what you want. Still, we are probably still jumping through too many flaming hoops. Note that the execution order is uniquely defined by the wiring alone, no sequence needed! Can you take a step back and tell us what you are actually trying to achieve with all this? How many columns are in the file? Only one?
    Message Edited by altenbach on 01-27-2009 04:02 PM
    LabVIEW Champion . Do more with less code and in less time .
    Attachments:
    AddArraysFromFile.png ‏13 KB

  • Adding two numbers

    Hi Frnds
    I am very much new to Oracle ADF and Jdeveloper.
    My requirement is , there are 3 input text field and a button.
    When I enter number values in text field 1 and 2 and press the button ,then the sum should be display in the 3rd text field.
    Like this way i ll try to build a calculator application.
    So please suggest me how to go ahead.
    The JDeveloper version I am using is 11.1.2.3.0
    Thanks in Advance

    Hello,
    as Frank said , this is not related to ADF
    and can be solved using a number of ways
    for example:
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
    "http://www.w3.org/TR/html4/loose.dtd">
    <%@ page contentType="text/html;charset=UTF-8"%>
    <%@ taglib uri="http://java.sun.com/jsf/core" prefix="f"%>
    <%@ taglib uri="http://java.sun.com/jsf/html" prefix="h"%>
    <%@ taglib uri="http://xmlns.oracle.com/adf/faces/rich" prefix="af"%>
    <f:view>
      <af:document id="d1">
        <af:form id="f1">
          <af:inputText label="Label 1" id="it1" value="#{requestScope.f1}"/>
          <af:inputText label="Label 2" id="it2" value="#{requestScope.f2}"/>
          <af:inputText label="Label 3" id="it3"
                        value="#{requestScope.f1 + requestScope.f2}"/>
          <af:commandButton text="commandButton 1" id="cb1"/>
        </af:form>
      </af:document>
    </f:view>
    Best Regards,
    Ahmad Al-Zamer

  • Adding two generic number types

    Hi all,
    As a small exercise I am trying to devise a generic maths class that can add two numbers together either Integer, Float and Double types.
    I have written the following code
    class Test {
    public static void main(String args[]) {
         MathClass<Integer> integers = new MathClass<Integer>();
         Integer i= new Integer(2);
         System.out.println(integers.add(i,i));
    class MathClass<T> {
         public T add(T a, T b) {
              return a + b;
         public T subtract(T a, T b) {
              return a - b;
         public T multiply(T a, T b) {
              return a * b;
         public T divide(T a, T b) {
              return a / b;
    }But I get a compile error which says that I can't use the + - * / operators on T.
    Yet something like the following code works
    public class Test2 {
       public static void main(String[] args) {
         Integer i = new Integer(2);
         Integer o = new Integer(2);
         System.out.println(i + o);
    }Is there a way to make the generic maths class work as I would like?

    Even with the UpperBound as Number it will not be able to work as the compiler will not be able to apply autoboxing feature with Number. Number class has byteValue(), intValue(), floatValue() and doubleValue() as method, so Number class is not a spefic datatype class.
    This will work because of the feature autoboxing.
    public Integer addInteger(Integer a, Integer b) {
              return a + b;
    This will not work...
         public Number addInteger(Number a, Number b) {
              return a + b;
         }

  • Adding two random generated numbers together?

    I'm writing a program for a class in which we have to simulate a two die rolling. So I got the computer to generate to random numbers, and now I need to add them to get the rolled die's sum. This info will then be organized into a chart. But I have no idea how to add to randomly generted numbers together, can anybody help me??
    import java.util.Random;
    import java.util.Scanner;
    public class Test
        public static void main(String [] args)
            //Start
            Scanner in = new Scanner (System.in);
            int randDieNum1 = 0;
            int randDieNum2 = 0;
            Random randDieNum1List = new Random();
            Random randDieNum2List = new Random();
            //User Input
            System.out.print("Number of Rolls: ");
            int numToRoll = in.nextInt();
            //Testints
            //Loop
            for(int rolled = 0; rolled != numToRoll; rolled ++)
                int randDie1 = randDieNum1List.nextInt(6) + 1;
                int randDie2 = randDieNum2List.nextInt(6) + 1;
                System.out.println("RandNum1: " + randDie1);
                System.out.println("RandNum2: " + randDie2);
                int final = (int)randDie1 + (int)randDie2;
                System.out.println("Add: " + randDie1 + randDie2);
    }

    You can't call the variable "final" as that's a Java keyword. Try something like "sum" or "total".
    (Also consider just using a single Random object and calling it twice to obtain the value for each of the dice.. And don't (cast) for the fun of it or as a talisman to ward off compiler messages.)

  • Problem-Solution: Help! I'm seeing my iCloud account two or more times in Notes and Contacts!

    Problem: Help! I’m seeing my iCloud account two or more times in Notes and Contacts!
    Solution:
    Open [System Preferences] >
    Open [iCloud] >
    Uncheck [Contacts] for each duplicate iCloud you see in Contacts. ex. My iCloud Account is listed three times = uncheck Contacts twice. The checkbox next to Contacts will fill back in again automatically.
    Uncheck [Notes] for each duplicate iCloud account you see in Notes. (same instructions for Contacts; repeat the steps for each duplicate account)
    Why is this happening?
    It has to do with iCloud Keychain. If you set up iCloud keychain on more than one Mac, it appears to duplicate the iCloud account in each respective application once per Mac. (ex. 2 Macs = 1 Duplicate). The good news is that the above fix appears to be permanent and does not reoccur.

    Minor addition:
    I’m setting up a new Mac—how can I avoid this?
    Turn on iCloud in System Preferences (SP)
    When asked if you wish to set up Mail, Contacts, Calendar, Find my Mac, et al., uncheck all boxes, and click Next.
    Check the “Keychain” box first, then check all other boxes except Contacts and Notes.
    Within a few minutes, these boxes will check themselves.

  • Problem araised in  adding two custom fields to ksb1 tcode.

    hi experts,
      I added tow fields vendor no, vendor name to Tcode:KSB1.
    i used user-exit :   coomep01 .
    in this exit i added two fields to ci_rkpos (include table) . i.e zlifnr,zname1.
    but that problem is ci_rkpos is not appearing in green color it means it is not transported .
    in development  client is working properly .
    using sm34 i added fields names.
    error is coming like this.
    The following syntax error occurred in the program SAPLXKAEP :
    "The data object "CS_RECORD" has no component called "ZLIFNR", but ther"
    Error in ABAP application program.
    The current ABAP program "SAPLKAEP" had to be terminated because one of the
    here wat ever we add the zfields will appear in kaep_coac ,so in this structure two added fields are appeared in dev client
    but,the same zfields when transported to quality is not appearing .
    please suggest how to do??

    hi breakpoint.
    yes i attached  in transport.
    in quality client.
    wat ever i wriiten code  in user exit it is coming ,but
    incldue table structure is not coming ,and even that fields are appearing in v_tkalv ,but in structure kaep_coac
    blank include strcuture CI_RKPOS is appearing ,but
    in dev client is working properly, and in quality first of all report is going to dump.
    here this tvode is using all 3 plants,how can i restrict to specified plant so that ,it will not affect others plant.
    suggest me how to do??
    Edited by: kamalsac on Aug 18, 2010 10:57 AM

  • Adding two special double numbers

    Adding two double numbers.
    say, 12543.34 and 42895.00 am getting in the decimal part .3999999.
    Now I want .34 instead .399999 and how??
    Can any body help me ??

    Read this (or search the forums--this question is asked at least once a day):
    http://docs.sun.com/source/806-3568/ncg_goldberg.html

  • Adding two possitive numbers results a negative????

    Hello everybody i posted that in an other subforum but i guess it was the wrong place. I have a strange problem that it's racking my brain! i have the following code for (int i=0;i<ascii.length;i++){
    int randNum=rand.nextInt(100000000);
    buffer=randNum*256+ascii[i];
    (ascii[i] is an array of four integers that picture an ascii characters).
    Normaly that would result a buffer full of positive numbers.In my case thats not always true. Many times i get as a result a negative number even if the other two numbers that i add are positive. What's wrong here?? Thanks in advance!

    Integer.MAX_VALUE is 0111 1111 1111 1111 1111 1111 1111 1111
    Add one to it, and you wrap around to Integer.MIN_VALUE: 1000 0000 000 0000 0000 0000 0000 0000 (-2 billionish)
    Keep addiing, and you end up at -1: 1111 1111 1111 1111 1111 1111 1111 1111
    http://en.wikipedia.org/wiki/Twos_complement

  • Hello The problem appeared two days ago is that I can't open my mail app. everything was fine and functional. Now I double click on the icon and it does not respond. it receives mail and I can see push notifications on the mail icon but when  I try t

    hello
    The problem appeared two days ago is that I can't open my mail app. everything was fine and functional. Now I double click on the icon and it does not respond. it receives mail and I can see push notifications on the mail icon but when  I try to open it is no use. OS Y 10.10.2 (14C1514)

    Please follow these directions to delete the Mail "sandbox" folder.
    Back up all data.
    Triple-click anywhere in the line below on this page to select it:
    ~/Library/Containers/com.apple.mail
    Right-click or control-click the highlighted line and select
              Services ▹ Reveal
    from the contextual menu.* A Finder window should open with a folder named "com.apple.mail" selected. If it does, move the selected folder—not just its contents—to the Desktop. Leave the Finder window open for now.
    Restart the computer. Launch Mail and test. If the problem is resolved, you may have to recreate some of your Mail settings. Any custom stationery that you created may be lost. Ask for instructions if you want to preserve that data. You can then delete the folder you moved and close the Finder window.
    Caution: If you change any of the contents of the sandbox, but leave the folder itself in place, Mail may crash or not launch at all. Deleting the whole sandbox will cause it to be rebuilt automatically.
    *If you don't see the contextual menu item, copy the selected text to the Clipboard by pressing the key combination  command-C. In the Finder, select
              Go ▹ Go to Folder...
    from the menu bar and paste into the box that opens by pressing command-V. You won't see what you pasted because a line break is included. Press return.

  • I just added two external firewire drives and they keep going to sleep.  I did not have this problem when USB.  I have turned off "put disks to sleep" in power preference.

    I just added two external firewire drives and they keep going to sleep.  I did not have this problem when using USB external drives.  I have turned off "put disks to sleep" in power preference.

    It is not clear if these are the same drives, just connected
    differently, or different drives?
    One thing that may be happening is that the drives firmware
    itself is putting it to sleep when inactive.  Many drives on
    the market have ths feature and it is turned on by default
    and require a drive utility from the manufacturer to disable it.

  • I am having problems because two phone numbers are on the Apple ID, how do I choose one for imessage?

    I am having problems because two phone numbers are on the Apple ID, how do I choose one for imessage?

    Hello,
    In my opinion, this is the best procedure to use to update your BB OS:
    http://supportforums.blackberry.com/t5/BlackBerry-Device-Software/How-To-Reload-Your-Operating-Syste...
    However, the official download site:
    http://us.blackberry.com/support/downloads/download_sites.jsp
    shows your installed OS to be the current version from your carrier. Therefore, how your friends got a newer OS is a question to ask them and/or your carrier.
    You are, of course, free to use (via the above procedure) any carriers OS package...if another has the newer OS you want, you can use it. If you choose to do so, then simply insert, between steps 1 and 2 in the above procedure, the deletion, on your PC, of a file named VENDOR.XML
    Good luck.
    Occam's Razor nearly always applies when troubleshooting technology issues!
    If anyone has been helpful to you, please show your appreciation by clicking the button inside of their post. Please click here and read, along with the threads to which it links, for helpful information to guide you as you proceed. I always recommend that you treat your BlackBerry like any other computing device, including using a regular backup schedule...click here for an article with instructions.
    Join our BBM Channels
    BSCF General Channel
    PIN: C0001B7B4   Display/Scan Bar Code
    Knowledge Base Updates
    PIN: C0005A9AA   Display/Scan Bar Code

  • How to merge to frequencies together and play it? I have a program that outputs two numbers everytime and those numbers in Hz. I want to merge those two different frequencies and play the sound.

    Hi there
    I have a program that reads from a table done in excel and finds two numbers from the table(they're different all the time). Those numbers are represented in Hz. What I want now is how to merge those two numbers as frequencies and output them and hear them from the speaker as audio. I also have the part of hearing them done but I can't figure out a way to have it connected so that it doesn't matter which numbers come up, it'll update it accordinaly. I appreciate any helpers.
    Thanks a lot

    Then I'm not sure what you're doing, or what your definition of "add" is. Here is the example I posted, with Signal 1 at 250 Hz and Signal 2 at 500 Hz:
    Message Edited by smercurio_fc on 01-15-2009 03:46 PM
    Attachments:
    add freqs.png ‏25 KB
    add freqs.vi ‏123 KB

Maybe you are looking for