Skip to content

Commit

Permalink
Revert "Fix eclipse-ee4j#1161: Clone appropriate fields in OneToManyM…
Browse files Browse the repository at this point in the history
…apping.clone(). Fix ConcurrentModificationException. (backport for 2.7) (eclipse-ee4j#1208)"

This reverts commit 474f855.
  • Loading branch information
vrossellotravelc committed Nov 11, 2021
1 parent bb9fb08 commit 090be54
Show file tree
Hide file tree
Showing 5 changed files with 5 additions and 323 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* Copyright (c) 1998, 2021 Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1998, 2021 IBM Corporation. All rights reserved.
* Copyright (c) 1998, 2020 Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1998, 2020 IBM Corporation. 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
Expand Down Expand Up @@ -1369,7 +1369,7 @@ public Object clone() {
clonedDescriptor.setFields(NonSynchronizedVector.newInstance());

// Referencing classes
clonedDescriptor.referencingClasses = new HashSet<>(referencingClasses);
referencingClasses = new HashSet<>();

// Post-calculate changes
if (this.mappingsPostCalculateChanges != null) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 1998, 2021 Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1998, 2018 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
Expand Down Expand Up @@ -309,12 +309,7 @@ public void collectQueryParameters(Set<DatabaseField> cacheFields){
@Override
public Object clone() {
OneToManyMapping clone = (OneToManyMapping)super.clone();

Map<DatabaseField, DatabaseField> old2cloned = new HashMap<>();
clone.sourceKeyFields = cloneDatabaseFieldVector(sourceKeyFields, old2cloned);
clone.targetForeignKeyFields = cloneDatabaseFieldVector(targetForeignKeyFields, old2cloned);
clone.setTargetForeignKeysToSourceKeys(cloneKeysMap(getTargetForeignKeysToSourceKeys(), old2cloned));
clone.sourceKeysToTargetForeignKeys = cloneKeysMap(getSourceKeysToTargetForeignKeys(), old2cloned);
clone.setTargetForeignKeysToSourceKeys(new HashMap(getTargetForeignKeysToSourceKeys()));

if (addTargetQuery != null){
clone.addTargetQuery = (DataModifyQuery) this.addTargetQuery.clone();
Expand All @@ -325,33 +320,6 @@ public Object clone() {
return clone;
}

private Map<DatabaseField, DatabaseField> cloneKeysMap(Map<DatabaseField, DatabaseField> toClone,
Map<DatabaseField, DatabaseField> old2cloned) {
if (toClone == null) {
return null;
}
Map<DatabaseField, DatabaseField> cloneTarget2Src = new HashMap<>(toClone.size());
for (Map.Entry<DatabaseField, DatabaseField> e : toClone.entrySet()) {
cloneTarget2Src.put(old2cloned.get(e.getKey()), old2cloned.get(e.getValue()));
}
return cloneTarget2Src;
}

private Vector<DatabaseField> cloneDatabaseFieldVector(Vector<DatabaseField> oldFlds,
Map<DatabaseField, DatabaseField> old2cloned) {
Vector<DatabaseField> clonedSourceKeyFields = null;
if (oldFlds != null) {
clonedSourceKeyFields =
org.eclipse.persistence.internal.helper.NonSynchronizedVector.newInstance(oldFlds.size());
for (DatabaseField old : oldFlds) {
DatabaseField cf = old.clone();
clonedSourceKeyFields.add(cf);
old2cloned.put(old, cf);
}
}
return clonedSourceKeyFields;
}

/**
* INTERNAL
* Called when a DatabaseMapping is used to map the key in a collection. Returns the key.
Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

0 comments on commit 090be54

Please sign in to comment.