Closing a stream in an applet causes a crash

Discussion in 'Java' started by Sam Takoy, Jan 31, 2011.

  1. Sam Takoy

    Sam Takoy Guest

    Hi,

    I have a signed applet that includes the following code:

    URL url = new URL(urlString);
    URLConnection urlc = url.openConnection();

    InputStream is = urlc.getInputStream();


    /////

    is.close();


    And everything works perfectly in terms of opening the stream and
    reading from it, until I attempt is.close() - then I get the

    java.io.IOException: stream is closed

    exception. Interestingly, this does not happen when I use the same code
    from an application rather than a signed applet. What could be going on
    here?

    Thanks in advance!

    Sam
    Sam Takoy, Jan 31, 2011
    #1
    1. Advertising

  2. Sam Takoy

    Arne Vajhøj Guest

    On 30-01-2011 19:04, Sam Takoy wrote:
    > I have a signed applet that includes the following code:
    >
    > URL url = new URL(urlString);
    > URLConnection urlc = url.openConnection();
    >
    > InputStream is = urlc.getInputStream();
    >
    >
    > /////
    >
    > is.close();
    >
    >
    > And everything works perfectly in terms of opening the stream and
    > reading from it, until I attempt is.close() - then I get the
    >
    > java.io.IOException: stream is closed
    >
    > exception. Interestingly, this does not happen when I use the same code
    > from an application rather than a signed applet. What could be going on
    > here?


    The only explanation I can think of is that the underlying TCP/IP
    tries to send a closing to the other end and that send is failing.

    Arne
    Arne Vajhøj, Jan 31, 2011
    #2
    1. Advertising

  3. Sam Takoy

    Esmond Pitt Guest

    On 31/01/2011 11:04 AM, Sam Takoy wrote:
    > And everything works perfectly in terms of opening the stream and
    > reading from it, until I attempt is.close() - then I get the
    >
    > java.io.IOException: stream is closed
    >
    > exception.


    That exception means you have already closed the stream or the
    connection yourself. Somewhere in the part starting /////.
    Esmond Pitt, Jan 31, 2011
    #3
  4. Sam Takoy

    Sam Takoy Guest

    On 1/30/2011 7:58 PM, Esmond Pitt wrote:
    > On 31/01/2011 11:04 AM, Sam Takoy wrote:
    >> And everything works perfectly in terms of opening the stream and
    >> reading from it, until I attempt is.close() - then I get the
    >>
    >> java.io.IOException: stream is closed
    >>
    >> exception.

    >
    > That exception means you have already closed the stream or the
    > connection yourself. Somewhere in the part starting /////.



    Thanks for the responses, but like I said, I run the same code as an
    application and as an applet and it fails only in the applet.

    Thanks.

    Sam
    Sam Takoy, Jan 31, 2011
    #4
  5. Sam Takoy

    Arne Vajhøj Guest

    On 30-01-2011 19:58, Esmond Pitt wrote:
    > On 31/01/2011 11:04 AM, Sam Takoy wrote:
    >> And everything works perfectly in terms of opening the stream and
    >> reading from it, until I attempt is.close() - then I get the
    >>
    >> java.io.IOException: stream is closed
    >>
    >> exception.

    >
    > That exception means you have already closed the stream or the
    > connection yourself. Somewhere in the part starting /////.


    That is specific for net?

    A file does not throw an exception in that case.

    Arne
    Arne Vajhøj, Jan 31, 2011
    #5
  6. Sam Takoy

    Lew Guest

    On 01/30/2011 08:34 PM, Sam Takoy wrote:
    > On 1/30/2011 7:58 PM, Esmond Pitt wrote:
    >> On 31/01/2011 11:04 AM, Sam Takoy wrote:
    >>> And everything works perfectly in terms of opening the stream and
    >>> reading from it, until I attempt is.close() - then I get the
    >>>
    >>> java.io.IOException: stream is closed
    >>>
    >>> exception.

    >>
    >> That exception means you have already closed the stream or the
    >> connection yourself. Somewhere in the part starting /////.

    >
    >
    > Thanks for the responses, but like I said, I run the same code as an
    > application and as an applet and it fails only in the applet.


    Well, la-dee-dah. Since you have not deigned to share your code with us I
    guess we'll have to be in the dark about what you're doing differently in the
    application context from the applet context. Since applets and applications
    start differently, one thing we can be sure of is that it's not the same code.

    Also, IOExceptions arise from external circumstances, i.e., the failure of an
    I/O operation. Application and applet environments are notably different. No
    doubt you are failing to handle that difference correctly.

    Another thing we can be sure of is that your carefully hidden code contains no
    exception handler for the 'close()' operation. Tsk, tsk.

    http://sscce.org/ if you want answers beyond, "Well, you did something wrong."
    That's all we can conclude based on the dearth of information you see fit to
    dole out.

    --
    Lew
    Ceci n'est pas une fenêtre.
    ..___________.
    |###] | [###|
    |##/ | *\##|
    |#/ * | \#|
    |#----|----#|
    || | * ||
    |o * | o|
    |_____|_____|
    |===========|
    Lew, Jan 31, 2011
    #6
  7. On 31/01/2011 04:00, Lew allegedly wrote:
    >That's all we can conclude based on the dearth of information
    > you see fit to dole out.

    <3

    If you write code like you write English, I'd like to read your code.
    Daniele Futtorovic, Jan 31, 2011
    #7
  8. Sam Takoy

    Roedy Green Guest

    On Sun, 30 Jan 2011 19:04:18 -0500, Sam Takoy <>
    wrote, quoted or indirectly quoted someone who said :

    > URL url = new URL(urlString);
    > URLConnection urlc = url.openConnection();
    >
    > InputStream is = urlc.getInputStream();


    You can't do that unless the Applet is signed. Go into the control
    panel and turn on the console so you can get more detail on where and
    why it died.


    See http://mindprod.com/jgloss/signedapplet.html
    --
    Roedy Green Canadian Mind Products
    http://mindprod.com
    To err is human, but to really foul things up requires a computer.
    ~ Farmer's Almanac
    It is breathtaking how a misplaced comma in a computer program can
    shred megabytes of data in seconds.
    Roedy Green, Jan 31, 2011
    #8
  9. Sam Takoy

    Lew Guest

    Lew allegedly wrote:
    >> That's all we can conclude based on the dearth of information
    >> you see fit to dole out.

    >


    Daniele Futtorovic wrote:
    > <3
    >
    > If you write code like you write English, I'd like to read your code.
    >


    Thank you, sirrah, for that laudatory feedback.

    My code is even better written, but somewhat less sesquipedalian. :)

    Kidding aside, I do practice precise and nuanced expression of intent
    in code, as best I can. I am an ardent Javadoc commenter and have
    rather obsessive patterns for brace placement, whitespace and such.
    I'm a huge fan of generics and interfaces, and I like long walks on
    the beach.

    Well, I haven't been such a fan of long walks on the beach since
    moving away from a maritime area, but I used to enjoy walking my dog
    at low tide.

    --
    Lew
    Lew, Jan 31, 2011
    #9
  10. Sam Takoy

    Arne Vajhøj Guest

    On 31-01-2011 15:53, Roedy Green wrote:
    > On Sun, 30 Jan 2011 19:04:18 -0500, Sam Takoy<>
    > wrote, quoted or indirectly quoted someone who said :
    >> URL url = new URL(urlString);
    >> URLConnection urlc = url.openConnection();
    >>
    >> InputStream is = urlc.getInputStream();

    >
    > You can't do that unless the Applet is signed. Go into the control
    > panel and turn on the console so you can get more detail on where and
    > why it died.


    Given that the applet dies i the close call, then
    it is hardly relevant.

    Oh - and it not really correct wither - the applet only needs
    to be signed if the URL from a different site than where
    the applet were retrieved.

    Arne
    Arne Vajhøj, Jan 31, 2011
    #10
  11. Sam Takoy

    Esmond Pitt Guest

    On 31/01/2011 12:45 PM, Arne Vajhøj wrote:
    > That is specific for net?


    I think it's specific for URLConnection streams actually. Most closes
    are idempotent in the JDK.
    Esmond Pitt, Jan 31, 2011
    #11
  12. In article <ii4ua5$elc$-september.org>,
    Sam Takoy <> wrote:

    > Hi,
    >
    > I have a signed applet that includes the following code:
    >
    > URL url = new URL(urlString);
    > URLConnection urlc = url.openConnection();
    >
    > InputStream is = urlc.getInputStream();
    >
    >
    > /////
    >
    > is.close();
    >
    >
    > And everything works perfectly in terms of opening the stream and
    > reading from it, until I attempt is.close() - then I get the
    >
    > java.io.IOException: stream is closed
    >
    > exception. Interestingly, this does not happen when I use the same code
    > from an application rather than a signed applet. What could be going on
    > here?
    >
    > Thanks in advance!
    >
    > Sam


    You need to post more to get help. The InputStream is going to have
    several layers of protocol handlers between you and the socket. It's
    probable that your use has caused one layer to close the connection but
    another layer is trying to read a trailer.
    --
    I will not see posts or email from Google because I must filter them as spam
    Kevin McMurtrie, Feb 1, 2011
    #12
  13. Sam Takoy

    Lars Enderin Guest

    2011-01-31 19:12, Daniele Futtorovic skrev:
    > On 31/01/2011 04:00, Lew allegedly wrote:
    >> That's all we can conclude based on the dearth of information
    >> you see fit to dole out.

    > <3
    >
    > If you write code like you write English, I'd like to read your code.


    Edsger W Dijkstra:

    Besides a mathematical inclination, an exceptionally good mastery of
    one's native tongue is the most vital asset of a competent programmer.
    Lars Enderin, Feb 1, 2011
    #13
  14. On 31/01/2011 23:22, Lew allegedly wrote:
    > Kidding aside, I do practice precise and nuanced expression of intent
    > in code, as best I can. I am an ardent Javadoc commenter and have
    > rather obsessive patterns for brace placement, whitespace and such.
    > I'm a huge fan of generics and interfaces, and I like long walks on
    > the beach.


    ++ and splitting nested expressions over many lines. Do prefer mountains
    and felinae, though. ;)

    df.
    Daniele Futtorovic, Feb 1, 2011
    #14
  15. On 01/02/2011 10:35, Lars Enderin allegedly wrote:
    > 2011-01-31 19:12, Daniele Futtorovic skrev:
    >> On 31/01/2011 04:00, Lew allegedly wrote:
    >>> That's all we can conclude based on the dearth of information you
    >>> see fit to dole out.

    >> <3
    >>
    >> If you write code like you write English, I'd like to read your
    >> code.

    >
    > Edsger W Dijkstra:
    >
    > Besides a mathematical inclination, an exceptionally good mastery of
    > one's native tongue is the most vital asset of a competent
    > programmer.


    Would extend that to tongues in general. After all, our business is in
    getting clearly understood by machines. What's that, if not linguistics?
    See L. Wall. Except perhaps that as opposed to vulgar linguistics, we
    control both sides.
    Daniele Futtorovic, Feb 1, 2011
    #15
  16. Sam Takoy

    Lew Guest

    Lew allegedly wrote:
    >> Kidding aside, I do practice precise and nuanced expression of intent
    >> in code, as best I can. I am an ardent Javadoc commenter and have
    >> rather obsessive patterns for brace placement, whitespace and such.
    >> I'm a huge fan of generics and interfaces, and I like long walks on
    >> the beach.


    Daniele Futtorovic wrote:
    > ++ and splitting nested expressions over many lines. Do prefer mountains and
    > felinae, though. ;)


    It's cats and dogs reigning.

    --
    Lew
    Ceci n'est pas une fenêtre.
    ..___________.
    |###] | [###|
    |##/ | *\##|
    |#/ * | \#|
    |#----|----#|
    || | * ||
    |o * | o|
    |_____|_____|
    |===========|
    Lew, Feb 1, 2011
    #16
  17. Sam Takoy

    Arne Vajhøj Guest

    On 01-02-2011 13:35, Daniele Futtorovic wrote:
    > On 01/02/2011 10:35, Lars Enderin allegedly wrote:
    >> 2011-01-31 19:12, Daniele Futtorovic skrev:
    >>> On 31/01/2011 04:00, Lew allegedly wrote:
    >>>> That's all we can conclude based on the dearth of information you
    >>>> see fit to dole out.
    >>> <3
    >>>
    >>> If you write code like you write English, I'd like to read your
    >>> code.

    >>
    >> Edsger W Dijkstra:
    >>
    >> Besides a mathematical inclination, an exceptionally good mastery of
    >> one's native tongue is the most vital asset of a competent
    >> programmer.

    >
    > Would extend that to tongues in general. After all, our business is in
    > getting clearly understood by machines. What's that, if not linguistics?
    > See L. Wall. Except perhaps that as opposed to vulgar linguistics, we
    > control both sides.


    But masters of both programming languages and natural languages
    does not use their skills to use all features of the languages - they
    use their skills to communicate in a ways so that everybody
    understands it.

    Arne
    Arne Vajhøj, Feb 2, 2011
    #17
  18. On 02/02/2011 02:09, Arne Vajhøj allegedly wrote:
    > On 01-02-2011 13:35, Daniele Futtorovic wrote:
    >> On 01/02/2011 10:35, Lars Enderin allegedly wrote:
    >>> 2011-01-31 19:12, Daniele Futtorovic skrev:
    >>>> On 31/01/2011 04:00, Lew allegedly wrote:
    >>>>> That's all we can conclude based on the dearth of
    >>>>> information you see fit to dole out.
    >>>> <3
    >>>>
    >>>> If you write code like you write English, I'd like to read your
    >>>> code.
    >>>
    >>> Edsger W Dijkstra:
    >>>
    >>> Besides a mathematical inclination, an exceptionally good
    >>> mastery of one's native tongue is the most vital asset of a
    >>> competent programmer.

    >>
    >> Would extend that to tongues in general. After all, our business
    >> is in getting clearly understood by machines. What's that, if not
    >> linguistics? See L. Wall. Except perhaps that as opposed to vulgar
    >> linguistics, we control both sides.

    >
    > But masters of both programming languages and natural languages does
    > not use their skills to use all features of the languages - they use
    > their skills to communicate in a ways so that everybody understands
    > it.


    Do they indeed?

    Firstly, as I think is pretty much the case for all masteries of a
    particular type, you'll often see masters indulging in pointless doodles
    and plays that summon all the extent of their mastery. Kind of a
    self-gratification for having had to go through the trouble of acquiring
    the knowledge -- as such a very understandable feat which I don't think
    there is anything inherently wrong with.

    Secondly, I fail to see a necessary correlation between greater command
    of a tongue and being able more effectively to make oneself understood.
    Partly because that greater command might open access to the expression
    of more complex thoughts, partly because it might cleanse one's speech
    of the inaccuracies or inadequacies that prevail in the vulgar.

    Lastly and perhaps most importantly, if the master finds his mastery to
    be a Satisfying Thing (patent pending) and happens to be humanistically
    inclined, mightn't he wish it unto others? And to that end, tease them
    and encourage them upon the path?

    df.
    Daniele Futtorovic, Feb 2, 2011
    #18
  19. Sam Takoy

    Lew Guest

    Daniele Futtorovic wrote:
    > Lastly and perhaps most importantly, if the master finds his mastery to
    > be a Satisfying Thing (patent pending) and happens to be humanistically
    > inclined, mightn't he wish it unto others? And to that end, tease them
    > and encourage them upon the path?
    >


    More likely he'll tease those who do not show talent for the field of
    which he's so fond, in an attempt to drive them either to excellence
    or to a job that doesn't require nearly as much skill.

    It doesn't serve a practitioner "humanistically" or otherwise to
    encourage them upon a path for which they are ill suited. A master
    will recognize that and only encourage those who have a chance to
    progress.

    For the rest, it's, "Would you like fries with that?" and the world is
    a better place for that.

    --
    Lew
    Lew, Feb 2, 2011
    #19
  20. On 02/02/2011 21:50, Lew allegedly wrote:
    > Daniele Futtorovic wrote:
    >> Lastly and perhaps most importantly, if the master finds his mastery to
    >> be a Satisfying Thing (patent pending) and happens to be humanistically
    >> inclined, mightn't he wish it unto others? And to that end, tease them
    >> and encourage them upon the path?
    >>

    >
    > More likely he'll tease those who do not show talent for the field of
    > which he's so fond, in an attempt to drive them either to excellence
    > or to a job that doesn't require nearly as much skill.
    >
    > It doesn't serve a practitioner "humanistically" or otherwise to
    > encourage them upon a path for which they are ill suited. A master
    > will recognize that and only encourage those who have a chance to
    > progress.
    >
    > For the rest, it's, "Would you like fries with that?" and the world is
    > a better place for that.


    Yeah, but at the same time he might not be pressed to repudiate anyone,
    instead living and letting live, if it weren't for external forces which
    take malign and interested pleasure in putting the inept in his way so
    as to erode the value of his skill.

    These external forces he will never succeed in getting to sell shakes as
    long as he persists in idiosyncratic complacency.

    --
    DF.
    Daniele Futtorovic, Feb 2, 2011
    #20
    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. Edward
    Replies:
    1
    Views:
    549
    =?Utf-8?B?U2NvdHQgU2ltb25z?=
    Oct 14, 2004
  2. =?Utf-8?B?QkQgSm9uZXM=?=

    Hourglass ('wait') cursor causes IE to crash

    =?Utf-8?B?QkQgSm9uZXM=?=, Oct 26, 2004, in forum: ASP .Net
    Replies:
    0
    Views:
    573
    =?Utf-8?B?QkQgSm9uZXM=?=
    Oct 26, 2004
  3. Bytz
    Replies:
    9
    Views:
    548
    Jeff Dillon
    Apr 13, 2006
  4. Marcel Raap

    Xvfb causes iPlanet to crash

    Marcel Raap, Jul 13, 2004, in forum: Java
    Replies:
    0
    Views:
    348
    Marcel Raap
    Jul 13, 2004
  5. Dusty Lefevre
    Replies:
    0
    Views:
    807
    Dusty Lefevre
    Mar 27, 2005
Loading...

Share This Page