You are viewing a plain text version of this content. The canonical link for it is here.
Posted to slide-dev@jakarta.apache.org by Valeriy Podkolzin <vp...@atg.com> on 2001/04/17 02:37:55 UTC

A BUG in JDBCContentStore

1. In storeContent(..) {

            if (contentLength == -1) {

                // If content length is unspecified, we have to buffer
                // to a temp file.
                String tempFileName = revisionUri + "-" + revisionNumber;

                int tempFileNameLength = tempFileName.length();
                if (tempFileNameLength > 200)
                    tempFileName = tempFileName.substring
                        (tempFileNameLength - 200, tempFileNameLength);
                tempFile = File.createTempFile(tempFileName, null);

                FileOutputStream fos = new FileOutputStream(tempFile);
                while (true) {
                    int nChar = is.read(buffer);
                    if (nChar == -1) {
                        break;
                    }
                    fos.write(buffer, 0, nChar);
                    position = position + nChar;
                }
                fos.close();

                if (position != contentLength) {
                    if (position < contentLength) {
                        // Not enough bytes read !!!
                        throw new IOException("Not enough bytes read");
                    }
                    if (position > contentLength) {
                        // Not enough bytes read !!!
                        throw new IOException("Too many bytes read");
                    }
                    // FIXME : Delete the file
                }

                is = new FileInputStream(tempFile);
                contentLength = tempFile.length();

            }

If contentLength == -1, the method always throws IOException because for a
real content source position > -1.

For myself I just commented out both IOException and SQL content store works
fine on PUT and GET content. I'm not sure of other possible consequences.

Valeriy Podkolzin



Re: A BUG in JDBCContentStore

Posted by Remy Maucherat <re...@apache.org>.
> 1. In storeContent(..) {

> If contentLength == -1, the method always throws IOException because for a
> real content source position > -1.
>
> For myself I just commented out both IOException and SQL content store
works
> fine on PUT and GET content. I'm not sure of other possible consequences.

Yes indeed. The problem was originally cause by Cut & Paste Abuse (TM).

Thanks !

Remy