Closing a stream in an applet causes a crash

S

Sam Takoy

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
 
A

Arne Vajhøj

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
 
E

Esmond Pitt

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 /////.
 
S

Sam Takoy

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
 
A

Arne Vajhøj

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
 
L

Lew

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|
|_____|_____|
|===========|
 
D

Daniele Futtorovic

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.
 
R

Roedy Green

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.
 
L

Lew

Daniele said:
<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.
 
A

Arne Vajhøj

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
 
K

Kevin McMurtrie

Sam Takoy said:
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.
 
L

Lars Enderin

2011-01-31 19:12, Daniele Futtorovic skrev:
<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.
 
D

Daniele Futtorovic

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.
 
D

Daniele Futtorovic

2011-01-31 19:12, Daniele Futtorovic skrev:

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.
 
L

Lew

Daniele said:
++ 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|
|_____|_____|
|===========|
 
A

Arne Vajhøj

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
 
D

Daniele Futtorovic

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.
 
L

Lew

Daniele said:
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.
 
D

Daniele Futtorovic

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.
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,263
Messages
2,571,064
Members
48,769
Latest member
Clifft

Latest Threads

Top