Closed andreak closed 2 years ago
It seems it's EclipseLink not free()
-ing the Array
after creation.
According to https://docs.oracle.com/javase/tutorial/jdbc/basics/array.html the Array returned should be freed after use.
The offending code is in EL's AbstractCompositeDirectCollectionMapping.writeFromObjectIntoRow
where the result-value of this.getDescriptor().buildFieldValueFromDirectValues
is never freed:
@Override
public void writeFromObjectIntoRow(Object object, AbstractRecord row, AbstractSession session, WriteType writeType) {
if (this.isReadOnly()) {
return;
}
Object attributeValue = this.getAttributeValueFromObject(object);
if (attributeValue == null) {
row.put(this.getField(), null);
return;
}
ContainerPolicy cp = this.getContainerPolicy();
Vector elements = new Vector(cp.sizeFor(attributeValue));
for (Object iter = cp.iteratorFor(attributeValue); cp.hasNext(iter);) {
Object element = cp.next(iter, session);
if (this.getValueConverter() != null) {
element = getValueConverter().convertObjectValueToDataValue(element, session);
}
if (element != null) {
elements.addElement(element);
}
}
Object fieldValue = null;
if (!elements.isEmpty()) {
fieldValue = this.getDescriptor().buildFieldValueFromDirectValues(elements, elementDataTypeName, session);
}
row.put(this.getField(), fieldValue);
// fieldValue should be free() here.
Hi all, I'm saving an JPA @Entity using EclipseLink and pgjdbc-ng-0.8.9 against PG-14.2, and I get this stacktrace:
Other places where we extract data from SQLArray we've wrapped them in this method (in Scala, but you get the idea):
Can this LEAK be caused by EclipseLink not calling
sqlArray.free()
or is it an actual leak in the driver, or something else?