Strange Socket Problem Solved!

Discussion in 'Java' started by Knute Johnson, Mar 10, 2012.

  1. I want to thank everybody that gave me ideas to help me find my problem
    with my program. It turns out that the problem was bad data throwing a
    RuntimeException in the thread, bringing it to a stop. I probably
    should have programmed it with bad data in mind but I didn't. We had an
    agreement on format and that was supposed to be that. I had some simple
    format checks but no protection for the Exception.

    I haven't seen the actual bad record yet but I put in traps for it and
    will have the offender soon.

    Thanks again everybody.

    --

    Knute Johnson
     
    Knute Johnson, Mar 10, 2012
    #1
    1. Advertising

  2. Knute Johnson

    Daniel Pitts Guest

    On 3/9/12 7:13 PM, Knute Johnson wrote:
    > I want to thank everybody that gave me ideas to help me find my problem
    > with my program. It turns out that the problem was bad data throwing a
    > RuntimeException in the thread, bringing it to a stop. I probably should
    > have programmed it with bad data in mind but I didn't. We had an
    > agreement on format and that was supposed to be that. I had some simple
    > format checks but no protection for the Exception.
    >
    > I haven't seen the actual bad record yet but I put in traps for it and
    > will have the offender soon.
    >
    > Thanks again everybody.
    >

    The lesson here should be that any "infinite loop" that you want to
    truly be infinite should have a "catch RuntimeException" inside of it.
    Unless you want an exception to end the loop. The nature of
    RuntimeException is that you never know what downstream code is going to
    throw it, and should be willing to handle it if you need to.

    On the other hand, "Bad data" should probably through a checked
    exception. I often try to differentiate checked vs unchecked as
    "Something that I have no control of, but should be reported", vs
    "Indication of a bug in the code." Of course, this isn't always the
    case, but often should be.
     
    Daniel Pitts, Mar 10, 2012
    #2
    1. Advertising

  3. On 3/10/2012 1:46 PM, Daniel Pitts wrote:
    > On 3/9/12 7:13 PM, Knute Johnson wrote:
    >> I want to thank everybody that gave me ideas to help me find my problem
    >> with my program. It turns out that the problem was bad data throwing a
    >> RuntimeException in the thread, bringing it to a stop. I probably should
    >> have programmed it with bad data in mind but I didn't. We had an
    >> agreement on format and that was supposed to be that. I had some simple
    >> format checks but no protection for the Exception.
    >>
    >> I haven't seen the actual bad record yet but I put in traps for it and
    >> will have the offender soon.
    >>
    >> Thanks again everybody.
    >>

    > The lesson here should be that any "infinite loop" that you want to
    > truly be infinite should have a "catch RuntimeException" inside of it.
    > Unless you want an exception to end the loop. The nature of
    > RuntimeException is that you never know what downstream code is going to
    > throw it, and should be willing to handle it if you need to.
    >
    > On the other hand, "Bad data" should probably through a checked
    > exception. I often try to differentiate checked vs unchecked as
    > "Something that I have no control of, but should be reported", vs
    > "Indication of a bug in the code." Of course, this isn't always the
    > case, but often should be.


    All true. It also shows how hard it is sometimes to diagnose a problem.
    I was sure it was related to a Socket issue because it wouldn't
    reconnect. I just didn't think through the problem of a
    RuntimeException causing the thread to stop. And that was partly
    because I didn't think the data was going to be the problem. We did the
    data format design, the big giant heads talked to the other big giant
    heads and they said the data will come in this format. Us pinheads
    never planned for the data coming out of format. So there you go.

    --

    Knute Johnson
     
    Knute Johnson, Mar 11, 2012
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Michael Bacarella
    Replies:
    26
    Views:
    1,353
    harri
    Nov 20, 2007
  2. Laszlo Nagy
    Replies:
    1
    Views:
    4,860
    Mark Wooding
    Jan 27, 2009
  3. Jean-Paul Calderone
    Replies:
    0
    Views:
    974
    Jean-Paul Calderone
    Jan 27, 2009
  4. Laszlo Nagy
    Replies:
    0
    Views:
    553
    Laszlo Nagy
    Feb 1, 2009
  5. Steve Holden
    Replies:
    0
    Views:
    669
    Steve Holden
    Feb 1, 2009
Loading...

Share This Page