Comments (4)
Thanks @inngvar. That isn't much of an embarrassing bug, is it?!?
I wonder how that was missed by our integration tests. Anyways, will fix.
from spring-content.
I looked at this a bit today. In fact it is working as designed; i.e. although a little weird the SQL is correct. When it comes to blob streaming the devil is in the detail as this blog post explains. On the surface JDBC provides several ways to get an input stream from a result set but when you go look at how they are implemented you often find they read the whole BLOB into memory.
This, in fact, is what MySQL does unless you use a feature called "locator emulation". With "locator emulation" turned on then the getBlob() jdbc api will use a different implementation that streams the content properly (i.e. in reasonable size chunks) through the memory space of the JVM running the mysql connector client. Without this the risk of OOMs are much greater and increase with the size of the content being stored.
To use "location emulation" you have to do a couple of things.
- You have to specify
emulateLocators=true
on the end of the jdbc connection string URL - The SQL you use to fetch the result set have to specify the name of the column that stores the blob/"locator". This is because behind the scenes when you call
getBlob
and thengetBinaryStream
on that blob object it creates and executes its own queries fetching chunks of the blob at a time and it uses the column name encoded in the sql statement to help create these queries. Presumably because otherwise it wouldnt know which column the blob was stored in.
So, it is not clear if this is working for you, or not. If it isnt then I suspect you might not have emulateLocators=true
on the end of your JDBC connection string. Admittedly, this isn't in our docs. So perhaps that is the bug here?
Anyways, let me know.
from spring-content.
Thank you, solution you suggest ( add emulateLocators=true) works fine.
And also thanks for the detailed description of the problem. As I thought, not everything is as obvious as it seemed.
from spring-content.
No problem. I'm going to close this as I think we are resolved. However, feel free to re-open or raise another issue if you find anything else.
from spring-content.
Related Issues (20)
- REST content request gives 404 when using spring.data.rest.base-path HOT 4
- Spring Method Security does not seem to work correctly. HOT 18
- Incompatibility between used versions of Hibernate Commons Annotations (5.1.2.Final) and Hibernate Core (6.1.7.Final) HOT 3
- Circular references in `AzureStorageConfiguration` during application startup HOT 1
- Spring-Content-JPA 2.9.0 nullpointer exception trying to setContent HOT 3
- Unable to use @EnableS3Stores in junit test annotated with @DataJpaTest HOT 9
- LockingAndVersioningRepositoryImpl seems to be shared between multiple repositories but caches EntityInformation HOT 2
- S3ContentStore, FilesystemContentStore, etc extend deprecated ContentStore HOT 2
- spring-content-fs depends on old version of Hibernate
- Fail to set content on nested content properties when using JPA. HOT 2
- @ContentLength field is set to 0 instead of null for nullable types
- POST to content-property without content-type results in NPE / HTTP-500 HOT 1
- Link relation and path configured with @RestResource ignored for content properties with multiple capital letters HOT 1
- Do not include junit as compile dependency
- Exception with unsetContent using SB3 and SC3.0.4 JPA Starter HOT 1
- File download not working on windows platform HOT 1
- How do I configure com.github.paulcwarren:spring-content-bom for spring boot kotlin gradle? HOT 1
- Hibernate dependency error HOT 4
- No suitable HttpMessageConverter found to read request body into object of type class com.example.demo.entity.client.image.Avatar from request with content type of image/png;charset=UTF-8 HOT 8
- Investigation into the cause of `java.lang.NullPointerException: Cannot invoke "org.springframework.content.commons.storeservice.StoreInfo.getInterface()" because the return value of "internal.org.springframework.content.rest.io.StoreResource.getStoreInfo()" is null`
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from spring-content.