-
Notifications
You must be signed in to change notification settings - Fork 3.6k
HHH-19464 storing a binary data into blob on oracle cutting off its content #10160
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
HHH-19464 storing a binary data into blob on oracle cutting off its content #10160
Conversation
|
||
@Test | ||
void hibernate_blob_streaming(SessionFactoryScope scope) throws Exception { | ||
final var zipFilePath = getClass().getClassLoader().getResource( "org/hibernate/orm/test/lob/JarFileEntryBlobTest.zip" ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not great (and potentially dangerous) to have a zip
file just for testing purposes. Could we reproduce the error with a simple byte-array and org.hibernate.engine.jdbc.proxy.BlobProxy
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Any stream that will always read complete buffer (with exception of last read) will not expose this problem. java.util.zip.InflaterInputStream
can return less bytes before reading next bytes to be deflated.
Possible way to avoid zip file in resources is to create it temporary on th fly.
To avoid this GZIPOutputStream
can be used to deflate (random) bytes, then GZIPInputStream
can be used to create blob.
…]) returns less bytes than buffer length
a69a8b7
to
baad677
Compare
baad677
to
0add274
Compare
Jira issue HHH-19464
In
org.hibernate.type.descriptor.java.DataHelper#extractBytes(java.io.InputStream, long, int)
assumption thatjava.io.InputStream#read(byte[])
reached EOF when number of bytes read is less than size of buffer is not correct.By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license
and can be relicensed under the terms of the LGPL v2.1 license in the future at the maintainers' discretion.
For more information on licensing, please check here.