• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Bear Bibeault
  • Junilu Lacar
  • Jeanne Boyarsky
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • salvin francis
  • Frits Walraven
  • Scott Selikoff
  • Piet Souris
  • Carey Brown

Corrupt GZIP trailer

Ranch Hand
Posts: 60
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm trying to convert a log file to a gzip file, and another application will unzip the file to a log file. I have attached my class that does so below. This is the error I get :

1132 [Thread-0] INFO util.GZipUtil - in unzip func
1132 [Thread-0] INFO util.GZipUtil - input file name = 1098035357042.gzip
1132 [Thread-0] INFO util.GZipUtil - output file name = c:\aaa\logs\1098035357042.log
1162 [Thread-0] INFO util.GZipUtil - (int)file.length() = 105
java.io.IOException: Corrupt GZIP trailer
1162 [Thread-0] DEBUG util.GZipUtil - java.io.IOException: Corrupt GZIP trailer
1162 [Thread-0] INFO LoggingTask - unzippedFile - c:\aaa\logs\1098035357042.log
at java.util.zip.GZIPInputStream.readTrailer(Unknown Source)
at java.util.zip.GZIPInputStream.read(Unknown Source)
at java.io.FilterInputStream.read(Unknown Source)
at com.patronsolutions.messaging.util.GZipUtil.unzip(GZipUtil.java:108)
at LoggingTask.run(LogGateLinkInfo.java:131)
at java.util.TimerThread.mainLoop(Unknown Source)
at java.util.TimerThread.run(Unknown Source)
V10/1/20042:32:23 PMPARKGATE A110180060033846ERUD CODE-10110331221True


I did find a bug that says that the gzip has a bug if the inflated file size is >2GB then we get the above exception. In my case I get it even when the file size is 89 bytes. Also my data get altered after I have unzipped it.
Data before zipping:
V10/1/20042:32:23 PMPARKGATE A110180060033846BUD CODE-11110031221True

Data after unzipping:
V10/1/20042:32:23 PMPARKGATE A110180060033846ERUD CODE-10110331221True

Can anyone help me out with this? Should I use gzip or zip for this? How does one decide which one to use? I read that the zip(not gzip) also has a bug in java. What does this "Corrupt GZIP trailer" mean?

Here is my code:

Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm afraid there is something in your program which you should give a second thought:

when you say
byte[] buf = new byte[(int)file.length()];

casting the file length to int , there are chances that you corrupt the stream for file sizes which are greater than
2148 MB , I think you will run into stream corruption in these cases....
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, did you ever figure out a solution? I'm running into very similar issue (same error) but in a slightly different scenario...

I'm not even writing anything to file, just create the input and output streams and then send it back...
Posts: 21997
Eclipse IDE Spring VI Editor Chrome Java Ubuntu Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Neither Karen nor Ajith has been active for years, so I doubt you will get an answer from them.
Because those who mind don't matter and those who matter don't mind - Seuss. Tiny ad:
Thread Boost feature
    Bookmark Topic Watch Topic
  • New Topic