Index: C:/Dokumente und Einstellungen/markuss/workspace/magnolia2.1/src/main/info/magnolia/cms/core/CacheHandler.java =================================================================== --- C:/Dokumente und Einstellungen/markuss/workspace/magnolia2.1/src/main/info/magnolia/cms/core/CacheHandler.java (revision 1578) +++ C:/Dokumente und Einstellungen/markuss/workspace/magnolia2.1/src/main/info/magnolia/cms/core/CacheHandler.java (working copy) @@ -105,6 +105,9 @@ file.delete(); log.error(MessageFormat.format("NOT Caching uri [{0}] due to a previous error", //$NON-NLS-1$ new Object[]{uri})); + + // caching failed, return + return; } else { if (log.isInfoEnabled()) { @@ -122,8 +125,24 @@ gzipFile.createNewFile(); out = new FileOutputStream(gzipFile); GZIPOutputStream gzipOut = new GZIPOutputStream(out); - streamURI(uri, gzipOut, request); + boolean success = streamURI(uri, gzipOut, request); + gzipOut.flush(); gzipOut.close(); + if (!success) { + // don't leave bad or incomplete files! + gzipFile.delete(); + log.error(MessageFormat.format("NOT Caching compressed uri [{0}] due to a previous error", //$NON-NLS-1$ + new Object[]{uri})); + + // caching failed, return + return; + } + else { + if (log.isInfoEnabled()) { + log.info(MessageFormat.format("Successfully cached compressed URI [{0}]", //$NON-NLS-1$ + new Object[]{uri})); + } + } } compressedSize = (new Long(gzipFile.length())).intValue(); }