From 419898854b15fe9b5aab8af268b9152cdc25dff7 Mon Sep 17 00:00:00 2001 From: Will Dazey Date: Fri, 20 Aug 2021 18:44:51 -0500 Subject: [PATCH] Bug 1245: NullPointerException from BatchFetchPolicy dataResults Signed-off-by: Will Dazey --- .../eclipse/persistence/queries/BatchFetchPolicy.java | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/foundation/org.eclipse.persistence.core/src/main/java/org/eclipse/persistence/queries/BatchFetchPolicy.java b/foundation/org.eclipse.persistence.core/src/main/java/org/eclipse/persistence/queries/BatchFetchPolicy.java index 7e5eef0d520..5f9eb0e8064 100644 --- a/foundation/org.eclipse.persistence.core/src/main/java/org/eclipse/persistence/queries/BatchFetchPolicy.java +++ b/foundation/org.eclipse.persistence.core/src/main/java/org/eclipse/persistence/queries/BatchFetchPolicy.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2019 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 2021 Oracle and/or its affiliates. All rights reserved. * * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v. 2.0 which is available at @@ -52,11 +52,13 @@ public class BatchFetchPolicy implements Serializable, Cloneable { protected transient Map batchObjects; public BatchFetchPolicy() { - this.type = BatchFetchType.JOIN; + this(BatchFetchType.JOIN); } public BatchFetchPolicy(BatchFetchType type) { this.type = type; + this.dataResults = new HashMap>(); + this.dataResults.put(this, new ArrayList()); } @Override @@ -236,10 +238,6 @@ public boolean isAttributeBatchRead(ClassDescriptor mappingDescriptor, String at * This is used for IN batching in batches. */ public void addDataResults(AbstractRecord row) { - if (this.dataResults == null) { - this.dataResults = new HashMap<>(); - this.dataResults.put(this, new ArrayList()); - } for (List results : this.dataResults.values()) { results.add(row); }