# Java getInputstream() - hängt!



## yigiter (22. Mai 2008)

Hallo zusammen,

ich moechte aus einer Url den Inhalt mit getInoutStream() holen, leider funktioniert das nicht immer, so das nach einiger Zeit die Threads keine Rückmeldung geben.

Code:

```
URL tUrl = new URL(aUrl);

URLConnection tConnection = tUrl.openConnection();

BufferedReader in = new BufferedReader(new InputStreamReader(tConnection.getInputStream(), CHARSET_UTF_8));

in.close();
```

Thread Dump:

```
"pool-6-thread-1" prio=10 tid=0x00002aaac80a9000 nid=0x3800 runnable [0x000000004143c000..0x000000004143cc00]
   java.lang.Thread.State: RUNNABLE
	at java.net.SocketInputStream.socketRead0(Native Method)
	at java.net.SocketInputStream.read(SocketInputStream.java:129)
	at java.io.BufferedInputStream.fill(BufferedInputStream.java:218)
	at java.io.BufferedInputStream.read1(BufferedInputStream.java:258)
	at java.io.BufferedInputStream.read(BufferedInputStream.java:317)
	- locked <0x00002aaab425a568> (a java.io.BufferedInputStream)
	at sun.net.www.http.ChunkedInputStream.fastRead(ChunkedInputStream.java:221)
	at sun.net.www.http.ChunkedInputStream.read(ChunkedInputStream.java:662)
	- locked <0x00002aaab4267168> (a sun.net.www.http.ChunkedInputStream)
	at java.io.FilterInputStream.read(FilterInputStream.java:116)
	at sun.net.www.protocol.http.HttpURLConnection$HttpInputStream.read(HttpURLConnection.java:2391)
	at sun.nio.cs.StreamDecoder.readBytes(StreamDecoder.java:264)
	at sun.nio.cs.StreamDecoder.implRead(StreamDecoder.java:306)
	at sun.nio.cs.StreamDecoder.read(StreamDecoder.java:158)
	- locked <0x00002aaab4267310> (a java.io.InputStreamReader)
	at java.io.InputStreamReader.read(InputStreamReader.java:167)
	at java.io.Reader.read(Reader.java:123)
	at javax.swing.text.html.parser.Parser.readCh(Parser.java:2272)
	at javax.swing.text.html.parser.Parser.parseContent(Parser.java:2123)
	at javax.swing.text.html.parser.Parser.parse(Parser.java:2211)
	- locked <0x00002aaab4267258> (a javax.swing.text.html.parser.DocumentParser)
	at javax.swing.text.html.parser.DocumentParser.parse(DocumentParser.java:105)
	at javax.swing.text.html.parser.ParserDelegator.parse(ParserDelegator.java:73)
	at javax.swing.text.html.HTMLEditorKit.read(HTMLEditorKit.java:230)
```

Hat einer eine Idee! wie das passieren kann!? Und welcher Workaround notwendig ist.. Java 1.6_04


----------



## zeja (23. Mai 2008)

Da sind ja auch wahnsinnig viele Locks drin... was genau machst du denn da? An dem Stück Code was du gepostet hast wird es eher nicht liegen.


----------

