GZIPInputStream fails with IOException in Android 2.3, but works fine in all previous releases?

I'm running into the same issue here. It looks like Gingerbread (2.3) changed the way GZipped streams are handled. Looking at the "magic block" characters indicates that openStream() automatically detects GZipped data and runs it through the correct stream decoder.

Of course, if you attempt to run another GZIP decoder on the same stream, that will fail with an IOException There are a couple ways to handle this. The first way is to switch to HttpClient/HttpGet. BUT there is no guarantee that this also won't change in the future.

Basically, that is a hack to get it working again. A more complete solution might be to do: InputStream in = url.openStream(); GZIPInputStream zin; try { zin = (GZIPInputStream)in; } catch (Exception e) { zin = new GZIPInputStream(in); } For older versions of Android, an exception fires while attempting the cast and, on newer versions of Android, the cast succeeds. Abusing an exception handler this way is not pretty but it works This, of course, will be a problem for underlying data that is compressed or binary data that looks like it is GZIP compressed data.

The Android devs think this change isn't a bug: http://code.google.com/p/android/issues/detail?id=16227 I disagree. This is severe breakage.

I'm running into the same issue here. It looks like Gingerbread (2.3) changed the way GZipped streams are handled. Looking at the "magic block" characters indicates that openStream() automatically detects GZipped data and runs it through the correct stream decoder.

Of course, if you attempt to run another GZIP decoder on the same stream, that will fail with an IOException. There are a couple ways to handle this. The first way is to switch to HttpClient/HttpGet.

BUT there is no guarantee that this also won't change in the future. Basically, that is a hack to get it working again. A more complete solution might be to do: InputStream in = url.openStream(); GZIPInputStream zin; try { zin = (GZIPInputStream)in; } catch (Exception e) { zin = new GZIPInputStream(in); } For older versions of Android, an exception fires while attempting the cast and, on newer versions of Android, the cast succeeds.

Abusing an exception handler this way is not pretty but it works. This, of course, will be a problem for underlying data that is compressed or binary data that looks like it is GZIP compressed data. The Android devs think this change isn't a bug: http://code.google.com/p/android/issues/detail?id=16227 I disagree.

This is severe breakage.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions