Skip to content

Commit

Permalink
replace NonSynchronizedVector with ArrayList - part 2
Browse files Browse the repository at this point in the history
Signed-off-by: Lukas Jungmann <lukas.jungmann@oracle.com>
  • Loading branch information
lukasj committed Feb 27, 2024
1 parent 039ce18 commit c8e02a4
Show file tree
Hide file tree
Showing 86 changed files with 458 additions and 417 deletions.
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, 2024 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 All @@ -19,6 +19,9 @@
import java.io.StringReader;
import java.lang.reflect.Field;
import java.sql.Array;
import java.util.ArrayList;
import java.util.List;

import org.w3c.dom.Document;

//Java extension libraries
Expand All @@ -35,7 +38,6 @@
import org.eclipse.persistence.internal.databaseaccess.Platform;
import org.eclipse.persistence.internal.descriptors.TransformerBasedFieldTransformation;
import org.eclipse.persistence.internal.helper.ConversionManager;
import org.eclipse.persistence.internal.helper.NonSynchronizedVector;
import org.eclipse.persistence.internal.sessions.factories.ObjectPersistenceWorkbenchXMLProject;
import org.eclipse.persistence.internal.xr.ProjectHelper;
import org.eclipse.persistence.internal.xr.XRDynamicClassLoader;
Expand Down Expand Up @@ -291,7 +293,7 @@ public void fromProjectXML() {
Class<?> t1Clz = t1Descriptor.getJavaClass();
((DatabaseSession)session).login();
String[] elements = {"first string", "second string", "third string"};
NonSynchronizedVector<Object> queryArgs = new NonSynchronizedVector<>();
List<Object> queryArgs = new ArrayList<>();
queryArgs.add(elements);
queryArgs.add("barf");
boolean worked = false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,18 +16,16 @@
package dbws.testing.veearray;

// javase imports
import java.util.ArrayList;
import java.util.Collection;

// EclipseLin imports
import org.eclipse.persistence.internal.helper.NonSynchronizedVector;

public class Employee {

public Integer id;
public String firstName;
public String lastName;
@SuppressWarnings({ "rawtypes" })
public Collection phones = new NonSynchronizedVector();
public Collection phones = new ArrayList();

@Override
public String toString() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
import java.io.StringReader;
import java.sql.SQLException;
import java.sql.Types;
import java.util.ArrayList;
import java.util.List;
import java.util.Vector;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
Expand All @@ -44,7 +46,6 @@
//EclipseLink imports
import org.eclipse.persistence.dbws.DBWSModel;
import org.eclipse.persistence.dbws.DBWSModelProject;
import org.eclipse.persistence.internal.helper.NonSynchronizedVector;
import org.eclipse.persistence.internal.xr.Invocation;
import org.eclipse.persistence.internal.xr.Operation;
import org.eclipse.persistence.internal.xr.XRServiceAdapter;
Expand Down Expand Up @@ -529,7 +530,7 @@ public void updateVeeArrayPhones() throws SQLException {
newPhone2.areaCode = "613";
newPhone2.phonenumber = "230-1579";
newPhone2.type = "Home";
Vector newPhones = new NonSynchronizedVector();
List newPhones = new ArrayList();
newPhones.add(newPhone1);
newPhones.add(newPhone2);
invocation.setParameter("Y", newPhones);
Expand Down Expand Up @@ -593,7 +594,7 @@ public void resetVeeArrayPhones() {
newPhone2.areaCode = "613";
newPhone2.phonenumber = "aaa-bbbb";
newPhone2.type = "Home";
Vector newPhones = new NonSynchronizedVector();
List newPhones = new ArrayList();
newPhones.add(newPhone1);
newPhones.add(newPhone2);
invocation.setParameter("Y", newPhones);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import static org.eclipse.persistence.internal.xr.Util.UNDERSCORE_STR;

//javase imports
import java.util.ArrayList;
import java.util.List;
import java.util.Vector;

Expand All @@ -28,7 +29,6 @@
//EclipseLink imports
import org.eclipse.persistence.descriptors.ClassDescriptor;
import org.eclipse.persistence.exceptions.DBWSException;
import org.eclipse.persistence.internal.helper.NonSynchronizedVector;
import org.eclipse.persistence.internal.jpa.JPAQuery;
import org.eclipse.persistence.queries.DatabaseQuery;
import org.eclipse.persistence.sessions.UnitOfWork;
Expand Down Expand Up @@ -128,7 +128,7 @@ public Object invoke(XRServiceAdapter xrService, Invocation invocation) {
// whereas named queries (SQL strings) do not...
List<String> queryArguments = query.getArguments();
int queryArgumentsSize = queryArguments.size();
Vector<Object> executeArguments = new NonSynchronizedVector<>();
List<Object> executeArguments = new ArrayList<>();
for (int i = 0; i < queryArgumentsSize; i++) {
String argName = queryArguments.get(i);
executeArguments.add(invocation.getParameter(argName));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -609,12 +609,11 @@ public static Transformer getTransformer() {
* would be: 'findAll_employeeType' and 'findByPrimaryKey_employeeType'.
*
*/
@SuppressWarnings("rawtypes")
protected static void updateFindQueryNames(Project orProject) {
for (ClassDescriptor orDesc : orProject.getDescriptors().values()) {
Vector queries = orDesc.getQueryManager().getAllQueries();
List<DatabaseQuery> queries = orDesc.getQueryManager().getAllQueries();
for (int i=0; i<queries.size(); i++) {
DatabaseQuery query = (DatabaseQuery) queries.get(i);
DatabaseQuery query = queries.get(i);
String qName = query.getName();
String END_PART = UNDERSCORE_STR + query.getDescriptor().getAlias() + TYPE_STR;
if ((PK_QUERYNAME.equals(qName) || ALL_QUERYNAME.equals(qName)) && !qName.endsWith(END_PART)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,11 +96,10 @@ public void setup() {
this.eventAdaptor = new VPDIsolatedSessionEventAdaptor();
this.server.getEventManager().addListener(this.eventAdaptor);
} catch (RuntimeException ex) {
getSession().logMessage("This test requires that the connected user has privleges to \"Creat any context\", \"Drop any context\" and \"execute Sys.DBMS_RLS package\".");
getSession().logMessage("This test requires that the connected user has privileges to \"Creat any context\", \"Drop any context\" and \"execute Sys.DBMS_RLS package\".");
throw ex;
} catch (java.sql.SQLException se) {
se.printStackTrace();
throw new TestErrorException("There is SQLException");
throw new TestErrorException("There is SQLException", se);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import org.eclipse.persistence.internal.databaseaccess.*;
import org.eclipse.persistence.descriptors.*;
import org.eclipse.persistence.expressions.*;
import org.eclipse.persistence.internal.helper.DatabaseField;
import org.eclipse.persistence.sessions.*;

import org.eclipse.persistence.testing.models.employee.domain.*;
Expand Down Expand Up @@ -57,15 +58,15 @@ public void verify() {
ClassDescriptor descriptor = getSession().getDescriptor(Employee.class);
DescriptorQueryManager descriptorQueryManager = descriptor.getDescriptorQueryManager();
// in the update transaction in test(), the lastName and the version fields are updated
Vector fields = new Vector(2);
List<DatabaseField> fields = new ArrayList<>(2);
fields.add(descriptor.getMappingForAttributeName("lastName").getField());
fields.add(descriptor.getOptimisticLockingPolicy().getWriteLockField());

Vector cachedUpdateCalls = descriptorQueryManager.getCachedUpdateCalls(fields);
List<DatasourceCall> cachedUpdateCalls = descriptorQueryManager.getCachedUpdateCalls(fields);
assertNotNull(cachedUpdateCalls);
assertFalse(cachedUpdateCalls.isEmpty());

for (DatasourceCall call : (Iterable<DatasourceCall>) cachedUpdateCalls) {
for (DatasourceCall call : cachedUpdateCalls) {
// calls should not cache a query
if (call.getQuery() != null) {
throw new TestErrorException("DatasourceCall's query is not null: " + call);
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, 2024 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 All @@ -14,8 +14,9 @@
// Oracle - initial API and implementation from Oracle TopLink
package org.eclipse.persistence.testing.tests.workbenchintegration;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.Vector;
import java.util.List;

import org.eclipse.persistence.descriptors.ClassDescriptor;
import org.eclipse.persistence.queries.DatabaseQuery;
Expand All @@ -30,7 +31,7 @@
* XML files written out the same as they were read in wrt query order.
*/
public class ProjectXMLQueryManagerQueryOrderTest extends AutoVerifyTestCase {
Vector original, current; //list of queries to compare
List<DatabaseQuery> original, current; //list of queries to compare

public ProjectXMLQueryManagerQueryOrderTest() {
}
Expand All @@ -57,20 +58,20 @@ protected void verify() {
throw new TestErrorException("The number of queries read was not equal to the number originally.");
}

Iterator orig = original.iterator();
Iterator curr = current.iterator();
Iterator<DatabaseQuery> orig = original.iterator();
Iterator<DatabaseQuery> curr = current.iterator();
while (orig.hasNext()) {
DatabaseQuery origQuery = (DatabaseQuery)orig.next();
DatabaseQuery origQuery = orig.next();
int argumentTypesSize = 0;
if (origQuery.getArguments() != null) {
argumentTypesSize = origQuery.getArguments().size();
}
Vector argumentTypes = new Vector();
List<String> argumentTypes = new ArrayList<>();
for (int i = 0; i < argumentTypesSize; i++) {
argumentTypes.addElement(origQuery.getArgumentTypeNames().get(i));
argumentTypes.add(origQuery.getArgumentTypeNames().get(i));
}

DatabaseQuery currentQuery = (DatabaseQuery)curr.next();
DatabaseQuery currentQuery = curr.next();
if ((origQuery.getName() != currentQuery.getName()) &&
((origQuery.getName() == null) || !origQuery.getName().equals(currentQuery.getName())))
if (!argumentTypes.equals(currentQuery.getArgumentTypeNames())) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public Object getChild(Object parent, int index) {
return new ExpressionNode(expression.getSecondChild());
}
} else if (parent instanceof FunctionExpression expression) {
return new ExpressionNode(expression.getChildren().elementAt(index));
return new ExpressionNode(expression.getChildren().get(index));
}

return null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -875,9 +875,9 @@ public DatasourceCall buildCallFromStatement(SQLStatement statement, DatabaseQue
/**
* INTERNAL:
* Extract the direct values from the specified field value.
* Return them in a vector.
* Return them in a list.
*/
public Vector buildDirectValuesFromFieldValue(Object fieldValue) throws DatabaseException {
public List<Object> buildDirectValuesFromFieldValue(Object fieldValue) throws DatabaseException {
throw DescriptorException.normalDescriptorsDoNotSupportNonRelationalExtensions(this);
}

Expand Down Expand Up @@ -983,7 +983,7 @@ public AbstractRecord buildNestedRowFromFieldValue(Object fieldValue) throws Dat
* INTERNAL:
* Build and return the nested rows from the specified field value.
*/
public Vector buildNestedRowsFromFieldValue(Object fieldValue, AbstractSession session) throws DatabaseException {
public List<AbstractRecord> buildNestedRowsFromFieldValue(Object fieldValue, AbstractSession session) throws DatabaseException {
throw DescriptorException.normalDescriptorsDoNotSupportNonRelationalExtensions(this);
}

Expand Down

0 comments on commit c8e02a4

Please sign in to comment.