Uploaded image for project: 'Infinispan'
  1. Infinispan
  2. ISPN-6042

NPE when using avg on repeated property and one group does not contain any value

This issue belongs to an archived project. You can view it, but you can't modify it. Learn more

XMLWordPrintable

      Adding this test to QueryDslConditionsTest results in NPE:

         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]);
         }
      
      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)
      

              anistor Adrian Nistor (Inactive)
              anistor Adrian Nistor (Inactive)
              Archiver:
              rhn-support-adongare Amol Dongare

                Created:
                Updated:
                Resolved:
                Archived: