Bug 1245: NullPointerException from BatchFetchPolicy dataResults
Signed-off-by: Will Dazey <dazeydev.3@gmail.com>
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 7e5eef0..5f9eb0e 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 @@
protected transient Map<Object, Object> batchObjects;
public BatchFetchPolicy() {
- this.type = BatchFetchType.JOIN;
+ this(BatchFetchType.JOIN);
}
public BatchFetchPolicy(BatchFetchType type) {
this.type = type;
+ this.dataResults = new HashMap<Object, List<AbstractRecord>>();
+ this.dataResults.put(this, new ArrayList<AbstractRecord>());
}
@Override
@@ -236,10 +238,6 @@
* 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<AbstractRecord>());
- }
for (List<AbstractRecord> results : this.dataResults.values()) {
results.add(row);
}