]
Adrian Nistor updated ISPN-6042:
--------------------------------
Status: Open (was: New)
NPE when using avg on repeated property and one group does not
contain any value
--------------------------------------------------------------------------------
Key: ISPN-6042
URL:
https://issues.jboss.org/browse/ISPN-6042
Project: Infinispan
Issue Type: Bug
Components: Embedded Querying
Affects Versions: 8.1.0.Final
Reporter: Adrian Nistor
Assignee: Adrian Nistor
Fix For: 8.2.0.Alpha1, 8.1.1.Final
Adding this test to QueryDslConditionsTest results in NPE:
{code}
public void testEmbeddedAvg() {
QueryFactory qf = getQueryFactory();
Query q = qf.from(getModelFactory().getUserImplClass())
.select(Expression.property("surname"),
Expression.avg("addresses.number"))
.groupBy("surname")
.orderBy("surname")
.build();
List<Object[]> list = q.list();
assertEquals(3, list.size());
assertEquals(2, list.get(0).length);
assertEquals(2, list.get(1).length);
assertEquals(2, list.get(2).length);
assertEquals(156d, (Double) list.get(0)[1], 0.0001d);
assertEquals(150d, (Double) list.get(1)[1], 0.0001d);
assertEquals(null, list.get(2)[1]);
}
{code}
{code}
java.lang.NullPointerException
at
org.infinispan.objectfilter.impl.aggregation.AvgAccumulator.merge(AvgAccumulator.java:39)
at
org.infinispan.objectfilter.impl.aggregation.FieldAccumulator.merge(FieldAccumulator.java:42)
at org.infinispan.objectfilter.impl.aggregation.Grouper.addRow(Grouper.java:133)
at
org.infinispan.query.dsl.embedded.impl.AggregatingQuery.getBaseIterator(AggregatingQuery.java:52)
at
org.infinispan.query.dsl.embedded.impl.HybridQuery$1.<init>(HybridQuery.java:47)
at org.infinispan.query.dsl.embedded.impl.HybridQuery.getIterator(HybridQuery.java:45)
at
org.infinispan.query.dsl.embedded.impl.BaseEmbeddedQuery.listInternal(BaseEmbeddedQuery.java:65)
at
org.infinispan.query.dsl.embedded.impl.BaseEmbeddedQuery.list(BaseEmbeddedQuery.java:57)
at org.infinispan.query.dsl.embedded.impl.DelegatingQuery.list(DelegatingQuery.java:45)
at
org.infinispan.query.dsl.embedded.QueryDslConditionsTest.testEmbeddedAvg(QueryDslConditionsTest.java:2066)
{code}