diff --git a/.lgtm.yml b/.lgtm.yml index 2eee7a71669..9d0b5be0288 100644 --- a/.lgtm.yml +++ b/.lgtm.yml @@ -14,6 +14,15 @@ path_classifiers: - "license.html" - "readme.html" +######################################################################################### +# Use the `queries` block to change the default display of query results. # +######################################################################################### + +queries: + - include: "*" + # "by design" - synch is being removed intentionally + - exclude: java/non-sync-override + extraction: java: index: diff --git a/dbws/org.eclipse.persistence.dbws/src/it/java/dbws/testing/keymappings/KeyMappingsTestSuite.java b/dbws/org.eclipse.persistence.dbws/src/it/java/dbws/testing/keymappings/KeyMappingsTestSuite.java index 20cc1621629..6073a76f5a1 100644 --- a/dbws/org.eclipse.persistence.dbws/src/it/java/dbws/testing/keymappings/KeyMappingsTestSuite.java +++ b/dbws/org.eclipse.persistence.dbws/src/it/java/dbws/testing/keymappings/KeyMappingsTestSuite.java @@ -731,7 +731,6 @@ public void getAllEmployees() { comparer.isNodeEqual(controlDoc, doc)); } - @SuppressWarnings("unchecked") @Test public void buildEmployees() { XMLUnmarshaller unMarshaller = xrService.getXMLContext().createUnmarshaller(); diff --git a/dbws/org.eclipse.persistence.dbws/src/it/java/dbws/testing/relationships/RelationshipsEmployee.java b/dbws/org.eclipse.persistence.dbws/src/it/java/dbws/testing/relationships/RelationshipsEmployee.java index f6dbafdd108..df94f95b480 100644 --- a/dbws/org.eclipse.persistence.dbws/src/it/java/dbws/testing/relationships/RelationshipsEmployee.java +++ b/dbws/org.eclipse.persistence.dbws/src/it/java/dbws/testing/relationships/RelationshipsEmployee.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2020 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 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 @@ -33,8 +33,8 @@ public class RelationshipsEmployee { public String gender; public BigDecimal salary; public RelationshipsAddress address; - public Collection phones = new ArrayList(); - public Collection responsibilities = new ArrayList(); + public Collection phones = new ArrayList<>(); + public Collection responsibilities = new ArrayList<>(); public RelationshipsEmployee() { } diff --git a/dbws/org.eclipse.persistence.dbws/src/it/java/dbws/testing/xrdynamicentity/XRDynamicEntityTestSuite.java b/dbws/org.eclipse.persistence.dbws/src/it/java/dbws/testing/xrdynamicentity/XRDynamicEntityTestSuite.java index 1dc8a6858e4..0bd2898628a 100644 --- a/dbws/org.eclipse.persistence.dbws/src/it/java/dbws/testing/xrdynamicentity/XRDynamicEntityTestSuite.java +++ b/dbws/org.eclipse.persistence.dbws/src/it/java/dbws/testing/xrdynamicentity/XRDynamicEntityTestSuite.java @@ -50,7 +50,7 @@ public class XRDynamicEntityTestSuite { @BeforeClass public static void setUp() throws NoSuchFieldException, IllegalArgumentException, IllegalAccessException { - Set propertyNames = new HashSet(); + Set propertyNames = new HashSet<>(); propertyNames.add(FIELD_1); propertyNames.add(FIELD_2); XRCustomer.DPM.setPropertyNames(propertyNames); @@ -95,7 +95,7 @@ public void buildTestEntity() throws ReflectiveOperationException { (Class)xrdcl.createDynamicClass(TEST_CLASSNAME); XRDynamicEntity newInstance = testClass.getConstructor().newInstance(); XRDynamicPropertiesManager xrDPM = newInstance.fetchPropertiesManager(); - Set propertyNames = new HashSet(); + Set propertyNames = new HashSet<>(); propertyNames.add(FIELD_1); propertyNames.add(FIELD_2); xrDPM.setPropertyNames(propertyNames); diff --git a/dbws/org.eclipse.persistence.dbws/src/main/java/org/eclipse/persistence/internal/dbws/ProviderHelper.java b/dbws/org.eclipse.persistence.dbws/src/main/java/org/eclipse/persistence/internal/dbws/ProviderHelper.java index 172bbe39852..29ca2269d2f 100644 --- a/dbws/org.eclipse.persistence.dbws/src/main/java/org/eclipse/persistence/internal/dbws/ProviderHelper.java +++ b/dbws/org.eclipse.persistence.dbws/src/main/java/org/eclipse/persistence/internal/dbws/ProviderHelper.java @@ -183,7 +183,7 @@ protected InputStream initXRServiceStream(ClassLoader parentClassLoader, } protected InputStream initXRSchemaStream(ClassLoader parentClassLoader, ServletContext sc) { - InputStream xrSchemaStream = null; + InputStream xrSchemaStream; String path = WSDL_DIR + DBWS_SCHEMA_XML; if (sc != null) { path = "/" + WEB_INF_DIR + path; @@ -200,7 +200,7 @@ protected InputStream initXRSchemaStream(ClassLoader parentClassLoader, ServletC } protected InputStream initWSDLInputStream(ClassLoader parentClassLoader, ServletContext sc) { - InputStream wsdlInputStream = null; + InputStream wsdlInputStream; String path = WSDL_DIR + DBWS_WSDL; if (sc != null) { path = "/" + WEB_INF_DIR + path; @@ -430,11 +430,11 @@ public SOAPMessage invoke(SOAPMessage request) { if (mtomEnabled) { attachments = (Map)mc.get(INBOUND_MESSAGE_ATTACHMENTS); } - SOAPMessage response = null; - boolean usesSOAP12 = false; + SOAPMessage response; + boolean usesSOAP12; DBWSAdapter dbwsAdapter = (DBWSAdapter)xrService; - SOAPEnvelope envelope = null; + SOAPEnvelope envelope; try { envelope = request.getSOAPPart().getEnvelope(); } @@ -454,15 +454,15 @@ public SOAPMessage invoke(SOAPMessage request) { } if (body == null) { - SOAPFault soapFault = null; + SOAPFault soapFault; try { - SOAPFactory soapFactory = null; + SOAPFactory soapFactory; if (usesSOAP12) { soapFactory = SOAPFactory.newInstance(SOAP_1_2_PROTOCOL); } else { soapFactory = SOAPFactory.newInstance(); } - QName faultCodeQName = null; + QName faultCodeQName; if (usesSOAP12) { faultCodeQName = SENDER_QNAME; } else { @@ -475,7 +475,7 @@ public SOAPMessage invoke(SOAPMessage request) { throw new SOAPFaultException(soapFault); } - XMLRoot xmlRoot = null; + XMLRoot xmlRoot; try { XMLContext xmlContext = dbwsAdapter.getXMLContext(); XMLUnmarshaller unmarshaller = xmlContext.createUnmarshaller(); @@ -529,15 +529,15 @@ public byte[] getAttachmentAsByteArray(String id) { xmlRoot = (XMLRoot)unmarshaller.unmarshal(body, Invocation.class); } catch (Exception e) { - SOAPFault soapFault = null; + SOAPFault soapFault; try { - SOAPFactory soapFactory = null; + SOAPFactory soapFactory; if (usesSOAP12) { soapFactory = SOAPFactory.newInstance(SOAP_1_2_PROTOCOL); } else { soapFactory = SOAPFactory.newInstance(); } - QName faultCodeQName = null; + QName faultCodeQName; if (usesSOAP12) { faultCodeQName = SENDER_QNAME; } else { @@ -606,7 +606,7 @@ public byte[] getAttachmentAsByteArray(String id) { // incoming attachments ? } } - Object result = null; + Object result; try { result = op.invoke(dbwsAdapter, invocation); if (result instanceof ValueObject) { @@ -622,15 +622,15 @@ public byte[] getAttachmentAsByteArray(String id) { response = responseWriter.generateResponse(op, usesSOAP12, e); } catch (SOAPException soape1) { - SOAPFault soapFault = null; + SOAPFault soapFault; try { - SOAPFactory soapFactory = null; + SOAPFactory soapFactory; if (usesSOAP12) { soapFactory = SOAPFactory.newInstance(SOAP_1_2_PROTOCOL); } else { soapFactory = SOAPFactory.newInstance(); } - QName faultCodeQName = null; + QName faultCodeQName; if (usesSOAP12) { faultCodeQName = RECEIVER_QNAME; } else { diff --git a/dbws/org.eclipse.persistence.dbws/src/main/java/org/eclipse/persistence/internal/dbws/SOAPAttachmentHandler.java b/dbws/org.eclipse.persistence.dbws/src/main/java/org/eclipse/persistence/internal/dbws/SOAPAttachmentHandler.java index fc38f0660bb..670f789f7ab 100644 --- a/dbws/org.eclipse.persistence.dbws/src/main/java/org/eclipse/persistence/internal/dbws/SOAPAttachmentHandler.java +++ b/dbws/org.eclipse.persistence.dbws/src/main/java/org/eclipse/persistence/internal/dbws/SOAPAttachmentHandler.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2020 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 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 @@ -37,7 +37,7 @@ public class SOAPAttachmentHandler implements XMLAttachmentMarshaller { private int count = 0; - private HashMap attachments = new HashMap(); + private HashMap attachments = new HashMap<>(); public boolean hasAttachments() { return attachments.size() > 0; diff --git a/dbws/org.eclipse.persistence.dbws/src/main/java/org/eclipse/persistence/internal/dbws/SOAPResponseWriter.java b/dbws/org.eclipse.persistence.dbws/src/main/java/org/eclipse/persistence/internal/dbws/SOAPResponseWriter.java index 361c4e13b40..4b237f8b2d3 100644 --- a/dbws/org.eclipse.persistence.dbws/src/main/java/org/eclipse/persistence/internal/dbws/SOAPResponseWriter.java +++ b/dbws/org.eclipse.persistence.dbws/src/main/java/org/eclipse/persistence/internal/dbws/SOAPResponseWriter.java @@ -58,7 +58,7 @@ public class SOAPResponseWriter { protected DBWSAdapter dbwsAdapter; - protected Map resultDescriptors = new HashMap(); + protected Map resultDescriptors = new HashMap<>(); public static final QName RECEIVER_QNAME = new QName(URI_NS_SOAP_1_2_ENVELOPE, "Receiver"); public static final QName SERVER_QNAME = new QName(URI_NS_SOAP_1_1_ENVELOPE, "Server"); diff --git a/dbws/org.eclipse.persistence.dbws/src/main/java/org/eclipse/persistence/internal/jpa/rs/metadata/model/Descriptor.java b/dbws/org.eclipse.persistence.dbws/src/main/java/org/eclipse/persistence/internal/jpa/rs/metadata/model/Descriptor.java index 74480af8041..a0c3d6fd594 100644 --- a/dbws/org.eclipse.persistence.dbws/src/main/java/org/eclipse/persistence/internal/jpa/rs/metadata/model/Descriptor.java +++ b/dbws/org.eclipse.persistence.dbws/src/main/java/org/eclipse/persistence/internal/jpa/rs/metadata/model/Descriptor.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2020 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 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 @@ -26,9 +26,9 @@ public class Descriptor { protected String name = null; protected String type = null; - protected List linkTemplates = new ArrayList(); - protected List attributes = new ArrayList(); - protected List queries = new ArrayList(); + protected List linkTemplates = new ArrayList<>(); + protected List attributes = new ArrayList<>(); + protected List queries = new ArrayList<>(); public String getName() { return name; diff --git a/dbws/org.eclipse.persistence.dbws/src/main/java/org/eclipse/persistence/internal/jpa/rs/metadata/model/ItemLinks.java b/dbws/org.eclipse.persistence.dbws/src/main/java/org/eclipse/persistence/internal/jpa/rs/metadata/model/ItemLinks.java index 718e39d69e2..6218c44b356 100644 --- a/dbws/org.eclipse.persistence.dbws/src/main/java/org/eclipse/persistence/internal/jpa/rs/metadata/model/ItemLinks.java +++ b/dbws/org.eclipse.persistence.dbws/src/main/java/org/eclipse/persistence/internal/jpa/rs/metadata/model/ItemLinks.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2019 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 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 @@ -43,7 +43,7 @@ public List getLinks() { */ public void setLinks(List links) { if (this.links == null) { - this.links = new ArrayList(); + this.links = new ArrayList<>(); } this.links = links; @@ -56,7 +56,7 @@ public void setLinks(List links) { */ public void addLink(LinkV2 link) { if (this.links == null) { - this.links = new ArrayList(); + this.links = new ArrayList<>(); } this.links.add(link); diff --git a/dbws/org.eclipse.persistence.dbws/src/main/java/org/eclipse/persistence/internal/jpa/rs/metadata/model/PersistenceUnit.java b/dbws/org.eclipse.persistence.dbws/src/main/java/org/eclipse/persistence/internal/jpa/rs/metadata/model/PersistenceUnit.java index e4b241a263b..19e7be332ea 100644 --- a/dbws/org.eclipse.persistence.dbws/src/main/java/org/eclipse/persistence/internal/jpa/rs/metadata/model/PersistenceUnit.java +++ b/dbws/org.eclipse.persistence.dbws/src/main/java/org/eclipse/persistence/internal/jpa/rs/metadata/model/PersistenceUnit.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2020 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 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 @@ -25,7 +25,7 @@ public class PersistenceUnit { protected String persistenceUnitName = null; - protected List types = new ArrayList(); + protected List types = new ArrayList<>(); public String getPersistenceUnitName() { return persistenceUnitName; diff --git a/dbws/org.eclipse.persistence.dbws/src/main/java/org/eclipse/persistence/internal/jpa/rs/metadata/model/Query.java b/dbws/org.eclipse.persistence.dbws/src/main/java/org/eclipse/persistence/internal/jpa/rs/metadata/model/Query.java index 3e6f1952763..df03b205ab8 100644 --- a/dbws/org.eclipse.persistence.dbws/src/main/java/org/eclipse/persistence/internal/jpa/rs/metadata/model/Query.java +++ b/dbws/org.eclipse.persistence.dbws/src/main/java/org/eclipse/persistence/internal/jpa/rs/metadata/model/Query.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2020 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 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 @@ -26,7 +26,7 @@ public class Query { protected String queryName; protected String jpql; protected LinkTemplate linkTemplate; - protected List returnTypes = new ArrayList(); + protected List returnTypes = new ArrayList<>(); public Query() { } diff --git a/dbws/org.eclipse.persistence.dbws/src/main/java/org/eclipse/persistence/internal/jpa/rs/metadata/model/SessionBeanCall.java b/dbws/org.eclipse.persistence.dbws/src/main/java/org/eclipse/persistence/internal/jpa/rs/metadata/model/SessionBeanCall.java index 17ebba5552a..5683ddbad5c 100644 --- a/dbws/org.eclipse.persistence.dbws/src/main/java/org/eclipse/persistence/internal/jpa/rs/metadata/model/SessionBeanCall.java +++ b/dbws/org.eclipse.persistence.dbws/src/main/java/org/eclipse/persistence/internal/jpa/rs/metadata/model/SessionBeanCall.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2020 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 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 @@ -27,7 +27,7 @@ public class SessionBeanCall { private String jndiName = null; private String methodName = null; private String context = null; - private List parameters = new ArrayList(); + private List parameters = new ArrayList<>(); public String getContext() { return context; diff --git a/dbws/org.eclipse.persistence.dbws/src/main/java/org/eclipse/persistence/internal/jpa/rs/metadata/model/v2/ContextsCatalog.java b/dbws/org.eclipse.persistence.dbws/src/main/java/org/eclipse/persistence/internal/jpa/rs/metadata/model/v2/ContextsCatalog.java index f6c75b7438e..e08220cbe54 100644 --- a/dbws/org.eclipse.persistence.dbws/src/main/java/org/eclipse/persistence/internal/jpa/rs/metadata/model/v2/ContextsCatalog.java +++ b/dbws/org.eclipse.persistence.dbws/src/main/java/org/eclipse/persistence/internal/jpa/rs/metadata/model/v2/ContextsCatalog.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, 2020 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 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 @@ -45,7 +45,7 @@ public void setItems(List items) { */ public void addContext(Resource context) { if (items == null) { - items = new ArrayList(); + items = new ArrayList<>(); } items.add(context); } diff --git a/dbws/org.eclipse.persistence.dbws/src/main/java/org/eclipse/persistence/internal/jpa/rs/metadata/model/v2/MetadataCatalog.java b/dbws/org.eclipse.persistence.dbws/src/main/java/org/eclipse/persistence/internal/jpa/rs/metadata/model/v2/MetadataCatalog.java index 41a43dd142d..ae1b97d6de6 100644 --- a/dbws/org.eclipse.persistence.dbws/src/main/java/org/eclipse/persistence/internal/jpa/rs/metadata/model/v2/MetadataCatalog.java +++ b/dbws/org.eclipse.persistence.dbws/src/main/java/org/eclipse/persistence/internal/jpa/rs/metadata/model/v2/MetadataCatalog.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, 2020 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 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 @@ -54,7 +54,7 @@ public void setLinks(List links) { public void addResource(Resource resource) { if (items == null) { - items = new ArrayList(); + items = new ArrayList<>(); } items.add(resource); } diff --git a/dbws/org.eclipse.persistence.dbws/src/main/java/org/eclipse/persistence/internal/jpa/rs/metadata/model/v2/ResourceSchema.java b/dbws/org.eclipse.persistence.dbws/src/main/java/org/eclipse/persistence/internal/jpa/rs/metadata/model/v2/ResourceSchema.java index e4ebe995d84..ea427d277a4 100644 --- a/dbws/org.eclipse.persistence.dbws/src/main/java/org/eclipse/persistence/internal/jpa/rs/metadata/model/v2/ResourceSchema.java +++ b/dbws/org.eclipse.persistence.dbws/src/main/java/org/eclipse/persistence/internal/jpa/rs/metadata/model/v2/ResourceSchema.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, 2020 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 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 @@ -108,23 +108,23 @@ public void setLinks(List links) { public void addProperty(String name, Property property) { if (properties == null) { - properties = new ArrayList(); + properties = new ArrayList<>(); } - properties.add(new JAXBElement(new QName(name), Property.class, property)); + properties.add(new JAXBElement<>(new QName(name), Property.class, property)); } public void addDefinition(String name, ResourceSchema definition) { // Lazy initialization if (definitions == null) { - definitions = new ArrayList(1); + definitions = new ArrayList<>(1); } - definitions.add(new JAXBElement(new QName(name), ResourceSchema.class, definition)); + definitions.add(new JAXBElement<>(new QName(name), ResourceSchema.class, definition)); } public void addAllOf(Reference reference) { // Lazy initialization if (allOf == null) { - allOf = new ArrayList(1); + allOf = new ArrayList<>(1); } allOf.add(reference); } diff --git a/dbws/org.eclipse.persistence.dbws/src/main/java/org/eclipse/persistence/internal/xr/DeleteOperation.java b/dbws/org.eclipse.persistence.dbws/src/main/java/org/eclipse/persistence/internal/xr/DeleteOperation.java index a0af2ceb161..15b24293871 100644 --- a/dbws/org.eclipse.persistence.dbws/src/main/java/org/eclipse/persistence/internal/xr/DeleteOperation.java +++ b/dbws/org.eclipse.persistence.dbws/src/main/java/org/eclipse/persistence/internal/xr/DeleteOperation.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2019 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 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 @@ -40,7 +40,6 @@ * @author Mike Norman - michael.norman@oracle.com * @since EclipseLink 1.x */ -@SuppressWarnings({"unchecked"}) public class DeleteOperation extends Operation { protected String descriptorName; protected ClassDescriptor classDescriptor; @@ -127,11 +126,11 @@ public Object invoke(XRServiceAdapter xrService, Invocation invocation) { // set query args or execute args for the non-JPAQuery case, // i.e. stored proc/funcs get populated from ORM metadata // whereas named queries (SQL strings) do not... - List queryArguments = query.getArguments(); + List queryArguments = query.getArguments(); int queryArgumentsSize = queryArguments.size(); - Vector executeArguments = new NonSynchronizedVector(); + Vector executeArguments = new NonSynchronizedVector<>(); for (int i = 0; i < queryArgumentsSize; i++) { - String argName = (String)queryArguments.get(i); + String argName = queryArguments.get(i); executeArguments.add(invocation.getParameter(argName)); } toBeDeleted = uow.executeQuery(query, executeArguments); diff --git a/dbws/org.eclipse.persistence.dbws/src/main/java/org/eclipse/persistence/internal/xr/Invocation.java b/dbws/org.eclipse.persistence.dbws/src/main/java/org/eclipse/persistence/internal/xr/Invocation.java index 8f70d87ae39..440b6508cb0 100644 --- a/dbws/org.eclipse.persistence.dbws/src/main/java/org/eclipse/persistence/internal/xr/Invocation.java +++ b/dbws/org.eclipse.persistence.dbws/src/main/java/org/eclipse/persistence/internal/xr/Invocation.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2020 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 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 @@ -34,7 +34,7 @@ public class Invocation { protected String name; - protected Map parameters = new HashMap(); + protected Map parameters = new HashMap<>(); public Invocation() { super(); diff --git a/dbws/org.eclipse.persistence.dbws/src/main/java/org/eclipse/persistence/internal/xr/Operation.java b/dbws/org.eclipse.persistence.dbws/src/main/java/org/eclipse/persistence/internal/xr/Operation.java index f4911de7197..ccb42a7e5fa 100644 --- a/dbws/org.eclipse.persistence.dbws/src/main/java/org/eclipse/persistence/internal/xr/Operation.java +++ b/dbws/org.eclipse.persistence.dbws/src/main/java/org/eclipse/persistence/internal/xr/Operation.java @@ -35,7 +35,7 @@ public abstract class Operation { protected String name; - protected List parameters = new ArrayList(); + protected List parameters = new ArrayList<>(); /** *

INTERNAL: diff --git a/dbws/org.eclipse.persistence.dbws/src/main/java/org/eclipse/persistence/internal/xr/ProjectHelper.java b/dbws/org.eclipse.persistence.dbws/src/main/java/org/eclipse/persistence/internal/xr/ProjectHelper.java index baa812eb9ae..2ebf6a1cb18 100644 --- a/dbws/org.eclipse.persistence.dbws/src/main/java/org/eclipse/persistence/internal/xr/ProjectHelper.java +++ b/dbws/org.eclipse.persistence.dbws/src/main/java/org/eclipse/persistence/internal/xr/ProjectHelper.java @@ -69,7 +69,7 @@ public static void fixOROXAccessors(Project orProject, Project oxProject) { e.printStackTrace(); } } - Set propertiesNameSet = new HashSet(); + Set propertiesNameSet = new HashSet<>(); for (Iterator j = desc.getMappings().iterator(); j.hasNext();) { DatabaseMapping dm = (DatabaseMapping)j.next(); String attributeName = dm.getAttributeName(); diff --git a/dbws/org.eclipse.persistence.dbws/src/main/java/org/eclipse/persistence/internal/xr/QNameTransformer.java b/dbws/org.eclipse.persistence.dbws/src/main/java/org/eclipse/persistence/internal/xr/QNameTransformer.java index d40acd7a585..7f02ee869f0 100644 --- a/dbws/org.eclipse.persistence.dbws/src/main/java/org/eclipse/persistence/internal/xr/QNameTransformer.java +++ b/dbws/org.eclipse.persistence.dbws/src/main/java/org/eclipse/persistence/internal/xr/QNameTransformer.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2020 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 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 @@ -85,7 +85,7 @@ public class QNameTransformer implements AttributeTransformer, FieldTransformer public static final Map SCHEMA_QNAMES; static { - SCHEMA_QNAMES = Collections.unmodifiableMap(new HashMap() { + SCHEMA_QNAMES = Collections.unmodifiableMap(new HashMap<>() { { put(ANY, ANY_QNAME); put(ANY_SIMPLE_TYPE, ANY_SIMPLE_TYPE_QNAME); diff --git a/dbws/org.eclipse.persistence.dbws/src/main/java/org/eclipse/persistence/internal/xr/QueryOperation.java b/dbws/org.eclipse.persistence.dbws/src/main/java/org/eclipse/persistence/internal/xr/QueryOperation.java index db03b34b71d..3f6f556a2d6 100644 --- a/dbws/org.eclipse.persistence.dbws/src/main/java/org/eclipse/persistence/internal/xr/QueryOperation.java +++ b/dbws/org.eclipse.persistence.dbws/src/main/java/org/eclipse/persistence/internal/xr/QueryOperation.java @@ -203,7 +203,7 @@ public void validate(XRServiceAdapter xrService) { // Made static final for performance reasons. private static final class DataHandlerInstantiationPolicy extends InstantiationPolicy { - protected String mimeType; + private String mimeType; public DataHandlerInstantiationPolicy(String mimeType) { super(); this.mimeType = mimeType; @@ -418,7 +418,7 @@ public Object invoke(XRServiceAdapter xrService, Invocation invocation) { if (returnedList.size() > 0 && returnedList.get(0) instanceof Object[]) { Object[] objs = (Object[]) returnedList.get(0); if (isCollection()) { - value = new ArrayList(); + value = new ArrayList<>(); for (Object obj : objs) { ((ArrayList) value).add(obj); } @@ -547,7 +547,7 @@ public Object createSimpleXMLFormat(XRServiceAdapter xrService, Object value) { // assumes JPAQuery JPAQuery jpaQuery = (JPAQuery) queryHandler.getDatabaseQuery(); // to match field names with results, we need to gather the database fields from each of the Output parameters - List paramFlds = new ArrayList(); + List paramFlds = new ArrayList<>(); DatasourceCall dsCall = (DatasourceCall) jpaQuery.getDatabaseQuery().getDatasourceCall(); for (Object obj : dsCall.getParameters()) { if (obj instanceof OutputParameterForCallableStatement) { @@ -571,20 +571,20 @@ public Object createSimpleXMLFormat(XRServiceAdapter xrService, Object value) { } else { dr.add(new DatabaseField(RESULT_STR), ((ArrayList) value).get(0)); } - records = new Vector(); + records = new Vector<>(); records.add(dr); } else if (value instanceof Vector) { Class vectorContent = ((Vector)value).firstElement().getClass(); if (DatabaseRecord.class.isAssignableFrom(vectorContent)) { records = (Vector)value; } else { - records = new Vector(); + records = new Vector<>(); DatabaseRecord dr = new DatabaseRecord(); dr.add(new DatabaseField(RESULT_STR), ((Vector)value).firstElement()); records.add(dr); } } else { - records = new Vector(); + records = new Vector<>(); DatabaseRecord dr = new DatabaseRecord(); dr.add(new DatabaseField(RESULT_STR), value); records.add(dr); @@ -655,8 +655,6 @@ public Object createSimpleXMLFormat(XRServiceAdapter xrService, Object value) { getStringMethod = PrivilegedAccessHelper.getDeclaredMethod(xmlTypeFactoryClass, GETSTRING_METHOD, new Class[] {oracleOPAQUE}); fieldValue = PrivilegedAccessHelper.invokeMethod(getStringMethod, xmlTypeFactory, new Object[] {fieldValue}); } - } catch (RuntimeException x) { - throw x; } catch (ReflectiveOperationException | PrivilegedActionException e) { // if the required resources are not available there's nothing we can do... log.logThrowable(SessionLog.FINE, SessionLog.DBWS, e); diff --git a/dbws/org.eclipse.persistence.dbws/src/main/java/org/eclipse/persistence/internal/xr/StoredProcedureQueryHandler.java b/dbws/org.eclipse.persistence.dbws/src/main/java/org/eclipse/persistence/internal/xr/StoredProcedureQueryHandler.java index 139f22cf5af..f8df6d5943e 100644 --- a/dbws/org.eclipse.persistence.dbws/src/main/java/org/eclipse/persistence/internal/xr/StoredProcedureQueryHandler.java +++ b/dbws/org.eclipse.persistence.dbws/src/main/java/org/eclipse/persistence/internal/xr/StoredProcedureQueryHandler.java @@ -49,9 +49,9 @@ public class StoredProcedureQueryHandler extends QueryHandler { public static final String CURSOR_STR = "CURSOR"; protected String name; - protected List inArguments = new ArrayList(); - protected List inOutArguments = new ArrayList(); - protected List outArguments = new ArrayList(); + protected List inArguments = new ArrayList<>(); + protected List inOutArguments = new ArrayList<>(); + protected List outArguments = new ArrayList<>(); public String getName() { return name; diff --git a/dbws/org.eclipse.persistence.dbws/src/main/java/org/eclipse/persistence/internal/xr/Util.java b/dbws/org.eclipse.persistence.dbws/src/main/java/org/eclipse/persistence/internal/xr/Util.java index a054da292ca..994285687bc 100644 --- a/dbws/org.eclipse.persistence.dbws/src/main/java/org/eclipse/persistence/internal/xr/Util.java +++ b/dbws/org.eclipse.persistence.dbws/src/main/java/org/eclipse/persistence/internal/xr/Util.java @@ -444,36 +444,36 @@ public static Class getClassFromJDBCType(String typeName, DatabasePlatform da public static final Map> SCHEMA_2_CLASS; static { SCHEMA_2_CLASS = Collections.unmodifiableMap(new HashMap>() {{ - put(ANY_SIMPLE_TYPE_QNAME,CoreClassConstants.OBJECT); - put(BASE_64_BINARY_QNAME, APBYTE); - put(BOOLEAN_QNAME, BOOLEAN); - put(BYTE_QNAME, BYTE); - //put(DATE_QNAME, SQLDATE); - put(DATE_QNAME, CALENDAR); - //put(DATE_TIME_QNAME, TIMESTAMP); - put(DATE_TIME_QNAME, CALENDAR); - put(DECIMAL_QNAME, BIGDECIMAL); - put(DOUBLE_QNAME, DOUBLE); - put(DURATION_QNAME, STRING); - put(FLOAT_QNAME, FLOAT); - put(G_YEAR_MONTH_QNAME, STRING); - put(G_YEAR_QNAME, STRING); - put(G_MONTH_QNAME, STRING); - put(G_MONTH_DAY_QNAME, STRING); - put(G_DAY_QNAME, STRING); - put(HEX_BINARY_QNAME, APBYTE); - put(INT_QNAME, INTEGER); - put(INTEGER_QNAME, BIGINTEGER); - put(LONG_QNAME, LONG); - put(QNAME_QNAME, QName.class); - put(SHORT_QNAME, SHORT); - put(STRING_QNAME, STRING); - //put(TIME_QNAME, TIME); - put(TIME_QNAME, CALENDAR); - put(UNSIGNED_BYTE_QNAME, SHORT); - put(UNSIGNED_INT_QNAME, LONG); - put(UNSIGNED_SHORT_QNAME, INTEGER); - }}); + put(ANY_SIMPLE_TYPE_QNAME, CoreClassConstants.OBJECT); + put(BASE_64_BINARY_QNAME, APBYTE); + put(BOOLEAN_QNAME, BOOLEAN); + put(BYTE_QNAME, BYTE); + //put(DATE_QNAME, SQLDATE); + put(DATE_QNAME, CALENDAR); + //put(DATE_TIME_QNAME, TIMESTAMP); + put(DATE_TIME_QNAME, CALENDAR); + put(DECIMAL_QNAME, BIGDECIMAL); + put(DOUBLE_QNAME, DOUBLE); + put(DURATION_QNAME, STRING); + put(FLOAT_QNAME, FLOAT); + put(G_YEAR_MONTH_QNAME, STRING); + put(G_YEAR_QNAME, STRING); + put(G_MONTH_QNAME, STRING); + put(G_MONTH_DAY_QNAME, STRING); + put(G_DAY_QNAME, STRING); + put(HEX_BINARY_QNAME, APBYTE); + put(INT_QNAME, INTEGER); + put(INTEGER_QNAME, BIGINTEGER); + put(LONG_QNAME, LONG); + put(QNAME_QNAME, QName.class); + put(SHORT_QNAME, SHORT); + put(STRING_QNAME, STRING); + //put(TIME_QNAME, TIME); + put(TIME_QNAME, CALENDAR); + put(UNSIGNED_BYTE_QNAME, SHORT); + put(UNSIGNED_INT_QNAME, LONG); + put(UNSIGNED_SHORT_QNAME, INTEGER); + }}); } /** diff --git a/dbws/org.eclipse.persistence.dbws/src/main/java/org/eclipse/persistence/internal/xr/XRDynamicEntity_CollectionWrapper.java b/dbws/org.eclipse.persistence.dbws/src/main/java/org/eclipse/persistence/internal/xr/XRDynamicEntity_CollectionWrapper.java index 248034b0f9b..164cbd88e00 100644 --- a/dbws/org.eclipse.persistence.dbws/src/main/java/org/eclipse/persistence/internal/xr/XRDynamicEntity_CollectionWrapper.java +++ b/dbws/org.eclipse.persistence.dbws/src/main/java/org/eclipse/persistence/internal/xr/XRDynamicEntity_CollectionWrapper.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2020 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 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 @@ -28,14 +28,14 @@ public class XRDynamicEntity_CollectionWrapper extends XRDynamicEntity implement static final String ITEMS_PROPERTY = "items"; public static final XRDynamicPropertiesManager DPM = new XRDynamicPropertiesManager(); static { - Set propertiesNameSet = new HashSet(); + Set propertiesNameSet = new HashSet<>(); propertiesNameSet.add(ITEMS_PROPERTY); DPM.setPropertyNames(propertiesNameSet); } public XRDynamicEntity_CollectionWrapper() { super(); - super.set(ITEMS_PROPERTY, new ArrayList()); + super.set(ITEMS_PROPERTY, new ArrayList<>()); } @Override diff --git a/dbws/org.eclipse.persistence.dbws/src/main/java/org/eclipse/persistence/internal/xr/XRDynamicPropertiesManager.java b/dbws/org.eclipse.persistence.dbws/src/main/java/org/eclipse/persistence/internal/xr/XRDynamicPropertiesManager.java index 610025430f4..329fb1406b5 100644 --- a/dbws/org.eclipse.persistence.dbws/src/main/java/org/eclipse/persistence/internal/xr/XRDynamicPropertiesManager.java +++ b/dbws/org.eclipse.persistence.dbws/src/main/java/org/eclipse/persistence/internal/xr/XRDynamicPropertiesManager.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2020 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 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 @@ -57,7 +57,7 @@ public boolean contains(String propertyName) { @Override public List getPropertyNames() { - List tmp = new ArrayList(); + List tmp = new ArrayList<>(); if (propertyNames != null) { for (String propertyName : propertyNames) { tmp.add(propertyName); diff --git a/dbws/org.eclipse.persistence.dbws/src/main/java/org/eclipse/persistence/internal/xr/XRFieldInfo.java b/dbws/org.eclipse.persistence.dbws/src/main/java/org/eclipse/persistence/internal/xr/XRFieldInfo.java index ad1ba8b0f32..84155eb26e4 100644 --- a/dbws/org.eclipse.persistence.dbws/src/main/java/org/eclipse/persistence/internal/xr/XRFieldInfo.java +++ b/dbws/org.eclipse.persistence.dbws/src/main/java/org/eclipse/persistence/internal/xr/XRFieldInfo.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2020 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 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 @@ -21,7 +21,7 @@ public class XRFieldInfo { - protected HashMap fieldInfo = new HashMap(); + protected HashMap fieldInfo = new HashMap<>(); public XRFieldInfo() { super(); diff --git a/dbws/org.eclipse.persistence.dbws/src/main/java/org/eclipse/persistence/internal/xr/XRServiceAdapter.java b/dbws/org.eclipse.persistence.dbws/src/main/java/org/eclipse/persistence/internal/xr/XRServiceAdapter.java index 9e93e87cdfd..4ec6598d202 100644 --- a/dbws/org.eclipse.persistence.dbws/src/main/java/org/eclipse/persistence/internal/xr/XRServiceAdapter.java +++ b/dbws/org.eclipse.persistence.dbws/src/main/java/org/eclipse/persistence/internal/xr/XRServiceAdapter.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2020 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 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 @@ -41,7 +41,7 @@ public class XRServiceAdapter extends XRServiceModel { protected Session oxSession; protected XMLContext xmlContext; protected Schema schema; - protected Map descriptorsByQName = new HashMap(); + protected Map descriptorsByQName = new HashMap<>(); public Session getORSession() { return orSession; diff --git a/dbws/org.eclipse.persistence.dbws/src/main/java/org/eclipse/persistence/internal/xr/XRServiceFactory.java b/dbws/org.eclipse.persistence.dbws/src/main/java/org/eclipse/persistence/internal/xr/XRServiceFactory.java index 6d3b7c71f3b..ec8c1ea543a 100644 --- a/dbws/org.eclipse.persistence.dbws/src/main/java/org/eclipse/persistence/internal/xr/XRServiceFactory.java +++ b/dbws/org.eclipse.persistence.dbws/src/main/java/org/eclipse/persistence/internal/xr/XRServiceFactory.java @@ -270,7 +270,7 @@ public void loadXMLSchema(InputStream xrSchemaStream) { */ protected Project loadORMetadata(final XRDynamicClassLoader xrdecl, final ServerSession session) { Project orProject = null; - String searchPath = null; + String searchPath; InputStream inStream = null; // try "META-INF/" and "/META-INF/" @@ -309,7 +309,7 @@ protected Project loadORMetadata(final XRDynamicClassLoader xrdecl, final Server protected Project loadOXMetadata(final ClassLoader xrdecl, final Session session) { Project oxProject = null; InputStream inStream = null; - String searchPath = null; + String searchPath; // try "META-INF/" and "/META-INF/" for (String prefix : META_INF_PATHS) { @@ -329,7 +329,7 @@ protected Project loadOXMetadata(final ClassLoader xrdecl, final Session session JAXBElement jaxbElt = unmarshaller.unmarshal(xml, XmlBindingsModel.class); XmlBindingsModel model = jaxbElt.getValue(); if (model.getBindingsList() != null) { - metadataMap = new HashMap(); + metadataMap = new HashMap<>(); for (XmlBindings xmlBindings : model.getBindingsList()) { metadataMap.put(xmlBindings.getPackageName(), new OXMMetadataSource(xmlBindings)); } @@ -342,7 +342,7 @@ protected Project loadOXMetadata(final ClassLoader xrdecl, final Session session } if (metadataMap != null) { - Map> properties = new HashMap>(); + Map> properties = new HashMap<>(); properties.put(JAXBContextProperties.OXM_METADATA_SOURCE, metadataMap); try { DynamicJAXBContext jCtx = DynamicJAXBContextFactory.createContextFromOXM(xrdecl, properties); @@ -458,7 +458,7 @@ public void buildSessions() { xrService.oxSession = (Session) sessions.get(oxSessionKey); // load OX project via xml-bindings - Project oxProject = null; + Project oxProject; if ((oxProject = loadOXMetadata(projectLoader, xrService.oxSession)) == null) { // at this point we may have a legacy deployment XML project, or none set oxProject = xrService.oxSession.getProject(); @@ -472,7 +472,7 @@ public void buildSessions() { ((XMLLogin) oxProject.getDatasourceLogin()).setEqualNamespaceResolvers(false); // load OR project via entity-mappings - Project orProject = null; + Project orProject; if ((orProject = loadORMetadata(projectLoader, (ServerSession) xrService.orSession)) == null) { // at this point we may have a legacy deployment XML project, or none set orProject = xrService.orSession.getProject(); @@ -497,9 +497,8 @@ public void loginSessions() { /** *

INTERNAL: */ - @SuppressWarnings("rawtypes") public void buildDescriptorIndex() { - for (Iterator i = xrService.oxSession.getProject().getOrderedDescriptors().iterator(); + for (Iterator i = xrService.oxSession.getProject().getOrderedDescriptors().iterator(); i.hasNext();) { XMLDescriptor xd = (XMLDescriptor)i.next(); XMLSchemaReference schemaReference = xd.getSchemaReference(); @@ -703,13 +702,13 @@ public XRPersistenceUnitInfo(XRDynamicClassLoader loader) { @Override public ClassLoader getNewTempClassLoader() { return xrdecl; } @Override - public List getMappingFileNames() { return new ArrayList(); } + public List getMappingFileNames() { return new ArrayList<>(); } @Override - public List getManagedClassNames() { return new ArrayList(); } + public List getManagedClassNames() { return new ArrayList<>(); } @Override public DataSource getJtaDataSource() { return null; } @Override - public List getJarFileUrls() { return new ArrayList(); } + public List getJarFileUrls() { return new ArrayList<>(); } @Override public ClassLoader getClassLoader() { return xrdecl; } @Override diff --git a/dbws/org.eclipse.persistence.dbws/src/main/java/org/eclipse/persistence/internal/xr/XRServiceModel.java b/dbws/org.eclipse.persistence.dbws/src/main/java/org/eclipse/persistence/internal/xr/XRServiceModel.java index df9fc034de6..c04c0cc1e52 100644 --- a/dbws/org.eclipse.persistence.dbws/src/main/java/org/eclipse/persistence/internal/xr/XRServiceModel.java +++ b/dbws/org.eclipse.persistence.dbws/src/main/java/org/eclipse/persistence/internal/xr/XRServiceModel.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2020 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 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 @@ -33,7 +33,7 @@ public class XRServiceModel { protected String name; - protected Map operations = new HashMap(); + protected Map operations = new HashMap<>(); protected String sessionsFile; public String getName() { diff --git a/dbws/org.eclipse.persistence.dbws/src/main/java/org/eclipse/persistence/internal/xr/sxf/SimpleXMLFormatModel.java b/dbws/org.eclipse.persistence.dbws/src/main/java/org/eclipse/persistence/internal/xr/sxf/SimpleXMLFormatModel.java index 634605de52a..12a47edba7e 100644 --- a/dbws/org.eclipse.persistence.dbws/src/main/java/org/eclipse/persistence/internal/xr/sxf/SimpleXMLFormatModel.java +++ b/dbws/org.eclipse.persistence.dbws/src/main/java/org/eclipse/persistence/internal/xr/sxf/SimpleXMLFormatModel.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2020 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 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 @@ -29,7 +29,7 @@ public class SimpleXMLFormatModel { public SimpleXMLFormatModel() { super(); - simpleXML = new ArrayList(); + simpleXML = new ArrayList<>(); } } diff --git a/dbws/org.eclipse.persistence.dbws/src/main/java/org/eclipse/persistence/jpa/rs/DataStorage.java b/dbws/org.eclipse.persistence.dbws/src/main/java/org/eclipse/persistence/jpa/rs/DataStorage.java index be5ac7d413c..96a5cce5e3c 100644 --- a/dbws/org.eclipse.persistence.dbws/src/main/java/org/eclipse/persistence/jpa/rs/DataStorage.java +++ b/dbws/org.eclipse.persistence.dbws/src/main/java/org/eclipse/persistence/jpa/rs/DataStorage.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2020 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 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 @@ -15,15 +15,16 @@ package org.eclipse.persistence.jpa.rs; import java.util.HashMap; +import java.util.Map; public class DataStorage { // key names in the data storage public static final String REQUEST_ID = "requestId"; - private final static InheritableThreadLocal> storage = new InheritableThreadLocal>() { + private final static InheritableThreadLocal> storage = new InheritableThreadLocal>() { @Override - protected HashMap initialValue() { - return new HashMap(); + protected Map initialValue() { + return new HashMap<>(); } }; diff --git a/dbws/org.eclipse.persistence.dbws/src/main/java/org/eclipse/persistence/jpa/rs/PersistenceContext.java b/dbws/org.eclipse.persistence.dbws/src/main/java/org/eclipse/persistence/jpa/rs/PersistenceContext.java index 99e122119c0..7cd495936cf 100644 --- a/dbws/org.eclipse.persistence.dbws/src/main/java/org/eclipse/persistence/jpa/rs/PersistenceContext.java +++ b/dbws/org.eclipse.persistence.dbws/src/main/java/org/eclipse/persistence/jpa/rs/PersistenceContext.java @@ -218,12 +218,9 @@ private void init(String emfName, EntityManagerFactoryImpl emf, URI defaultURI, try { this.jaxbContext = createDynamicJAXBContext(emf.getDatabaseSession()); - } catch (JAXBException jaxbe) { + } catch (JAXBException | IOException jaxbe) { JPARSLogger.exception(getSessionLog(), "exception_creating_jaxb_context", new Object[] { emfName, jaxbe.toString() }, jaxbe); emf.close(); - } catch (IOException e) { - JPARSLogger.exception(getSessionLog(), "exception_creating_jaxb_context", new Object[] { emfName, e.toString() }, e); - emf.close(); } } @@ -265,7 +262,7 @@ public ServiceVersion getServiceVersion() { * that is used for JSON and XML translation. */ protected void addDynamicXMLMetadataSources(List metadataSources, AbstractSession session) { - Set packages = new HashSet(); + Set packages = new HashSet<>(); for (Class descriptorClass : session.getDescriptors().keySet()) { String packageName = ""; int lastDotIndex = descriptorClass.getName().lastIndexOf('.'); @@ -344,10 +341,10 @@ protected EntityManager createEntityManager(String tenantId) { * Build the set of properties used to create the JAXBContext based on the EntityManagerFactory that * this PersistenceContext wraps */ - @SuppressWarnings({ "unchecked", "rawtypes" }) + @SuppressWarnings({"rawtypes" }) protected Map createJAXBProperties(AbstractSession session) throws IOException { - Map properties = new HashMap(1); - List metadataLocations = new ArrayList(); + Map properties = new HashMap<>(1); + List metadataLocations = new ArrayList<>(); addDynamicXMLMetadataSources(metadataLocations, session); @@ -596,7 +593,6 @@ public Object removeAttribute(Map tenantId, String entityName, O } } - @SuppressWarnings("unchecked") private Object getAttribute(Object entity, String propertyName) { try { BeanInfo info = Introspector.getBeanInfo(entity.getClass(), Object.class); @@ -607,7 +603,7 @@ private Object getAttribute(Object entity, String propertyName) { Method getter = pd.getReadMethod(); Object value; if (PrivilegedAccessHelper.shouldUsePrivilegedAccess()) { - value = AccessController.doPrivileged(new PrivilegedMethodInvoker(getter, entity)); + value = AccessController.doPrivileged(new PrivilegedMethodInvoker<>(getter, entity)); } else { value = PrivilegedAccessHelper.invokeMethod(getter, entity); } @@ -778,7 +774,7 @@ public Object merge(Map tenantId, Object entity) { try { transaction.beginTransaction(em); if (entity instanceof List) { - List mergeList = new ArrayList(); + List mergeList = new ArrayList<>(); for (Object o : (List) entity) { mergeList.add(em.merge(o)); } @@ -912,7 +908,6 @@ protected Query constructQuery(EntityManager em, String name, Map paramete * @param hints the hints * @return the query */ - @SuppressWarnings("rawtypes") public Query buildQuery(Map tenantId, String name, Map parameters, Map hints) { EntityManager em = getEmf().createEntityManager(tenantId); Query query = em.createNamedQuery(name); @@ -922,7 +917,7 @@ public Query buildQuery(Map tenantId, String name, Map par while (i.hasNext()) { Map.Entry entry = (Map.Entry) i.next(); String key = (String) entry.getKey(); - Class parameterClass = null; + Class parameterClass = null; int index = dbQuery.getArguments().indexOf(key); if (index >= 0) { parameterClass = dbQuery.getArgumentTypes().get(index); @@ -1149,6 +1144,7 @@ public void marshall(Object object, MediaType mediaType, OutputStream output, bo * the actual objects in the relationships. * @param fieldsFilter Specifies fields to include/exclude from the response. */ + @SuppressWarnings({"unchecked"}) public void marshall(final Object object, final MediaType mediaType, final OutputStream output, boolean sendRelationships, final FieldsFilter fieldsFilter) throws JAXBException { if (version.compareTo(ServiceVersion.VERSION_2_0) < 0 && sendRelationships) { preMarshallEntity(object); @@ -1274,7 +1270,7 @@ private void setRelationshipInfo(Object entity) { if ((entity != null) && (entity instanceof PersistenceWeavedRest)) { ClassDescriptor descriptor = getServerSession().getClassDescriptor(entity.getClass()); if (descriptor != null) { - ((PersistenceWeavedRest) entity)._persistence_setRelationships(new ArrayList()); + ((PersistenceWeavedRest) entity)._persistence_setRelationships(new ArrayList<>()); for (DatabaseMapping mapping : descriptor.getMappings()) { if (mapping.isForeignReferenceMapping()) { ForeignReferenceMapping frMapping = (ForeignReferenceMapping) mapping; @@ -1305,11 +1301,11 @@ protected void postMarshallEntity(Object object) { if (object instanceof List) { for (Object entity : ((List) object)) { if (entity instanceof PersistenceWeavedRest) { - ((PersistenceWeavedRest) entity)._persistence_setRelationships(new ArrayList()); + ((PersistenceWeavedRest) entity)._persistence_setRelationships(new ArrayList<>()); } } } else if (object instanceof PersistenceWeavedRest) { - ((PersistenceWeavedRest) object)._persistence_setRelationships(new ArrayList()); + ((PersistenceWeavedRest) object)._persistence_setRelationships(new ArrayList<>()); } } @@ -1318,7 +1314,7 @@ protected void postMarshallEntity(Object object) { if (adapters != null) { return adapters; } - adapters = new ArrayList>(); + adapters = new ArrayList<>(); try { final ClassLoader cl = getServerSession().getDatasourcePlatform().getConversionManager().getLoader(); @@ -1459,7 +1455,7 @@ private Map getPageableQueries() { * Initializes pageableQueries map by reading RestPageableQueries entity annotations. */ private void initPageableQueries() { - pageableQueries = new HashMap(); + pageableQueries = new HashMap<>(); // Iterate on all entity classes for (Class clazz : getServerSession().getProject().getDescriptors().keySet()) { diff --git a/dbws/org.eclipse.persistence.dbws/src/main/java/org/eclipse/persistence/jpa/rs/exceptions/AbstractExceptionMapper.java b/dbws/org.eclipse.persistence.dbws/src/main/java/org/eclipse/persistence/jpa/rs/exceptions/AbstractExceptionMapper.java index ad220f7ed1a..b1e87177d82 100644 --- a/dbws/org.eclipse.persistence.dbws/src/main/java/org/eclipse/persistence/jpa/rs/exceptions/AbstractExceptionMapper.java +++ b/dbws/org.eclipse.persistence.dbws/src/main/java/org/eclipse/persistence/jpa/rs/exceptions/AbstractExceptionMapper.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2020 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 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 @@ -59,7 +59,7 @@ public abstract class AbstractExceptionMapper { UriInfo uriInfo; private static final Map HTTP_STATUS_CODE_MAPPING = - Collections.unmodifiableMap(new HashMap() { + Collections.unmodifiableMap(new HashMap<>() { { put(ClassNotFoundException.class.getName(), Status.BAD_REQUEST); put(ConversionException.class.getName(), Status.BAD_REQUEST); diff --git a/dbws/org.eclipse.persistence.dbws/src/main/java/org/eclipse/persistence/jpa/rs/features/FeatureResponseBuilderImpl.java b/dbws/org.eclipse.persistence.dbws/src/main/java/org/eclipse/persistence/jpa/rs/features/FeatureResponseBuilderImpl.java index 8bea568540a..9f8c5802b42 100644 --- a/dbws/org.eclipse.persistence.dbws/src/main/java/org/eclipse/persistence/jpa/rs/features/FeatureResponseBuilderImpl.java +++ b/dbws/org.eclipse.persistence.dbws/src/main/java/org/eclipse/persistence/jpa/rs/features/FeatureResponseBuilderImpl.java @@ -125,7 +125,7 @@ public List> createShellJAXBElementList(List reportIt private SimpleHomogeneousList populateSimpleHomogeneousList(Collection collection, String attributeName) { SimpleHomogeneousList simpleList = new SimpleHomogeneousList(); - List items = new ArrayList(); + List items = new ArrayList<>(); for (Iterator iterator = collection.iterator(); iterator.hasNext();) { Object collectionItem = iterator.next(); diff --git a/dbws/org.eclipse.persistence.dbws/src/main/java/org/eclipse/persistence/jpa/rs/features/FeatureSetPreV2.java b/dbws/org.eclipse.persistence.dbws/src/main/java/org/eclipse/persistence/jpa/rs/features/FeatureSetPreV2.java index 98410224113..9022364188f 100644 --- a/dbws/org.eclipse.persistence.dbws/src/main/java/org/eclipse/persistence/jpa/rs/features/FeatureSetPreV2.java +++ b/dbws/org.eclipse.persistence.dbws/src/main/java/org/eclipse/persistence/jpa/rs/features/FeatureSetPreV2.java @@ -69,7 +69,7 @@ public FeatureResponseBuilder getResponseBuilder(Feature feature) { @Override public List getMetadataSources() { - final List metadataSources = new ArrayList(); + final List metadataSources = new ArrayList<>(); metadataSources.add(new LinkMetadataSource()); metadataSources.add(new ReportQueryResultListMetadataSource()); diff --git a/dbws/org.eclipse.persistence.dbws/src/main/java/org/eclipse/persistence/jpa/rs/features/FeatureSetV2.java b/dbws/org.eclipse.persistence.dbws/src/main/java/org/eclipse/persistence/jpa/rs/features/FeatureSetV2.java index e10c88838e8..808a1ac723c 100644 --- a/dbws/org.eclipse.persistence.dbws/src/main/java/org/eclipse/persistence/jpa/rs/features/FeatureSetV2.java +++ b/dbws/org.eclipse.persistence.dbws/src/main/java/org/eclipse/persistence/jpa/rs/features/FeatureSetV2.java @@ -73,7 +73,7 @@ public FeatureResponseBuilder getResponseBuilder(Feature feature) { @Override public List getMetadataSources() { - final List metadataSources = new ArrayList(); + final List metadataSources = new ArrayList<>(); metadataSources.add(new ReportQueryResultListMetadataSource()); metadataSources.add(new ReportQueryResultListItemMetadataSource()); diff --git a/dbws/org.eclipse.persistence.dbws/src/main/java/org/eclipse/persistence/jpa/rs/features/ItemLinksBuilder.java b/dbws/org.eclipse.persistence.dbws/src/main/java/org/eclipse/persistence/jpa/rs/features/ItemLinksBuilder.java index f79083b2e7a..4acaa10ca74 100644 --- a/dbws/org.eclipse.persistence.dbws/src/main/java/org/eclipse/persistence/jpa/rs/features/ItemLinksBuilder.java +++ b/dbws/org.eclipse.persistence.dbws/src/main/java/org/eclipse/persistence/jpa/rs/features/ItemLinksBuilder.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, 2020 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 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 @@ -29,7 +29,7 @@ * @since EclipseLink 2.6.0 */ public final class ItemLinksBuilder { - private final List links = new ArrayList(); + private final List links = new ArrayList<>(); /** * Adds a 'self' link. diff --git a/dbws/org.eclipse.persistence.dbws/src/main/java/org/eclipse/persistence/jpa/rs/resources/MetadataResource.java b/dbws/org.eclipse.persistence.dbws/src/main/java/org/eclipse/persistence/jpa/rs/resources/MetadataResource.java index 6e63c550c41..5dcd47b72ea 100644 --- a/dbws/org.eclipse.persistence.dbws/src/main/java/org/eclipse/persistence/jpa/rs/resources/MetadataResource.java +++ b/dbws/org.eclipse.persistence.dbws/src/main/java/org/eclipse/persistence/jpa/rs/resources/MetadataResource.java @@ -70,7 +70,7 @@ @Path("/{version : " + SERVICE_VERSION_FORMAT + "}/{context}/metadata-catalog/") public class MetadataResource extends AbstractResource { private static final String CLASS_NAME = MetadataResource.class.getName(); - private static final Map, String> PRIMITIVE_TO_JSON = new HashMap, String>(); + private static final Map, String> PRIMITIVE_TO_JSON = new HashMap<>(); static { PRIMITIVE_TO_JSON.put(boolean.class, "boolean"); diff --git a/dbws/org.eclipse.persistence.dbws/src/main/java/org/eclipse/persistence/jpa/rs/resources/common/AbstractPersistenceUnitResource.java b/dbws/org.eclipse.persistence.dbws/src/main/java/org/eclipse/persistence/jpa/rs/resources/common/AbstractPersistenceUnitResource.java index 5224a4672ad..1e60f3cf006 100644 --- a/dbws/org.eclipse.persistence.dbws/src/main/java/org/eclipse/persistence/jpa/rs/resources/common/AbstractPersistenceUnitResource.java +++ b/dbws/org.eclipse.persistence.dbws/src/main/java/org/eclipse/persistence/jpa/rs/resources/common/AbstractPersistenceUnitResource.java @@ -86,7 +86,7 @@ protected Response getQueriesMetadataInternal(String version, String persistence try { PersistenceContext context = getPersistenceContext(persistenceUnit, null, uriInfo.getBaseUri(), version, null); - List queries = new ArrayList(); + List queries = new ArrayList<>(); addQueries(queries, context, null); String mediaType = StreamingOutputMarshaller.mediaType(headers.getAcceptableMediaTypes()).toString(); QueryList queryList = new QueryList(); @@ -107,7 +107,7 @@ protected Response getQueryMetadataInternal(String version, String persistenceUn JPARSLogger.entering(CLASS_NAME, "getQueryMetadataInternal", new Object[] { "GET", version, persistenceUnit, queryName, uriInfo.getRequestUri().toASCIIString() }); try { PersistenceContext context = getPersistenceContext(persistenceUnit, null, uriInfo.getBaseUri(), version, null); - List returnQueries = new ArrayList(); + List returnQueries = new ArrayList<>(); Map> queries = context.getServerSession().getQueries(); if (queries.get(queryName) != null) { for (DatabaseQuery query : queries.get(queryName)) { @@ -130,7 +130,6 @@ protected Response getQueryMetadataInternal(String version, String persistenceUn } } - @SuppressWarnings("rawtypes") protected Response getTypesInternal(String version, String persistenceUnit, HttpHeaders headers, UriInfo uriInfo) { JPARSLogger.entering(CLASS_NAME, "getTypesInternal", new Object[] { "GET", version, persistenceUnit, uriInfo.getRequestUri().toASCIIString() }); try { @@ -218,7 +217,7 @@ private void addMapping(Descriptor descriptor, DatabaseMapping mapping) { private void addQueries(List queryList, PersistenceContext context, String javaClassName) { Map> queries = context.getServerSession().getQueries(); - List returnQueries = new ArrayList(); + List returnQueries = new ArrayList<>(); for (List keyQueries : queries.values()) { Iterator queryIterator = keyQueries.iterator(); while (queryIterator.hasNext()) { @@ -315,9 +314,9 @@ private String getSimplePublicCollectionTypeName(Class clazz) { if (clazz == null) { return null; } - LinkedHashSet> all = new LinkedHashSet>(); + LinkedHashSet> all = new LinkedHashSet<>(); getInterfaces(clazz, all); - ArrayList> list = new ArrayList>(all); + ArrayList> list = new ArrayList<>(all); for (int i = 0; i < all.size(); i++) { Class clas = list.get(i); if (clas.getName().equals(List.class.getName())) { diff --git a/dbws/org.eclipse.persistence.dbws/src/main/java/org/eclipse/persistence/jpa/rs/resources/common/AbstractResource.java b/dbws/org.eclipse.persistence.dbws/src/main/java/org/eclipse/persistence/jpa/rs/resources/common/AbstractResource.java index d2e4663e32d..8532baac431 100644 --- a/dbws/org.eclipse.persistence.dbws/src/main/java/org/eclipse/persistence/jpa/rs/resources/common/AbstractResource.java +++ b/dbws/org.eclipse.persistence.dbws/src/main/java/org/eclipse/persistence/jpa/rs/resources/common/AbstractResource.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2020 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 @@ -132,7 +132,7 @@ protected PersistenceContextFactory buildPersistenceContextFactory(ClassLoader l * @return the matrix parameters */ protected static Map getMatrixParameters(UriInfo info, String segment) { - Map matrixParameters = new HashMap(); + Map matrixParameters = new HashMap<>(); for (PathSegment pathSegment : info.getPathSegments()) { if (pathSegment.getPath() != null && pathSegment.getPath().equals(segment)) { for (Entry> entry : pathSegment.getMatrixParameters().entrySet()) { @@ -155,7 +155,7 @@ protected static Map getMatrixParameters(UriInfo info, String se * @return the query parameters */ public static Map getQueryParameters(UriInfo info) { - Map queryParameters = new HashMap(); + Map queryParameters = new HashMap<>(); for (String key : info.getQueryParameters().keySet()) { queryParameters.put(key, info.getQueryParameters().getFirst(key)); } diff --git a/dbws/org.eclipse.persistence.dbws/src/main/java/org/eclipse/persistence/jpa/rs/util/CollectionWrapperBuilder.java b/dbws/org.eclipse.persistence.dbws/src/main/java/org/eclipse/persistence/jpa/rs/util/CollectionWrapperBuilder.java index aca84284e3e..acdcb202ae6 100644 --- a/dbws/org.eclipse.persistence.dbws/src/main/java/org/eclipse/persistence/jpa/rs/util/CollectionWrapperBuilder.java +++ b/dbws/org.eclipse.persistence.dbws/src/main/java/org/eclipse/persistence/jpa/rs/util/CollectionWrapperBuilder.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, 2019 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 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 @@ -74,7 +74,7 @@ private void wrapCollectionsForEntity(Object entity) { final String id = IdHelper.stringifyId(entity, entity.getClass().getSimpleName(), context); // Generate links - final List links = new ArrayList(2); + final List links = new ArrayList<>(2); final String href = HrefHelper.buildEntityFieldHref(context, entity.getClass().getSimpleName(), id, field.getName()); links.add(new LinkV2(ReservedWords.JPARS_REL_SELF, href)); links.add(new LinkV2(ReservedWords.JPARS_REL_CANONICAL, href)); diff --git a/dbws/org.eclipse.persistence.dbws/src/main/java/org/eclipse/persistence/jpa/rs/util/IdHelper.java b/dbws/org.eclipse.persistence.dbws/src/main/java/org/eclipse/persistence/jpa/rs/util/IdHelper.java index dd097602b07..6913d73d1bc 100644 --- a/dbws/org.eclipse.persistence.dbws/src/main/java/org/eclipse/persistence/jpa/rs/util/IdHelper.java +++ b/dbws/org.eclipse.persistence.dbws/src/main/java/org/eclipse/persistence/jpa/rs/util/IdHelper.java @@ -196,7 +196,7 @@ public static Object buildObjectShell(PersistenceContext context, String entityT // If there are more that one PK, we assume an array as produced // by buildId() above with the keys // based on a sorted order of PK fields - List pkIndices = new ArrayList(); + List pkIndices = new ArrayList<>(); int index = 0; for (DatabaseMapping mapping : pkMappings) { pkIndices.add(new SortableKey(mapping, index)); @@ -226,7 +226,7 @@ public static Object buildObjectShell(PersistenceContext context, String entityT public static List getPrimaryKey(PersistenceContext context, String entityName) { ClassDescriptor descriptor = context.getDescriptor(entityName); List pkMappings = descriptor.getObjectBuilder().getPrimaryKeyMappings(); - List pkIndices = new ArrayList(); + List pkIndices = new ArrayList<>(); int index = 0; for (DatabaseMapping mapping : pkMappings) { if (!mapping.isMultitenantPrimaryKeyMapping()) { diff --git a/dbws/org.eclipse.persistence.dbws/src/main/java/org/eclipse/persistence/jpa/rs/util/ObjectGraphBuilder.java b/dbws/org.eclipse.persistence.dbws/src/main/java/org/eclipse/persistence/jpa/rs/util/ObjectGraphBuilder.java index 17ad199ff8e..498db363ef5 100644 --- a/dbws/org.eclipse.persistence.dbws/src/main/java/org/eclipse/persistence/jpa/rs/util/ObjectGraphBuilder.java +++ b/dbws/org.eclipse.persistence.dbws/src/main/java/org/eclipse/persistence/jpa/rs/util/ObjectGraphBuilder.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, 2020 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 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 @@ -188,7 +188,7 @@ private void fillSubgraphFromNode(Subgraph subgraph, Node node, FieldsFilter fil * Internal object graph node. */ private static class Node { - private final Map nodesMap = new HashMap(); + private final Map nodesMap = new HashMap<>(); public void addAttributeNode(final String attribute) { nodesMap.put(attribute, null); diff --git a/dbws/org.eclipse.persistence.dbws/src/main/java/org/eclipse/persistence/jpa/rs/util/list/ReportQueryResultCollection.java b/dbws/org.eclipse.persistence.dbws/src/main/java/org/eclipse/persistence/jpa/rs/util/list/ReportQueryResultCollection.java index f0906164698..a8b12f6fc45 100644 --- a/dbws/org.eclipse.persistence.dbws/src/main/java/org/eclipse/persistence/jpa/rs/util/list/ReportQueryResultCollection.java +++ b/dbws/org.eclipse.persistence.dbws/src/main/java/org/eclipse/persistence/jpa/rs/util/list/ReportQueryResultCollection.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2020 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 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 @@ -51,7 +51,7 @@ public ReportQueryResultCollection() { */ public void addItem(ReportQueryResultListItem item) { if (items == null) { - items = new ArrayList(); + items = new ArrayList<>(); } items.add(item); } @@ -64,7 +64,7 @@ public void addItem(ReportQueryResultListItem item) { @Override public void addLink(LinkV2 link) { if (links == null) { - links = new ArrayList(); + links = new ArrayList<>(); } links.add(link); } diff --git a/dbws/org.eclipse.persistence.dbws/src/main/java/org/eclipse/persistence/jpa/rs/util/list/ReportQueryResultList.java b/dbws/org.eclipse.persistence.dbws/src/main/java/org/eclipse/persistence/jpa/rs/util/list/ReportQueryResultList.java index 879973d693d..62f0f26a2dd 100644 --- a/dbws/org.eclipse.persistence.dbws/src/main/java/org/eclipse/persistence/jpa/rs/util/list/ReportQueryResultList.java +++ b/dbws/org.eclipse.persistence.dbws/src/main/java/org/eclipse/persistence/jpa/rs/util/list/ReportQueryResultList.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2020 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 @@ -65,7 +65,7 @@ public void setItems(List items) { */ public void addItem(ReportQueryResultListItem item) { if (items == null) { - items = new ArrayList(); + items = new ArrayList<>(); } items.add(item); } diff --git a/dbws/org.eclipse.persistence.dbws/src/main/java/org/eclipse/persistence/jpa/rs/util/list/SingleResultQueryResult.java b/dbws/org.eclipse.persistence.dbws/src/main/java/org/eclipse/persistence/jpa/rs/util/list/SingleResultQueryResult.java index 68b34fbff74..ed770f3b84a 100644 --- a/dbws/org.eclipse.persistence.dbws/src/main/java/org/eclipse/persistence/jpa/rs/util/list/SingleResultQueryResult.java +++ b/dbws/org.eclipse.persistence.dbws/src/main/java/org/eclipse/persistence/jpa/rs/util/list/SingleResultQueryResult.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, 2020 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 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 @@ -61,7 +61,7 @@ public void setLinks(List links) { public void addLink(LinkV2 link) { if (links == null) { - links = new ArrayList(); + links = new ArrayList<>(); } links.add(link); } diff --git a/dbws/org.eclipse.persistence.dbws/src/main/java/org/eclipse/persistence/jpa/rs/util/xmladapters/LinkAdapter.java b/dbws/org.eclipse.persistence.dbws/src/main/java/org/eclipse/persistence/jpa/rs/util/xmladapters/LinkAdapter.java index 9c0b26a8eea..2a35c30bbd4 100644 --- a/dbws/org.eclipse.persistence.dbws/src/main/java/org/eclipse/persistence/jpa/rs/util/xmladapters/LinkAdapter.java +++ b/dbws/org.eclipse.persistence.dbws/src/main/java/org/eclipse/persistence/jpa/rs/util/xmladapters/LinkAdapter.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2020 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 @@ -78,7 +78,7 @@ protected Object constructObjectForId(String entityType, Object id){ for (DatabaseMapping mapping: pkMappings){ fetchGroup.addAttribute(mapping.getAttributeName()); } - Map properties = new HashMap(); + Map properties = new HashMap<>(); properties.put(QueryHints.FETCH_GROUP, fetchGroup); properties.put(QueryHints.CACHE_USAGE, CacheUsage.CheckCacheOnly); Object entity = context.find(null, entityType, id, properties); diff --git a/dbws/org.eclipse.persistence.dbws/src/main/java/org/eclipse/persistence/jpa/rs/util/xmladapters/RestCollectionAdapter.java b/dbws/org.eclipse.persistence.dbws/src/main/java/org/eclipse/persistence/jpa/rs/util/xmladapters/RestCollectionAdapter.java index bebff73e2f0..a1ab31d5000 100644 --- a/dbws/org.eclipse.persistence.dbws/src/main/java/org/eclipse/persistence/jpa/rs/util/xmladapters/RestCollectionAdapter.java +++ b/dbws/org.eclipse.persistence.dbws/src/main/java/org/eclipse/persistence/jpa/rs/util/xmladapters/RestCollectionAdapter.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, 2020 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 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 @@ -63,7 +63,7 @@ public Collection unmarshal(CollectionWrapper v) throws Exception { return null; } - final Collection result = new ArrayList(); + final Collection result = new ArrayList<>(); // Check if links exist and items from there if it does if (v.getLinks() != null && !v.getLinks().isEmpty()) { @@ -76,7 +76,7 @@ public Collection unmarshal(CollectionWrapper v) throws Exception { if (v.getItems() != null) { // Process each item (load from href, etc.) - final ReferenceAdapterV2 referenceAdapter = new ReferenceAdapterV2(context); + final ReferenceAdapterV2 referenceAdapter = new ReferenceAdapterV2<>(context); for (T item : v.getItems()) { if (context != null) { result.add(referenceAdapter.unmarshal(item)); @@ -94,7 +94,7 @@ public CollectionWrapper marshal(Collection v) throws Exception { return null; } - final CollectionWrapper result = new CollectionWrapper(); + final CollectionWrapper result = new CollectionWrapper<>(); // Currently it returns only links. It will return items when 'expand' // feature will be implemented. diff --git a/foundation/org.eclipse.persistence.core/src/main/java/org/eclipse/persistence/descriptors/ClassDescriptor.java b/foundation/org.eclipse.persistence.core/src/main/java/org/eclipse/persistence/descriptors/ClassDescriptor.java index a04a54268ba..7e09c22ba87 100644 --- a/foundation/org.eclipse.persistence.core/src/main/java/org/eclipse/persistence/descriptors/ClassDescriptor.java +++ b/foundation/org.eclipse.persistence.core/src/main/java/org/eclipse/persistence/descriptors/ClassDescriptor.java @@ -370,12 +370,12 @@ public ClassDescriptor() { // Properties this.tables = NonSynchronizedVector.newInstance(3); this.mappings = NonSynchronizedVector.newInstance(); - this.primaryKeyFields = new ArrayList(2); + this.primaryKeyFields = new ArrayList<>(2); this.fields = NonSynchronizedVector.newInstance(); this.allFields = NonSynchronizedVector.newInstance(); this.constraintDependencies = NonSynchronizedVector.newInstance(2); - this.multipleTableForeignKeys = new HashMap(5); - this.queryKeys = new HashMap(5); + this.multipleTableForeignKeys = new HashMap<>(5); + this.queryKeys = new HashMap<>(5); this.initializationStage = UNINITIALIZED; this.interfaceInitializationStage = UNINITIALIZED; this.descriptorType = NORMAL; @@ -384,7 +384,7 @@ public ClassDescriptor() { this.shouldAlwaysConformResultsInUnitOfWork = false; this.shouldAcquireCascadedLocks = false; this.hasSimplePrimaryKey = false; - this.derivesIdMappings = new HashMap(5); + this.derivesIdMappings = new HashMap<>(5); this.referencingClasses = new HashSet<>(); @@ -392,7 +392,7 @@ public ClassDescriptor() { this.objectBuilder = new ObjectBuilder(this); this.cachePolicy = new CachePolicy(); - this.additionalWritableMapKeyFields = new ArrayList(2); + this.additionalWritableMapKeyFields = new ArrayList<>(2); this.foreignKeyValuesForCaching = new HashSet<>(); } @@ -4082,11 +4082,11 @@ private void browseReturningPolicies(List returningPolicies, Ve } private void prepareReturnFields(List returningPolicies) { - Vector returnFieldsInsert = new NonSynchronizedVector(); - Vector returnFieldsUpdate = new NonSynchronizedVector(); + Vector returnFieldsInsert = new NonSynchronizedVector<>(); + Vector returnFieldsUpdate = new NonSynchronizedVector<>(); List returnFieldsToMergeInsert = new ArrayList<>(); List returnFieldsToMergeUpdate = new ArrayList<>(); - Collection tmpFields; + Collection tmpFields; for (ReturningPolicy returningPolicy: returningPolicies) { tmpFields = returningPolicy.getFieldsToGenerateInsert(this.defaultTable); if (tmpFields != null) { diff --git a/foundation/org.eclipse.persistence.core/src/main/java/org/eclipse/persistence/descriptors/ReturningPolicy.java b/foundation/org.eclipse.persistence.core/src/main/java/org/eclipse/persistence/descriptors/ReturningPolicy.java index 4b882323e62..07178828780 100644 --- a/foundation/org.eclipse.persistence.core/src/main/java/org/eclipse/persistence/descriptors/ReturningPolicy.java +++ b/foundation/org.eclipse.persistence.core/src/main/java/org/eclipse/persistence/descriptors/ReturningPolicy.java @@ -123,14 +123,14 @@ protected void fieldIsNotFromDescriptor(DatabaseField field) { /** * INTERNAL: */ - public List getFieldsToGenerateInsert(DatabaseTable table) { + public List getFieldsToGenerateInsert(DatabaseTable table) { return getVectorOfFieldsToGenerate(INSERT, table); } /** * INTERNAL: */ - public List getFieldsToGenerateUpdate(DatabaseTable table) { + public List getFieldsToGenerateUpdate(DatabaseTable table) { return getVectorOfFieldsToGenerate(UPDATE, table); } diff --git a/foundation/org.eclipse.persistence.core/src/main/java/org/eclipse/persistence/internal/databaseaccess/DatabaseAccessor.java b/foundation/org.eclipse.persistence.core/src/main/java/org/eclipse/persistence/internal/databaseaccess/DatabaseAccessor.java index 412d7dab6a2..3c9da3bdea9 100644 --- a/foundation/org.eclipse.persistence.core/src/main/java/org/eclipse/persistence/internal/databaseaccess/DatabaseAccessor.java +++ b/foundation/org.eclipse.persistence.core/src/main/java/org/eclipse/persistence/internal/databaseaccess/DatabaseAccessor.java @@ -818,7 +818,7 @@ public Object processResultSet(ResultSet resultSet, DatabaseCall call, Statement * This code is not currently publicly supported. */ protected Vector buildThreadCursoredResult(final DatabaseCall dbCall, final ResultSet resultSet, final Statement statement, final ResultSetMetaData metaData, final AbstractSession session) { - final ThreadCursoredList results = new ThreadCursoredList(20); + final ThreadCursoredList results = new ThreadCursoredList<>(20); Runnable runnable = new Runnable() { @Override public void run() { diff --git a/foundation/org.eclipse.persistence.core/src/main/java/org/eclipse/persistence/internal/helper/ConcurrencyManager.java b/foundation/org.eclipse.persistence.core/src/main/java/org/eclipse/persistence/internal/helper/ConcurrencyManager.java index b09cc5409d8..ec8970af1f2 100644 --- a/foundation/org.eclipse.persistence.core/src/main/java/org/eclipse/persistence/internal/helper/ConcurrencyManager.java +++ b/foundation/org.eclipse.persistence.core/src/main/java/org/eclipse/persistence/internal/helper/ConcurrencyManager.java @@ -391,8 +391,8 @@ protected static Map getDeferredLockManagers() { /** * Init the deferred lock managers (thread - DeferredLockManager). */ - protected static Map initializeDeferredLockManagers() { - return new ConcurrentHashMap(); + protected static Map initializeDeferredLockManagers() { + return new ConcurrentHashMap<>(); } /** @@ -449,7 +449,7 @@ public boolean isLockedByMergeManager() { * contain the thread we will explore next. * @return true if object is complete */ - public static boolean isBuildObjectOnThreadComplete(Thread thread, Map recursiveSet, List parentChainOfThreads, boolean deadLockDiagnostic) { + public static boolean isBuildObjectOnThreadComplete(Thread thread, Map recursiveSet, List parentChainOfThreads, boolean deadLockDiagnostic) { if (recursiveSet.containsKey(thread)) { return true; } @@ -460,10 +460,10 @@ public static boolean isBuildObjectOnThreadComplete(Thread thread, Map recursive return true; } - Vector deferredLocks = lockManager.getDeferredLocks(); - for (Enumeration deferredLocksEnum = deferredLocks.elements(); + Vector deferredLocks = lockManager.getDeferredLocks(); + for (Enumeration deferredLocksEnum = deferredLocks.elements(); deferredLocksEnum.hasMoreElements();) { - ConcurrencyManager deferedLock = (ConcurrencyManager)deferredLocksEnum.nextElement(); + ConcurrencyManager deferedLock = deferredLocksEnum.nextElement(); Thread activeThread = null; if (deferedLock.isAcquired()) { activeThread = deferedLock.getActiveThread(); @@ -636,7 +636,7 @@ public void releaseDeferredLock() throws ConcurrencyException { boolean isBuildObjectCompleteSlow = ConcurrencyUtil.SINGLETON.tooMuchTimeHasElapsed(whileStartTimeMillis, ConcurrencyUtil.SINGLETON.getBuildObjectCompleteWaitTime()); try{ // 2612538 - the default size of Map (32) is appropriate - Map recursiveSet = new IdentityHashMap(); + Map recursiveSet = new IdentityHashMap<>(); if (isBuildObjectOnThreadComplete(currentThread, recursiveSet, Arrays.asList(currentThread), isBuildObjectCompleteSlow)) {// Thread job done. // Remove from debug metadata the fact that the current thread needed to wait // for one or more build objects to be completed by other threads. diff --git a/foundation/org.eclipse.persistence.core/src/main/java/org/eclipse/persistence/internal/helper/ConcurrencyUtil.java b/foundation/org.eclipse.persistence.core/src/main/java/org/eclipse/persistence/internal/helper/ConcurrencyUtil.java index 5ae4f25e789..f767721cd1f 100644 --- a/foundation/org.eclipse.persistence.core/src/main/java/org/eclipse/persistence/internal/helper/ConcurrencyUtil.java +++ b/foundation/org.eclipse.persistence.core/src/main/java/org/eclipse/persistence/internal/helper/ConcurrencyUtil.java @@ -1420,11 +1420,12 @@ public Map cloneDeferredLockManagerMap(Map cloneOfActiveLocks = (Vector) deferredLockManagerOriginal.getActiveLocks().clone(); + @SuppressWarnings("unchecked") + Vector cloneOfDeferredLocks = (Vector) deferredLockManagerOriginal.getDeferredLocks().clone(); // (b) Build our clone object DeferredLockManager deferredLockManagerClone = new DeferredLockManager(); diff --git a/foundation/org.eclipse.persistence.core/src/main/java/org/eclipse/persistence/internal/helper/CustomObjectInputStream.java b/foundation/org.eclipse.persistence.core/src/main/java/org/eclipse/persistence/internal/helper/CustomObjectInputStream.java index ea67253f19e..4257245c7ba 100644 --- a/foundation/org.eclipse.persistence.core/src/main/java/org/eclipse/persistence/internal/helper/CustomObjectInputStream.java +++ b/foundation/org.eclipse.persistence.core/src/main/java/org/eclipse/persistence/internal/helper/CustomObjectInputStream.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2020 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 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 @@ -41,7 +41,7 @@ public CustomObjectInputStream(InputStream stream, Session session) throws IOExc } @Override - public Class resolveClass(ObjectStreamClass classDesc) throws ClassNotFoundException, IOException { + public Class resolveClass(ObjectStreamClass classDesc) throws ClassNotFoundException, IOException { return m_conversionManager.convertClassNameToClass(classDesc.getName()); } } diff --git a/foundation/org.eclipse.persistence.core/src/main/java/org/eclipse/persistence/internal/helper/DBPlatformHelper.java b/foundation/org.eclipse.persistence.core/src/main/java/org/eclipse/persistence/internal/helper/DBPlatformHelper.java index 3120e7905c4..f9df821d2ba 100644 --- a/foundation/org.eclipse.persistence.core/src/main/java/org/eclipse/persistence/internal/helper/DBPlatformHelper.java +++ b/foundation/org.eclipse.persistence.core/src/main/java/org/eclipse/persistence/internal/helper/DBPlatformHelper.java @@ -175,10 +175,10 @@ private static void load(List properties, final String resourceName, * Open resourceName as input stream inside doPriviledged block */ private static InputStream openResourceInputStream(final String resourceName, final ClassLoader classLoader) { - return (InputStream) AccessController.doPrivileged( - new PrivilegedAction() { + return AccessController.doPrivileged( + new PrivilegedAction() { @Override - public Object run() { + public InputStream run() { if (classLoader != null) { return classLoader.getResourceAsStream(resourceName); } else { diff --git a/foundation/org.eclipse.persistence.core/src/main/java/org/eclipse/persistence/internal/helper/DeferredLockManager.java b/foundation/org.eclipse.persistence.core/src/main/java/org/eclipse/persistence/internal/helper/DeferredLockManager.java index 82a9794f591..de0e8695064 100644 --- a/foundation/org.eclipse.persistence.core/src/main/java/org/eclipse/persistence/internal/helper/DeferredLockManager.java +++ b/foundation/org.eclipse.persistence.core/src/main/java/org/eclipse/persistence/internal/helper/DeferredLockManager.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2020 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 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 @@ -30,8 +30,8 @@ * */ public class DeferredLockManager { - protected Vector deferredLocks; - protected Vector activeLocks; + protected Vector deferredLocks; + protected Vector activeLocks; protected int threadDepth; protected boolean isThreadComplete; @@ -42,8 +42,8 @@ public class DeferredLockManager { */ public DeferredLockManager() { super(); - this.deferredLocks = new Vector(1); - this.activeLocks = new Vector(1); + this.deferredLocks = new Vector<>(1); + this.activeLocks = new Vector<>(1); this.threadDepth = 0; this.isThreadComplete = false; } @@ -52,14 +52,14 @@ public DeferredLockManager() { * add a concurrency manager as active locks to the DLM */ public void addActiveLock(Object manager) { - getActiveLocks().addElement(manager); + getActiveLocks().addElement((ConcurrencyManager) manager); } /** * add a concurrency manager as deferred locks to the DLM */ public void addDeferredLock(Object manager) { - getDeferredLocks().addElement(manager); + getDeferredLocks().addElement((ConcurrencyManager) manager); } /** @@ -72,14 +72,14 @@ public void decrementDepth() { /** * Return a set of the active locks from the DLM */ - public Vector getActiveLocks() { + public Vector getActiveLocks() { return activeLocks; } /** * Return a set of the deferred locks */ - public Vector getDeferredLocks() { + public Vector getDeferredLocks() { return deferredLocks; } @@ -115,11 +115,11 @@ public boolean isThreadComplete() { * Release the active lock on the DLM */ public void releaseActiveLocksOnThread() { - Vector activeLocks = getActiveLocks(); + Vector activeLocks = getActiveLocks(); if (!activeLocks.isEmpty()) { - for (Enumeration activeLocksEnum = activeLocks.elements(); + for (Enumeration activeLocksEnum = activeLocks.elements(); activeLocksEnum.hasMoreElements();) { - ConcurrencyManager manager = (ConcurrencyManager)activeLocksEnum.nextElement(); + ConcurrencyManager manager = activeLocksEnum.nextElement(); manager.release(); } } @@ -129,14 +129,14 @@ public void releaseActiveLocksOnThread() { /** * set a set of the active locks to the DLM */ - public void setActiveLocks(Vector activeLocks) { + public void setActiveLocks(Vector activeLocks) { this.activeLocks = activeLocks; } /** * set a set of the deferred locks to the DLM */ - public void setDeferredLocks(Vector deferredLocks) { + public void setDeferredLocks(Vector deferredLocks) { this.deferredLocks = deferredLocks; } diff --git a/foundation/org.eclipse.persistence.core/src/main/java/org/eclipse/persistence/internal/helper/DescriptorCompare.java b/foundation/org.eclipse.persistence.core/src/main/java/org/eclipse/persistence/internal/helper/DescriptorCompare.java index 5c46b3e5d14..61abe5ba4a0 100644 --- a/foundation/org.eclipse.persistence.core/src/main/java/org/eclipse/persistence/internal/helper/DescriptorCompare.java +++ b/foundation/org.eclipse.persistence.core/src/main/java/org/eclipse/persistence/internal/helper/DescriptorCompare.java @@ -28,6 +28,12 @@ public class DescriptorCompare implements Comparator, Serializa private static final long serialVersionUID = -2792350655245140468L; + /** + * Default constructor. + */ + public DescriptorCompare() { + } + @Override public int compare(ClassDescriptor arg1, ClassDescriptor arg2) { return arg1.getJavaClassName().compareTo(arg2.getJavaClassName()); diff --git a/foundation/org.eclipse.persistence.core/src/main/java/org/eclipse/persistence/internal/helper/ExplainDeadLockUtil.java b/foundation/org.eclipse.persistence.core/src/main/java/org/eclipse/persistence/internal/helper/ExplainDeadLockUtil.java index b36b7cfc28c..cc6d074ee4e 100644 --- a/foundation/org.eclipse.persistence.core/src/main/java/org/eclipse/persistence/internal/helper/ExplainDeadLockUtil.java +++ b/foundation/org.eclipse.persistence.core/src/main/java/org/eclipse/persistence/internal/helper/ExplainDeadLockUtil.java @@ -774,7 +774,7 @@ protected DeadLockComponent recursiveExplainPossibleDeadLockStep04ExpandBasedOnT // is not able to make progress. // To understand why we do this one would need to have a good look at the concurrenyc manager implementation // at the logic that of the logic of the releaseDeferredLock method - IsBuildObjectCompleteOutcome result = isBuildObjectOnThreadComplete(concurrencyManagerStateDto, currentCandidateThreadPartOfTheDeadLock, new IdentityHashMap()); + IsBuildObjectCompleteOutcome result = isBuildObjectOnThreadComplete(concurrencyManagerStateDto, currentCandidateThreadPartOfTheDeadLock, new IdentityHashMap<>()); // (b) Our expectation is that the result of the step above is always different than null // after all if this candidate thread is stuck trying to release deferred locks there must be an explanation for it not making progress @@ -885,7 +885,7 @@ protected DeadLockComponent recursiveExplainPossibleDeadLockStep05ExpandBasedOnC */ public static IsBuildObjectCompleteOutcome isBuildObjectOnThreadComplete( final ConcurrencyManagerState concurrencyManagerStateDto, Thread thread, - Map recursiveSet) { + Map recursiveSet) { if (recursiveSet.containsKey(thread)) { // if the thread we are consider as we go deeper in the recursion is thread in an upper stack of the // recursion @@ -904,9 +904,9 @@ public static IsBuildObjectCompleteOutcome isBuildObjectOnThreadComplete( return IsBuildObjectCompleteOutcome.BUILD_OBJECT_IS_COMPLETE_TRUE; } - Vector deferredLocks = lockManager.getDeferredLocks(); - for (Enumeration deferredLocksEnum = deferredLocks.elements(); deferredLocksEnum.hasMoreElements();) { - ConcurrencyManager deferedLock = (ConcurrencyManager) deferredLocksEnum.nextElement(); + Vector deferredLocks = lockManager.getDeferredLocks(); + for (Enumeration deferredLocksEnum = deferredLocks.elements(); deferredLocksEnum.hasMoreElements();) { + ConcurrencyManager deferedLock = deferredLocksEnum.nextElement(); Thread activeThread = null; if (deferedLock.isAcquired()) { activeThread = deferedLock.getActiveThread(); diff --git a/foundation/org.eclipse.persistence.core/src/main/java/org/eclipse/persistence/internal/helper/Helper.java b/foundation/org.eclipse.persistence.core/src/main/java/org/eclipse/persistence/internal/helper/Helper.java index 27202afcf64..a18b402f79e 100644 --- a/foundation/org.eclipse.persistence.core/src/main/java/org/eclipse/persistence/internal/helper/Helper.java +++ b/foundation/org.eclipse.persistence.core/src/main/java/org/eclipse/persistence/internal/helper/Helper.java @@ -173,8 +173,8 @@ public static Queue getCalendarCache() { * PERF: * Init the calendar cache use to avoid calendar creation for processing java.sql/util.Date/Time/Timestamp objects. */ - public static Queue initCalendarCache() { - Queue calendarCache = new ConcurrentLinkedQueue(); + public static Queue initCalendarCache() { + Queue calendarCache = new ConcurrentLinkedQueue<>(); for (int index = 0; index < 10; index++) { calendarCache.add(Calendar.getInstance()); } diff --git a/foundation/org.eclipse.persistence.core/src/main/java/org/eclipse/persistence/internal/helper/JavaPlatform.java b/foundation/org.eclipse.persistence.core/src/main/java/org/eclipse/persistence/internal/helper/JavaPlatform.java index 9ebf0a9c17c..e54e97779f0 100644 --- a/foundation/org.eclipse.persistence.core/src/main/java/org/eclipse/persistence/internal/helper/JavaPlatform.java +++ b/foundation/org.eclipse.persistence.core/src/main/java/org/eclipse/persistence/internal/helper/JavaPlatform.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2019 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 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 @@ -36,13 +36,13 @@ public class JavaPlatform { * PERF: The like expression compiled Pattern objects are cached * to avoid re-compilation on every usage. */ - private static final ConcurrentHashMap patternCache = new ConcurrentHashMap(); + private static final ConcurrentHashMap patternCache = new ConcurrentHashMap<>(); /** * PERF: The regular expression compiled Pattern objects are cached * to avoid re-compilation on every usage. */ - private static final ConcurrentHashMap regexpPatternCache = new ConcurrentHashMap(); + private static final ConcurrentHashMap regexpPatternCache = new ConcurrentHashMap<>(); /** * INTERNAL: @@ -59,7 +59,7 @@ public static Boolean conformLike(Object left, Object right) { right = String.valueOf(right); // PERF: First check the pattern cache for the pattern. // Note that the original string is the key, to avoid having to translate it first. - Pattern pattern = (Pattern)patternCache.get(right); + Pattern pattern = patternCache.get(right); if (pattern == null) { // Bug 3936427 - Replace regular expression reserved characters with escaped version of those characters // For instance replace ? with \? @@ -90,7 +90,7 @@ public static Boolean conformRegexp(Object left, Object right) { right = String.valueOf(right); // PERF: First check the pattern cache for the pattern. // Note that the original string is the key, to avoid having to translate it first. - Pattern pattern = (Pattern)regexpPatternCache.get(right); + Pattern pattern = regexpPatternCache.get(right); if (pattern == null) { pattern = Pattern.compile((String)right); // Ensure cache does not grow beyond 100. diff --git a/foundation/org.eclipse.persistence.core/src/main/java/org/eclipse/persistence/internal/helper/LOBValueWriter.java b/foundation/org.eclipse.persistence.core/src/main/java/org/eclipse/persistence/internal/helper/LOBValueWriter.java index 2be49eab961..e5dbe99be41 100644 --- a/foundation/org.eclipse.persistence.core/src/main/java/org/eclipse/persistence/internal/helper/LOBValueWriter.java +++ b/foundation/org.eclipse.persistence.core/src/main/java/org/eclipse/persistence/internal/helper/LOBValueWriter.java @@ -55,7 +55,7 @@ */ public class LOBValueWriter { //DatabaseCalls still to be processed - private Collection calls = null; + private Collection calls = null; private Accessor accessor; private boolean isNativeConnectionRequired; @@ -93,7 +93,7 @@ protected void buildAndExecuteCall(DatabaseCall dbCall, AbstractSession session) */ public void fetchLocatorAndWriteValue(DatabaseCall dbCall, Object resultSet) throws SQLException { Enumeration enumFields = dbCall.getContexts().getFields().elements(); - Enumeration enumValues = dbCall.getContexts().getValues().elements(); + Enumeration enumValues = dbCall.getContexts().getValues().elements(); AbstractSession executionSession = dbCall.getQuery().getSession().getExecutionSession(dbCall.getQuery()); while (enumFields.hasMoreElements()) { DatabaseField field = enumFields.nextElement(); @@ -171,9 +171,9 @@ private DatabaseCall buildCallFromSelectStatementForLocator(SQLSelectStatement s public void addCall(Call call) { if (calls == null) { //use lazy initialization - calls = new ArrayList(2); + calls = new ArrayList<>(2); } - calls.add(call); + calls.add((DatabaseCall) call); } // Bug 3110860: RETURNINGPOLICY-OBTAINED PK CAUSES LOB TO BE INSERTED INCORRECTLY @@ -194,8 +194,8 @@ public void buildAndExecuteSelectCalls(AbstractSession session) { //all INSERTs have been executed, time to execute the SELECTs try { - for (Iterator callIt = calls.iterator(); callIt.hasNext();) { - DatabaseCall dbCall = (DatabaseCall)callIt.next(); + for (Iterator callIt = calls.iterator(); callIt.hasNext();) { + DatabaseCall dbCall = callIt.next(); buildAndExecuteCall(dbCall, session); } } finally { diff --git a/foundation/org.eclipse.persistence.core/src/main/java/org/eclipse/persistence/internal/helper/MappingCompare.java b/foundation/org.eclipse.persistence.core/src/main/java/org/eclipse/persistence/internal/helper/MappingCompare.java index 770567124e5..ad0e262a360 100644 --- a/foundation/org.eclipse.persistence.core/src/main/java/org/eclipse/persistence/internal/helper/MappingCompare.java +++ b/foundation/org.eclipse.persistence.core/src/main/java/org/eclipse/persistence/internal/helper/MappingCompare.java @@ -26,21 +26,21 @@ * Avoid using this class as sun.misc is not part of many VM's like Netscapes. * */ -public class MappingCompare implements Comparator, Serializable { +public class MappingCompare implements Comparator, Serializable { private static final long serialVersionUID = -2749222441763925989L; @Override - public int compare(Object arg1, Object arg2) { - int arg1Value = ((DatabaseMapping) arg1).getWeight(); - int arg2Value = ((DatabaseMapping) arg2).getWeight(); + public int compare(DatabaseMapping arg1, DatabaseMapping arg2) { + int arg1Value = arg1.getWeight(); + int arg2Value = arg2.getWeight(); if (arg1Value == arg2Value) { - int result = ((DatabaseMapping)arg1).getClass().getName().compareTo(((DatabaseMapping)arg2).getClass().getName()); + int result = arg1.getClass().getName().compareTo(arg2.getClass().getName()); // For same classes, compare attribute names. if (result == 0) { // Can be null for TransformationMapping. - if (((DatabaseMapping)arg1).getAttributeName() != null && ((DatabaseMapping)arg2).getAttributeName() != null) { - result = ((DatabaseMapping)arg1).getAttributeName().compareTo(((DatabaseMapping)arg2).getAttributeName()); + if (arg1.getAttributeName() != null && arg2.getAttributeName() != null) { + result = arg1.getAttributeName().compareTo(arg2.getAttributeName()); } } return result; diff --git a/foundation/org.eclipse.persistence.core/src/main/java/org/eclipse/persistence/internal/helper/NonSynchronizedProperties.java b/foundation/org.eclipse.persistence.core/src/main/java/org/eclipse/persistence/internal/helper/NonSynchronizedProperties.java index 4f6b65ffec0..fce293a406e 100644 --- a/foundation/org.eclipse.persistence.core/src/main/java/org/eclipse/persistence/internal/helper/NonSynchronizedProperties.java +++ b/foundation/org.eclipse.persistence.core/src/main/java/org/eclipse/persistence/internal/helper/NonSynchronizedProperties.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2020 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 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 @@ -26,7 +26,7 @@ public class NonSynchronizedProperties extends Properties { public NonSynchronizedProperties(int size) { super(); - this.values = new HashMap(size); + this.values = new HashMap<>(size); } @Override @@ -59,7 +59,7 @@ public boolean containsValue(Object value) { @Override public Enumeration elements() { - return new Hashtable(this.values).elements(); + return new Hashtable<>(this.values).elements(); } @Override @@ -89,7 +89,7 @@ public boolean isEmpty() { @Override public Enumeration keys() { - return new Hashtable(this.values).keys(); + return new Hashtable<>(this.values).keys(); } @Override @@ -107,7 +107,7 @@ public Object put(Object key, Object value) { } @Override - public void putAll(Map t) { + public void putAll(Map t) { this.values.putAll(t); } diff --git a/foundation/org.eclipse.persistence.core/src/main/java/org/eclipse/persistence/internal/helper/NonSynchronizedSubVector.java b/foundation/org.eclipse.persistence.core/src/main/java/org/eclipse/persistence/internal/helper/NonSynchronizedSubVector.java index f8b8d45f638..58315bcba2f 100644 --- a/foundation/org.eclipse.persistence.core/src/main/java/org/eclipse/persistence/internal/helper/NonSynchronizedSubVector.java +++ b/foundation/org.eclipse.persistence.core/src/main/java/org/eclipse/persistence/internal/helper/NonSynchronizedSubVector.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2020 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 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 @@ -19,12 +19,12 @@ /** * SubList that implements Vector. */ -public class NonSynchronizedSubVector extends NonSynchronizedVector { - private Vector l; +public class NonSynchronizedSubVector extends NonSynchronizedVector { + private Vector l; private int offset; private int size; - public NonSynchronizedSubVector(Vector list, int fromIndex, int toIndex) { + public NonSynchronizedSubVector(Vector list, int fromIndex, int toIndex) { super(0); if (fromIndex < 0) throw new IndexOutOfBoundsException("fromIndex = " + fromIndex); @@ -39,27 +39,27 @@ public NonSynchronizedSubVector(Vector list, int fromIndex, int toIndex) { } @Override - public Object set(int index, Object element) { + public E set(int index, E element) { return l.set(index+offset, element); } @Override - public void setElementAt(Object obj, int index) { + public void setElementAt(E obj, int index) { set(index, obj); } @Override - public Object elementAt(int index) { + public E elementAt(int index) { return get(index); } @Override - public Object firstElement() { + public E firstElement() { return get(0); } @Override - public Object lastElement() { + public E lastElement() { return get(size() - 1); } @@ -96,7 +96,7 @@ public int lastIndexOf(Object elem, int index) { } @Override - public Object get(int index) { + public E get(int index) { return l.get(index+offset); } @@ -106,7 +106,7 @@ public int size() { } @Override - public void add(int index, Object element) { + public void add(int index, E element) { if (index<0 || index>size) throw new IndexOutOfBoundsException(); l.add(index+offset, element); @@ -115,8 +115,8 @@ public void add(int index, Object element) { } @Override - public Object remove(int index) { - Object result = l.remove(index+offset); + public E remove(int index) { + E result = l.remove(index+offset); size--; modCount++; return result; @@ -129,12 +129,12 @@ public Object remove(int index) { }*/ @Override - public boolean addAll(Collection c) { + public boolean addAll(Collection c) { return addAll(size, c); } @Override - public boolean addAll(int index, Collection c) { + public boolean addAll(int index, Collection c) { if (index<0 || index>size) throw new IndexOutOfBoundsException( "Index: "+index+", Size: "+size); @@ -148,8 +148,8 @@ public boolean addAll(int index, Collection c) { } @Override - public Enumeration elements() { - return new Enumeration() { + public Enumeration elements() { + return new Enumeration() { int count = 0; @Override @@ -158,7 +158,7 @@ public boolean hasMoreElements() { } @Override - public Object nextElement() { + public E nextElement() { if (count < elementCount) { return get(count++); } @@ -175,10 +175,10 @@ public Object[] toArray() { } @Override - public Object[] toArray(Object a[]) { + @SuppressWarnings({"unchecked"}) + public T[] toArray(T[] a) { if (a.length < size) - a = (Object[])java.lang.reflect.Array.newInstance( - a.getClass().getComponentType(), size); + return (T[]) Arrays.copyOfRange(elementData, offset, size, a.getClass()); System.arraycopy(l.toArray(), offset, a, 0, size); @@ -189,18 +189,18 @@ public Object[] toArray(Object a[]) { } @Override - public Iterator iterator() { + public Iterator iterator() { return listIterator(); } @Override - public ListIterator listIterator(final int index) { + public ListIterator listIterator(final int index) { if (index<0 || index>size) throw new IndexOutOfBoundsException( "Index: "+index+", Size: "+size); - return new ListIterator() { - private ListIterator i = l.listIterator(index+offset); + return new ListIterator() { + private ListIterator i = l.listIterator(index+offset); @Override public boolean hasNext() { @@ -208,7 +208,7 @@ public boolean hasNext() { } @Override - public Object next() { + public E next() { if (hasNext()) return i.next(); else @@ -221,7 +221,7 @@ public boolean hasPrevious() { } @Override - public Object previous() { + public E previous() { if (hasPrevious()) return i.previous(); else @@ -246,12 +246,12 @@ public void remove() { } @Override - public void set(Object o) { + public void set(E o) { i.set(o); } @Override - public void add(Object o) { + public void add(E o) { i.add(o); size++; modCount++; diff --git a/foundation/org.eclipse.persistence.core/src/main/java/org/eclipse/persistence/internal/helper/NonSynchronizedVector.java b/foundation/org.eclipse.persistence.core/src/main/java/org/eclipse/persistence/internal/helper/NonSynchronizedVector.java index 7b80f025f71..7f44216fafc 100644 --- a/foundation/org.eclipse.persistence.core/src/main/java/org/eclipse/persistence/internal/helper/NonSynchronizedVector.java +++ b/foundation/org.eclipse.persistence.core/src/main/java/org/eclipse/persistence/internal/helper/NonSynchronizedVector.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2020 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 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 @@ -14,26 +14,32 @@ // Oracle - initial API and implementation from Oracle TopLink package org.eclipse.persistence.internal.helper; +import java.io.IOException; +import java.io.ObjectInputStream; +import java.io.StreamCorruptedException; import java.util.*; +import java.util.function.Consumer; +import java.util.function.Predicate; +import java.util.function.UnaryOperator; /** * Vector subclass that removes the synchronization. */ -public class NonSynchronizedVector extends Vector { - public static NonSynchronizedVector newInstance(int initialCapacity, int capacityIncrement) { - return new NonSynchronizedVector(initialCapacity, capacityIncrement); +public class NonSynchronizedVector extends Vector { + public static NonSynchronizedVector newInstance(int initialCapacity, int capacityIncrement) { + return new NonSynchronizedVector(initialCapacity, capacityIncrement); } - public static NonSynchronizedVector newInstance(int initialCapacity) { - return new NonSynchronizedVector(initialCapacity); + public static NonSynchronizedVector newInstance(int initialCapacity) { + return new NonSynchronizedVector(initialCapacity); } - public static NonSynchronizedVector newInstance() { - return new NonSynchronizedVector(); + public static NonSynchronizedVector newInstance() { + return new NonSynchronizedVector<>(); } - public static NonSynchronizedVector newInstance(Collection c) { - return new NonSynchronizedVector(c); + public static NonSynchronizedVector newInstance(Collection c) { + return new NonSynchronizedVector<>(c); } public NonSynchronizedVector(int initialCapacity, int capacityIncrement) { @@ -48,12 +54,12 @@ public NonSynchronizedVector() { super(); } - public NonSynchronizedVector(Collection c) { + public NonSynchronizedVector(Collection c) { super(c); } @Override - public void copyInto(Object anArray[]) { + public void copyInto(Object[] anArray) { System.arraycopy(elementData, 0, anArray, 0, elementCount); } @@ -62,42 +68,61 @@ public void trimToSize() { modCount++; int oldCapacity = elementData.length; if (elementCount < oldCapacity) { - Object oldData[] = elementData; - elementData = new Object[elementCount]; - System.arraycopy(oldData, 0, elementData, 0, elementCount); + elementData = Arrays.copyOf(elementData, elementCount); } } @Override public void ensureCapacity(int minCapacity) { - modCount++; - ensureCapacityHelper(minCapacity); + if (minCapacity > 0) { + modCount++; + if (minCapacity > elementData.length) + grow(minCapacity); + } } - private void ensureCapacityHelper(int minCapacity) { + private Object[] grow(int minCapacity) { int oldCapacity = elementData.length; - if (minCapacity > oldCapacity) { - Object oldData[] = elementData; - int newCapacity = (capacityIncrement > 0) ? - (oldCapacity + capacityIncrement) : (oldCapacity * 2); - if (newCapacity < minCapacity) { - newCapacity = minCapacity; - } - elementData = new Object[newCapacity]; - System.arraycopy(oldData, 0, elementData, 0, elementCount); + int newCapacity = newLength(oldCapacity, minCapacity - oldCapacity, + capacityIncrement > 0 ? capacityIncrement : oldCapacity); + return elementData = Arrays.copyOf(elementData, newCapacity); + } + + private int newLength(int oldLength, int minGrowth, int prefGrowth) { + int prefLength = oldLength + Math.max(minGrowth, prefGrowth); // might overflow + if (0 < prefLength && prefLength <= Integer.MAX_VALUE - 16) { + return prefLength; } + throw new OutOfMemoryError("Required array length is too large"); + } + + private Object[] grow() { + return grow(elementCount + 1); } + +// private void ensureCapacityHelper(int minCapacity) { +// int oldCapacity = elementData.length; +// if (minCapacity > oldCapacity) { +// Object oldData[] = elementData; +// int newCapacity = (capacityIncrement > 0) ? +// (oldCapacity + capacityIncrement) : (oldCapacity * 2); +// if (newCapacity < minCapacity) { +// newCapacity = minCapacity; +// } +// elementData = new Object[newCapacity]; +// System.arraycopy(oldData, 0, elementData, 0, elementCount); +// } +// } + @Override public void setSize(int newSize) { modCount++; - if (newSize > elementCount) { - ensureCapacityHelper(newSize); - } else { - for (int i = newSize ; i < elementCount ; i++) { - elementData[i] = null; - } - } + if (newSize > elementData.length) + grow(newSize); + final Object[] es = elementData; + for (int to = elementCount, i = newSize; i < to; i++) + es[i] = null; elementCount = newSize; } @@ -108,7 +133,7 @@ public int capacity() { @Override public Object clone() { - return new NonSynchronizedVector(this); + return new NonSynchronizedVector<>(this); } @Override @@ -122,19 +147,17 @@ public boolean isEmpty() { } @Override - public Enumeration elements() { - return new Enumeration() { + public Enumeration elements() { + return new Enumeration() { int count = 0; - @Override public boolean hasMoreElements() { return count < elementCount; } - @Override - public Object nextElement() { + public E nextElement() { if (count < elementCount) { - return elementData[count++]; + return elementData(count++); } throw new NoSuchElementException("Vector Enumeration"); } @@ -145,12 +168,12 @@ public Object nextElement() { public int indexOf(Object elem, int index) { if (elem == null) { for (int i = index ; i < elementCount ; i++) - if (elementData[i]==null) - return i; + if (elementData[i]==null) + return i; } else { for (int i = index ; i < elementCount ; i++) - if (elem.equals(elementData[i])) - return i; + if (elem.equals(elementData[i])) + return i; } return -1; } @@ -166,84 +189,90 @@ public int lastIndexOf(Object elem, int index) { throw new IndexOutOfBoundsException(index + " >= "+ elementCount); if (elem == null) { for (int i = index; i >= 0; i--) - if (elementData[i]==null) - return i; + if (elementData[i]==null) + return i; } else { for (int i = index; i >= 0; i--) - if (elem.equals(elementData[i])) - return i; + if (elem.equals(elementData[i])) + return i; } return -1; } @Override - public Object elementAt(int index) { + public E elementAt(int index) { if (index >= elementCount) { throw new ArrayIndexOutOfBoundsException(index + " >= " + elementCount); } - return elementData[index]; + + return elementData(index); } @Override - public Object firstElement() { + public E firstElement() { if (elementCount == 0) { throw new NoSuchElementException(); } - return elementData[0]; + return elementData(0); } @Override - public Object lastElement() { + public E lastElement() { if (elementCount == 0) { throw new NoSuchElementException(); } - return elementData[elementCount - 1]; + return elementData(elementCount - 1); } @Override - public void setElementAt(Object obj, int index) { + public void setElementAt(E obj, int index) { if (index >= elementCount) { throw new ArrayIndexOutOfBoundsException(index + " >= " + - elementCount); + elementCount); } elementData[index] = obj; } @Override public void removeElementAt(int index) { - modCount++; if (index >= elementCount) { throw new ArrayIndexOutOfBoundsException(index + " >= " + - elementCount); - } else if (index < 0) { + elementCount); + } + else if (index < 0) { throw new ArrayIndexOutOfBoundsException(index); } int j = elementCount - index - 1; if (j > 0) { System.arraycopy(elementData, index + 1, elementData, index, j); } + modCount++; elementCount--; elementData[elementCount] = null; /* to let gc do its work */ } @Override - public void insertElementAt(Object obj, int index) { - modCount++; + public void insertElementAt(E obj, int index) { if (index > elementCount) { throw new ArrayIndexOutOfBoundsException(index - + " > " + elementCount); + + " > " + elementCount); } - ensureCapacityHelper(elementCount + 1); - System.arraycopy(elementData, index, elementData, index + 1, elementCount - index); + modCount++; + final int s = elementCount; + Object[] elementData = this.elementData; + if (s == elementData.length) + elementData = grow(); + System.arraycopy(elementData, index, + elementData, index + 1, + s - index); elementData[index] = obj; - elementCount++; + elementCount = s + 1; } @Override - public void addElement(Object obj) { + public void addElement(E obj) { modCount++; - ensureCapacityHelper(elementCount + 1); - elementData[elementCount++] = obj; + add(obj, elementData, elementCount); } @Override @@ -259,26 +288,22 @@ public boolean removeElement(Object obj) { @Override public void removeAllElements() { + final Object[] es = elementData; + for (int to = elementCount, i = elementCount = 0; i < to; i++) + es[i] = null; modCount++; - // Let gc do its work - for (int i = 0; i < elementCount; i++) - elementData[i] = null; - - elementCount = 0; } @Override public Object[] toArray() { - Object[] result = new Object[elementCount]; - System.arraycopy(elementData, 0, result, 0, elementCount); - return result; + return Arrays.copyOf(elementData, elementCount); } @Override - public Object[] toArray(Object a[]) { + @SuppressWarnings({"unchecked"}) + public T[] toArray(T[] a) { if (a.length < elementCount) - a = (Object[])java.lang.reflect.Array.newInstance( - a.getClass().getComponentType(), elementCount); + return (T[]) Arrays.copyOf(elementData, elementCount, a.getClass()); System.arraycopy(elementData, 0, a, 0, elementCount); @@ -288,113 +313,168 @@ public Object[] toArray(Object a[]) { return a; } + @SuppressWarnings("unchecked") + E elementData(int index) { + return (E) elementData[index]; + } + + @SuppressWarnings("unchecked") + static E elementAt(Object[] es, int index) { + return (E) es[index]; + } + @Override - public Object get(int index) { + public E get(int index) { if (index >= elementCount) throw new ArrayIndexOutOfBoundsException(index); - return elementData[index]; + return elementData(index); } @Override - public Object set(int index, Object element) { + public E set(int index, E element) { if (index >= elementCount) throw new ArrayIndexOutOfBoundsException(index); - Object oldValue = elementData[index]; + E oldValue = elementData(index); elementData[index] = element; return oldValue; } + private void add(E e, Object[] elementData, int s) { + if (s == elementData.length) + elementData = grow(); + elementData[s] = e; + elementCount = s + 1; + } + @Override - public boolean add(Object o) { + public boolean add(E o) { modCount++; - ensureCapacityHelper(elementCount + 1); - elementData[elementCount++] = o; + add(o, elementData, elementCount); return true; } @Override - public Object remove(int index) { + public E remove(int index) { modCount++; if (index >= elementCount) throw new ArrayIndexOutOfBoundsException(index); - Object oldValue = elementData[index]; + E oldValue = elementData(index); int numMoved = elementCount - index - 1; if (numMoved > 0) System.arraycopy(elementData, index+1, elementData, index, - numMoved); + numMoved); elementData[--elementCount] = null; // Let gc do its work return oldValue; } @Override - public boolean containsAll(Collection c) { - Iterator e = c.iterator(); - while (e.hasNext()) - if(!contains(e.next())) + public boolean containsAll(Collection c) { + for (Object e : c) + if (!contains(e)) return false; - return true; } @Override - public boolean addAll(Collection c) { + public boolean addAll(Collection c) { + Object[] a = c.toArray(); modCount++; - Object[] a = c.toArray(); - int numNew = a.length; - ensureCapacityHelper(elementCount + numNew); - System.arraycopy(a, 0, elementData, elementCount, numNew); - elementCount += numNew; - return numNew != 0; - } - - @Override - public boolean removeAll(Collection c) { - boolean modified = false; - Iterator e = iterator(); - while (e.hasNext()) { - if(c.contains(e.next())) { - e.remove(); - modified = true; - } + int numNew = a.length; + if (numNew == 0) + return false; + Object[] elementData = this.elementData; + final int s = elementCount; + if (numNew > elementData.length - s) + elementData = grow(s + numNew); + System.arraycopy(a, 0, elementData, s, numNew); + elementCount = s + numNew; + return true; + } + + private static long[] nBits(int n) { + return new long[((n - 1) >> 6) + 1]; + } + private static void setBit(long[] bits, int i) { + bits[i >> 6] |= 1L << i; + } + private static boolean isClear(long[] bits, int i) { + return (bits[i >> 6] & (1L << i)) == 0; + } + + private boolean bulkRemove(Predicate filter) { + int expectedModCount = modCount; + final Object[] es = elementData; + final int end = elementCount; + int i; + // Optimize for initial run of survivors + for (i = 0; i < end && !filter.test(elementAt(es, i)); i++) + ; + // Tolerate predicates that reentrantly access the collection for + // read (but writers still get CME), so traverse once to find + // elements to delete, a second pass to physically expunge. + if (i < end) { + final int beg = i; + final long[] deathRow = nBits(end - beg); + deathRow[0] = 1L; // set bit 0 + for (i = beg + 1; i < end; i++) + if (filter.test(elementAt(es, i))) + setBit(deathRow, i - beg); + if (modCount != expectedModCount) + throw new ConcurrentModificationException(); + modCount++; + int w = beg; + for (i = beg; i < end; i++) + if (isClear(deathRow, i - beg)) + es[w++] = es[i]; + for (i = elementCount = w; i < end; i++) + es[i] = null; + return true; + } else { + if (modCount != expectedModCount) + throw new ConcurrentModificationException(); + return false; } - return modified; } @Override - public boolean retainAll(Collection c) { - boolean modified = false; - Iterator e = iterator(); - while (e.hasNext()) { - if(!c.contains(e.next())) { - e.remove(); - modified = true; - } - } - return modified; + public boolean removeAll(Collection c) { + Objects.requireNonNull(c); + return bulkRemove(e -> c.contains(e)); } @Override - public boolean addAll(int index, Collection c) { - modCount++; + public boolean retainAll(Collection c) { + Objects.requireNonNull(c); + return bulkRemove(e -> !c.contains(e)); + } + + @Override + public boolean addAll(int index, Collection c) { if (index < 0 || index > elementCount) throw new ArrayIndexOutOfBoundsException(index); - Object[] a = c.toArray(); + Object[] a = c.toArray(); + modCount++; int numNew = a.length; - ensureCapacityHelper(elementCount + numNew); + if (numNew == 0) + return false; + Object[] elementData = this.elementData; + final int s = elementCount; + if (numNew > elementData.length - s) + elementData = grow(s + numNew); - int numMoved = elementCount - index; + int numMoved = s - index; if (numMoved > 0) - System.arraycopy(elementData, index, elementData, index + numNew, - numMoved); - - System.arraycopy(a, 0, elementData, index, numNew); - elementCount += numNew; - return numNew != 0; + System.arraycopy(elementData, index, + elementData, index + numNew, + numMoved); + System.arraycopy(a, 0, elementData, index, numNew); + elementCount = s + numNew; + return true; } @Override @@ -404,70 +484,291 @@ public boolean equals(Object o) { if (!(o instanceof List)) return false; - List list = (List) o; - int size = size(); - if (list.size() != size) { - return false; - } - for (int index = 0; index < size; index++) { - Object left = get(index); - Object right = list.get(index); - if ((left != right) && ((left == null) || (right == null) || (!left.equals(right)))) { + ListIterator e1 = listIterator(); + ListIterator e2 = ((List) o).listIterator(); + while (e1.hasNext() && e2.hasNext()) { + E o1 = e1.next(); + Object o2 = e2.next(); + if (!(o1==null ? o2==null : o1.equals(o2))) return false; - } } - return true; + return !(e1.hasNext() || e2.hasNext()); } @Override public int hashCode() { int hashCode = 1; - int size = size(); - for (int index = 0; index < size; index++) { - Object obj = get(index); - hashCode = 31*hashCode + (obj==null ? 0 : obj.hashCode()); - } + for (E e : this) + hashCode = 31*hashCode + (e==null ? 0 : e.hashCode()); return hashCode; } @Override public String toString() { - StringBuilder buf = new StringBuilder(); - Iterator e = iterator(); - buf.append("["); - int maxIndex = size() - 1; - for (int i = 0; i <= maxIndex; i++) { - buf.append(String.valueOf(e.next())); - if (i < maxIndex) - buf.append(", "); + Iterator it = iterator(); + if (! it.hasNext()) + return "[]"; + + StringBuilder sb = new StringBuilder(); + sb.append('['); + for (;;) { + E e = it.next(); + sb.append(e == this ? "(this Collection)" : e); + if (! it.hasNext()) + return sb.append(']').toString(); + sb.append(',').append(' '); } - buf.append("]"); - return buf.toString(); + } + + @Override + public List subList(int fromIndex, int toIndex) { + return new NonSynchronizedSubVector(this, fromIndex, toIndex); } @Override protected void removeRange(int fromIndex, int toIndex) { modCount++; - int numMoved = elementCount - toIndex; - System.arraycopy(elementData, toIndex, elementData, fromIndex, - numMoved); + shiftTailOverGap(elementData, fromIndex, toIndex); + } + + private void shiftTailOverGap(Object[] es, int lo, int hi) { + System.arraycopy(es, hi, es, lo, elementCount - hi); + for (int to = elementCount, i = (elementCount -= hi - lo); i < to; i++) + es[i] = null; + } - // Let gc do its work - int newElementCount = elementCount - (toIndex-fromIndex); - while (elementCount != newElementCount) - elementData[--elementCount] = null; + private void readObject(ObjectInputStream in) + throws IOException, ClassNotFoundException { + in.defaultReadObject(); } private void writeObject(java.io.ObjectOutputStream s) - throws java.io.IOException - { + throws java.io.IOException { s.defaultWriteObject(); } + public ListIterator listIterator(int index) { + if (index < 0 || index > elementCount) + throw new IndexOutOfBoundsException("Index: "+index); + return new ListItr(index); + } + + public ListIterator listIterator() { + return new ListItr(0); + } + + public Iterator iterator() { + return new Itr(); + } + + private class Itr implements Iterator { + int cursor; // index of next element to return + int lastRet = -1; // index of last element returned; -1 if no such + int expectedModCount = modCount; + + public boolean hasNext() { + // Racy but within spec, since modifications are checked + // within or after synchronization in next/previous + return cursor != elementCount; + } + + public E next() { + checkForComodification(); + int i = cursor; + if (i >= elementCount) + throw new NoSuchElementException(); + cursor = i + 1; + return elementData(lastRet = i); + } + + public void remove() { + if (lastRet == -1) + throw new IllegalStateException(); + checkForComodification(); + NonSynchronizedVector.this.remove(lastRet); + expectedModCount = modCount; + cursor = lastRet; + lastRet = -1; + } + + @Override + public void forEachRemaining(Consumer action) { + Objects.requireNonNull(action); + final int size = elementCount; + int i = cursor; + if (i >= size) { + return; + } + final Object[] es = elementData; + if (i >= es.length) + throw new ConcurrentModificationException(); + while (i < size && modCount == expectedModCount) + action.accept(elementAt(es, i++)); + // update once at end of iteration to reduce heap write traffic + cursor = i; + lastRet = i - 1; + checkForComodification(); + } + + final void checkForComodification() { + if (modCount != expectedModCount) + throw new ConcurrentModificationException(); + } + } + + /** + * An optimized version of AbstractList.ListItr + */ + final class ListItr extends Itr implements ListIterator { + ListItr(int index) { + super(); + cursor = index; + } + + public boolean hasPrevious() { + return cursor != 0; + } + + public int nextIndex() { + return cursor; + } + + public int previousIndex() { + return cursor - 1; + } + + public E previous() { + checkForComodification(); + int i = cursor - 1; + if (i < 0) + throw new NoSuchElementException(); + cursor = i; + return elementData(lastRet = i); + } + + public void set(E e) { + if (lastRet == -1) + throw new IllegalStateException(); + checkForComodification(); + NonSynchronizedVector.this.set(lastRet, e); + } + + public void add(E e) { + int i = cursor; + checkForComodification(); + NonSynchronizedVector.this.add(i, e); + expectedModCount = modCount; + cursor = i + 1; + lastRet = -1; + } + } + + @Override + public void forEach(Consumer action) { + Objects.requireNonNull(action); + final int expectedModCount = modCount; + final Object[] es = elementData; + final int size = elementCount; + for (int i = 0; modCount == expectedModCount && i < size; i++) + action.accept(elementAt(es, i)); + if (modCount != expectedModCount) + throw new ConcurrentModificationException(); + } + + /** + * @throws NullPointerException {@inheritDoc} + */ @Override - public List subList(int fromIndex, int toIndex) { - return new NonSynchronizedSubVector(this, fromIndex, toIndex); + public void replaceAll(UnaryOperator operator) { + Objects.requireNonNull(operator); + final ListIterator li = this.listIterator(); + while (li.hasNext()) { + li.set(operator.apply(li.next())); + } } + @Override + @SuppressWarnings({"unchecked", "rawtypes"}) + public void sort(Comparator c) { + Object[] a = this.toArray(); + Arrays.sort(a, (Comparator) c); + ListIterator i = this.listIterator(); + for (Object e : a) { + i.next(); + i.set((E) e); + } + } + + @Override + public Spliterator spliterator() { + return new VectorSpliterator(null, 0, -1, 0); + } + + /** Similar to ArrayList Spliterator */ + final class VectorSpliterator implements Spliterator { + private Object[] array; + private int index; // current index, modified on advance/split + private int fence; // -1 until used; then one past last index + private int expectedModCount; // initialized when fence set + + /** Creates new spliterator covering the given range. */ + VectorSpliterator(Object[] array, int origin, int fence, + int expectedModCount) { + this.array = array; + this.index = origin; + this.fence = fence; + this.expectedModCount = expectedModCount; + } + + private int getFence() { // initialize on first use + int hi; + if ((hi = fence) < 0) { + array = elementData; + expectedModCount = modCount; + hi = fence = elementCount; + } + return hi; + } + + public Spliterator trySplit() { + int hi = getFence(), lo = index, mid = (lo + hi) >>> 1; + return (lo >= mid) ? null : + new VectorSpliterator(array, lo, index = mid, expectedModCount); + } + + @SuppressWarnings("unchecked") + public boolean tryAdvance(Consumer action) { + Objects.requireNonNull(action); + int i; + if (getFence() > (i = index)) { + index = i + 1; + action.accept((E)array[i]); + if (modCount != expectedModCount) + throw new ConcurrentModificationException(); + return true; + } + return false; + } + + @SuppressWarnings("unchecked") + public void forEachRemaining(Consumer action) { + Objects.requireNonNull(action); + final int hi = getFence(); + final Object[] a = array; + int i; + for (i = index, index = hi; i < hi; i++) + action.accept((E) a[i]); + if (modCount != expectedModCount) + throw new ConcurrentModificationException(); + } + + public long estimateSize() { + return getFence() - index; + } + + public int characteristics() { + return Spliterator.ORDERED | Spliterator.SIZED | Spliterator.SUBSIZED; + } + } } diff --git a/foundation/org.eclipse.persistence.core/src/main/java/org/eclipse/persistence/internal/helper/ThreadCursoredList.java b/foundation/org.eclipse.persistence.core/src/main/java/org/eclipse/persistence/internal/helper/ThreadCursoredList.java index b2a56076e9f..17bce4ff3fe 100644 --- a/foundation/org.eclipse.persistence.core/src/main/java/org/eclipse/persistence/internal/helper/ThreadCursoredList.java +++ b/foundation/org.eclipse.persistence.core/src/main/java/org/eclipse/persistence/internal/helper/ThreadCursoredList.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2019 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 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 @@ -36,7 +36,7 @@ * @author James Sutherland * @since OracleAS 10g TopLink (10.0.3) */ -public class ThreadCursoredList extends Vector { +public class ThreadCursoredList extends Vector { /** Store if the list is fully populated. */ protected boolean isComplete; @@ -73,7 +73,7 @@ public ThreadCursoredList(int initialCapacity, int capacityIncrement) { * Add and notify any waiters that there are new elements. */ @Override - public synchronized void add(int index, Object element) { + public synchronized void add(int index, E element) { super.add(index, element); this.notifyAll(); } @@ -82,7 +82,7 @@ public synchronized void add(int index, Object element) { * Add and notify any waiters that there are new elements. */ @Override - public synchronized boolean add(Object element) { + public synchronized boolean add(E element) { boolean result = super.add(element); notifyAll(); return result; @@ -92,7 +92,7 @@ public synchronized boolean add(Object element) { * Add and notify any waiters that there are new elements. */ @Override - public synchronized boolean addAll(int index, Collection collection) { + public synchronized boolean addAll(int index, Collection collection) { boolean result = super.addAll(index, collection); notifyAll(); return result; @@ -102,7 +102,7 @@ public synchronized boolean addAll(int index, Collection collection) { * Add and notify any waiters that there are new elements. */ @Override - public synchronized boolean addAll(Collection collection) { + public synchronized boolean addAll(Collection collection) { boolean result = super.addAll(collection); notifyAll(); return result; @@ -112,7 +112,7 @@ public synchronized boolean addAll(Collection collection) { * Add and notify any waiters that there are new elements. */ @Override - public synchronized void addElement(Object object) { + public synchronized void addElement(E object) { super.addElement(object); notifyAll(); } @@ -220,7 +220,7 @@ public synchronized boolean contains(Object element) { * If it does not contain the object must wait until it is complete. */ @Override - public synchronized boolean containsAll(Collection collection) { + public synchronized boolean containsAll(Collection collection) { boolean result = super.containsAll(collection); if ((result != true) && (!isComplete())) { waitUntilComplete(); @@ -242,8 +242,8 @@ public synchronized void copyInto(Object[] array) { * If the index is beyond the size wait until complete. */ @Override - public synchronized Object elementAt(int index) { - Object result = super.elementAt(index); + public synchronized E elementAt(int index) { + E result = super.elementAt(index); if ((result == null) && (!isComplete())) { waitUntilComplete(); result = super.elementAt(index); @@ -259,8 +259,8 @@ protected int getSize() { * Allow concurrent streaming of the elements. */ @Override - public Enumeration elements() { - return new Enumeration() { + public Enumeration elements() { + return new Enumeration() { int count = 0; @Override @@ -276,7 +276,7 @@ public boolean hasMoreElements() { } @Override - public Object nextElement() { + public E nextElement() { synchronized (ThreadCursoredList.this) { boolean result = count < ThreadCursoredList.this.getSize(); while ((!result) && (!isComplete())) { @@ -305,7 +305,7 @@ public synchronized boolean equals(Object object) { * Wait until has an element or is complete. */ @Override - public synchronized Object firstElement() { + public synchronized E firstElement() { while ((!isComplete()) && (super.size() < 1)) { waitUntilAdd(); } @@ -316,7 +316,7 @@ public synchronized Object firstElement() { * Wait until has the element or is complete. */ @Override - public synchronized Object get(int index) { + public synchronized E get(int index) { while ((!isComplete()) && (super.size() < index)) { waitUntilAdd(); } @@ -362,7 +362,7 @@ public synchronized int indexOf(Object element, int index) { * Add the element a notify any waiters that there are new elements. */ @Override - public synchronized void insertElementAt(Object element, int index) { + public synchronized void insertElementAt(E element, int index) { super.insertElementAt(element, index); notify(); } @@ -381,7 +381,7 @@ public boolean isEmpty() { } @Override - public Iterator iterator() { + public Iterator iterator() { return listIterator(0); } @@ -389,7 +389,7 @@ public Iterator iterator() { * First wait until complete. */ @Override - public synchronized Object lastElement() { + public synchronized E lastElement() { waitUntilComplete(); return super.lastElement(); } @@ -413,7 +413,7 @@ public synchronized int lastIndexOf(Object element, int index) { } @Override - public ListIterator listIterator() { + public ListIterator listIterator() { return listIterator(0); } @@ -421,8 +421,8 @@ public ListIterator listIterator() { * Iterate while waiting at end until complete. */ @Override - public ListIterator listIterator(final int index) { - return new ListIterator() { + public ListIterator listIterator(final int index) { + return new ListIterator() { int count = index; @Override @@ -438,7 +438,7 @@ public boolean hasNext() { } @Override - public Object next() { + public E next() { synchronized (ThreadCursoredList.this) { boolean result = count < ThreadCursoredList.this.getSize(); while ((!result) && (!isComplete())) { @@ -478,7 +478,7 @@ public int nextIndex() { } @Override - public Object previous() { + public E previous() { count--; return get(count); } @@ -494,7 +494,7 @@ public boolean hasPrevious() { * If index is missing wait until is there. */ @Override - public synchronized Object remove(int index) { + public synchronized E remove(int index) { while ((!isComplete()) && (super.size() < index)) { waitUntilAdd(); } @@ -518,7 +518,7 @@ public boolean remove(Object element) { * First wait until complete. */ @Override - public synchronized boolean removeAll(Collection collection) { + public synchronized boolean removeAll(Collection collection) { waitUntilComplete(); return super.removeAll(collection); } @@ -560,7 +560,7 @@ public synchronized void removeElementAt(int index) { * First wait until complete. */ @Override - public synchronized boolean retainAll(Collection collection) { + public synchronized boolean retainAll(Collection collection) { waitUntilComplete(); return super.retainAll(collection); } @@ -569,7 +569,7 @@ public synchronized boolean retainAll(Collection collection) { * If index is missing wait until reached or complete. */ @Override - public synchronized Object set(int index, Object element) { + public synchronized E set(int index, E element) { while ((!isComplete()) && (super.size() < index)) { waitUntilAdd(); } @@ -580,7 +580,7 @@ public synchronized Object set(int index, Object element) { * If index is missing wait until reached or complete. */ @Override - public synchronized void setElementAt(Object element, int index) { + public synchronized void setElementAt(E element, int index) { while ((!isComplete()) && (super.size() < index)) { waitUntilAdd(); } @@ -600,7 +600,7 @@ public int size() { * If index is missing wait until reached or complete. */ @Override - public List subList(int fromIndex, int toIndex) { + public List subList(int fromIndex, int toIndex) { while ((!isComplete()) && (super.size() < toIndex)) { waitUntilAdd(); } @@ -620,7 +620,7 @@ public synchronized Object[] toArray() { * First wait until complete. */ @Override - public synchronized Object[] toArray(Object[] array) { + public synchronized T[] toArray(T[] array) { waitUntilComplete(); return super.toArray(array); } diff --git a/foundation/org.eclipse.persistence.core/src/main/java/org/eclipse/persistence/internal/queries/ExpressionQueryMechanism.java b/foundation/org.eclipse.persistence.core/src/main/java/org/eclipse/persistence/internal/queries/ExpressionQueryMechanism.java index d7f618adc5b..863a7d721bc 100644 --- a/foundation/org.eclipse.persistence.core/src/main/java/org/eclipse/persistence/internal/queries/ExpressionQueryMechanism.java +++ b/foundation/org.eclipse.persistence.core/src/main/java/org/eclipse/persistence/internal/queries/ExpressionQueryMechanism.java @@ -574,7 +574,7 @@ protected SQLInsertStatement buildInsertStatement(DatabaseTable table) { insertStatement.setModifyRow(getModifyRow()); if (getDescriptor().hasReturningPolicies() && getDescriptor().getReturnFieldsToGenerateInsert() != null) { // In case of RelationalDescriptor only return fields for current table must be used. - Vector returnFieldsForTable = new NonSynchronizedVector(); + Vector returnFieldsForTable = new NonSynchronizedVector<>(); for (DatabaseField item: getDescriptor().getReturnFieldsToGenerateInsert()) { if (table.equals(item.getTable())) { returnFieldsForTable.add(item); diff --git a/foundation/org.eclipse.persistence.core/src/main/java/org/eclipse/persistence/internal/queries/JoinedAttributeManager.java b/foundation/org.eclipse.persistence.core/src/main/java/org/eclipse/persistence/internal/queries/JoinedAttributeManager.java index ccd0d8ef199..68723281926 100644 --- a/foundation/org.eclipse.persistence.core/src/main/java/org/eclipse/persistence/internal/queries/JoinedAttributeManager.java +++ b/foundation/org.eclipse.persistence.core/src/main/java/org/eclipse/persistence/internal/queries/JoinedAttributeManager.java @@ -32,6 +32,7 @@ import org.eclipse.persistence.internal.expressions.ForUpdateOfClause; import org.eclipse.persistence.internal.expressions.ObjectExpression; import org.eclipse.persistence.internal.expressions.QueryKeyExpression; +import org.eclipse.persistence.internal.helper.DatabaseField; import org.eclipse.persistence.internal.helper.NonSynchronizedSubVector; import org.eclipse.persistence.internal.sessions.AbstractRecord; import org.eclipse.persistence.internal.sessions.AbstractSession; @@ -990,14 +991,14 @@ protected void processDataResults(AbstractSession session) { List childRows = null; ObjectBuilder builder = getDescriptor().getObjectBuilder(); int parentIndex = getParentResultIndex(); - Vector trimedFields = null; + Vector trimedFields = null; for (int dataResultsIndex = 0; dataResultsIndex < size; dataResultsIndex++) { AbstractRecord row = this.dataResults.get(dataResultsIndex); AbstractRecord parentRow = row; // Must adjust for the parent index to ensure the correct pk is extracted. if (parentIndex > 0) { if (trimedFields == null) { // The fields are always the same, so only build once. - trimedFields = new NonSynchronizedSubVector(row.getFields(), parentIndex, row.size()); + trimedFields = new NonSynchronizedSubVector<>(row.getFields(), parentIndex, row.size()); } Vector trimedValues = new NonSynchronizedSubVector(row.getValues(), parentIndex, row.size()); parentRow = new DatabaseRecord(trimedFields, trimedValues); @@ -1057,14 +1058,14 @@ public void clearDataResults() { */ public AbstractRecord processDataResults(AbstractRecord row, Cursor cursor, boolean forward) { if (this.dataResultsByPrimaryKey == null) { - this.dataResultsByPrimaryKey = new HashMap(); + this.dataResultsByPrimaryKey = new HashMap<>(); } AbstractRecord parentRow = row; List childRows = new ArrayList<>(); childRows.add(row); int parentIndex = getParentResultIndex(); // Must adjust for the parent index to ensure the correct pk is extracted. - Vector trimedFields = new NonSynchronizedSubVector(row.getFields(), parentIndex, row.size()); + Vector trimedFields = new NonSynchronizedSubVector<>(row.getFields(), parentIndex, row.size()); if (parentIndex > 0) { Vector trimedValues = new NonSynchronizedSubVector(row.getValues(), parentIndex, row.size()); parentRow = new DatabaseRecord(trimedFields, trimedValues); diff --git a/foundation/org.eclipse.persistence.core/src/main/java/org/eclipse/persistence/internal/sessions/AbstractRecord.java b/foundation/org.eclipse.persistence.core/src/main/java/org/eclipse/persistence/internal/sessions/AbstractRecord.java index b4274ba0416..0d02c26e068 100644 --- a/foundation/org.eclipse.persistence.core/src/main/java/org/eclipse/persistence/internal/sessions/AbstractRecord.java +++ b/foundation/org.eclipse.persistence.core/src/main/java/org/eclipse/persistence/internal/sessions/AbstractRecord.java @@ -73,7 +73,7 @@ private NoEntry() { * converts JDBC results to collections of rows. */ protected AbstractRecord() { - this.fields = new NonSynchronizedVector(); + this.fields = new NonSynchronizedVector<>(); this.values = new NonSynchronizedVector(); this.size = 0; this.nullValueInFields = false; @@ -84,7 +84,7 @@ protected AbstractRecord() { * converts JDBC results to collections of rows. */ protected AbstractRecord(int initialCapacity) { - this.fields = new NonSynchronizedVector(initialCapacity); + this.fields = new NonSynchronizedVector<>(initialCapacity); this.values = new NonSynchronizedVector(initialCapacity); this.size = 0; this.nullValueInFields = false; diff --git a/foundation/org.eclipse.persistence.core/src/main/java/org/eclipse/persistence/mappings/DatabaseMapping.java b/foundation/org.eclipse.persistence.core/src/main/java/org/eclipse/persistence/mappings/DatabaseMapping.java index 66b2b858058..50a377364c3 100644 --- a/foundation/org.eclipse.persistence.core/src/main/java/org/eclipse/persistence/mappings/DatabaseMapping.java +++ b/foundation/org.eclipse.persistence.core/src/main/java/org/eclipse/persistence/mappings/DatabaseMapping.java @@ -926,7 +926,7 @@ public Vector getSelectFields() { * @return TODO */ public Vector getSelectTables() { - return new NonSynchronizedVector(0); + return new NonSynchronizedVector<>(0); } /** diff --git a/foundation/org.eclipse.persistence.core/src/main/java/org/eclipse/persistence/mappings/DirectCollectionMapping.java b/foundation/org.eclipse.persistence.core/src/main/java/org/eclipse/persistence/mappings/DirectCollectionMapping.java index 2f62d300d51..036750e84c6 100644 --- a/foundation/org.eclipse.persistence.core/src/main/java/org/eclipse/persistence/mappings/DirectCollectionMapping.java +++ b/foundation/org.eclipse.persistence.core/src/main/java/org/eclipse/persistence/mappings/DirectCollectionMapping.java @@ -1212,7 +1212,7 @@ protected ModifyQuery getUpdateAtIndexQuery() { */ @Override public Vector getSelectFields() { - Vector fields = new NonSynchronizedVector(2); + Vector fields = new NonSynchronizedVector<>(2); fields.add(getDirectField()); return fields; } @@ -1224,7 +1224,7 @@ public Vector getSelectFields() { */ @Override public Vector getSelectTables() { - Vector tables = new NonSynchronizedVector(0); + Vector tables = new NonSynchronizedVector<>(0); tables.add(getReferenceTable()); return tables; } diff --git a/foundation/org.eclipse.persistence.core/src/main/java/org/eclipse/persistence/mappings/ForeignReferenceMapping.java b/foundation/org.eclipse.persistence.core/src/main/java/org/eclipse/persistence/mappings/ForeignReferenceMapping.java index 40e490d45fe..afc1cc3de99 100644 --- a/foundation/org.eclipse.persistence.core/src/main/java/org/eclipse/persistence/mappings/ForeignReferenceMapping.java +++ b/foundation/org.eclipse.persistence.core/src/main/java/org/eclipse/persistence/mappings/ForeignReferenceMapping.java @@ -2398,7 +2398,7 @@ public AbstractRecord trimRowForJoin(AbstractRecord row, Object value, AbstractS } fieldStartIndex = (Integer) map.get(cls); } - Vector trimedFields = new NonSynchronizedSubVector(row.getFields(), fieldStartIndex, row.size()); + Vector trimedFields = new NonSynchronizedSubVector<>(row.getFields(), fieldStartIndex, row.size()); Vector trimedValues = new NonSynchronizedSubVector(row.getValues(), fieldStartIndex, row.size()); return new DatabaseRecord(trimedFields, trimedValues); } diff --git a/foundation/org.eclipse.persistence.core/src/main/java/org/eclipse/persistence/oxm/mappings/XMLCollectionReferenceMapping.java b/foundation/org.eclipse.persistence.core/src/main/java/org/eclipse/persistence/oxm/mappings/XMLCollectionReferenceMapping.java index 6564e72fea8..637b82e3a84 100644 --- a/foundation/org.eclipse.persistence.core/src/main/java/org/eclipse/persistence/oxm/mappings/XMLCollectionReferenceMapping.java +++ b/foundation/org.eclipse.persistence.core/src/main/java/org/eclipse/persistence/oxm/mappings/XMLCollectionReferenceMapping.java @@ -84,8 +84,8 @@ public class XMLCollectionReferenceMapping extends XMLObjectReferenceMapping imp * and sourceToTargetKeys data structures. */ public XMLCollectionReferenceMapping() { - sourceToTargetKeyFieldAssociations = new HashMap(); - sourceToTargetKeys = new NonSynchronizedVector(); + sourceToTargetKeyFieldAssociations = new HashMap<>(); + sourceToTargetKeys = new NonSynchronizedVector<>(); this.containerPolicy = ContainerPolicy.buildDefaultPolicy(); this.usesSingleNode = false; } diff --git a/foundation/org.eclipse.persistence.core/src/main/java/org/eclipse/persistence/queries/ReportQueryResult.java b/foundation/org.eclipse.persistence.core/src/main/java/org/eclipse/persistence/queries/ReportQueryResult.java index 322e7290e9f..232a3174662 100644 --- a/foundation/org.eclipse.persistence.core/src/main/java/org/eclipse/persistence/queries/ReportQueryResult.java +++ b/foundation/org.eclipse.persistence.core/src/main/java/org/eclipse/persistence/queries/ReportQueryResult.java @@ -39,6 +39,7 @@ import org.eclipse.persistence.internal.expressions.FunctionExpression; import org.eclipse.persistence.internal.expressions.MapEntryExpression; import org.eclipse.persistence.internal.helper.ConversionManager; +import org.eclipse.persistence.internal.helper.DatabaseField; import org.eclipse.persistence.internal.helper.NonSynchronizedSubVector; import org.eclipse.persistence.internal.queries.JoinedAttributeManager; import org.eclipse.persistence.internal.queries.ReportItem; @@ -250,7 +251,7 @@ protected Object processItem(ReportQuery query, AbstractRecord row, Vector toMan AbstractRecord subRow = row; // Check if at the start of the row, then avoid building a subRow. if (itemIndex > 0) { - Vector trimedFields = new NonSynchronizedSubVector(row.getFields(), itemIndex, rowSize); + Vector trimedFields = new NonSynchronizedSubVector<>(row.getFields(), itemIndex, rowSize); Vector trimedValues = new NonSynchronizedSubVector(row.getValues(), itemIndex, rowSize); subRow = new DatabaseRecord(trimedFields, trimedValues); } diff --git a/src/main/resources/spotbugs-exclude-common.xml b/src/main/resources/spotbugs-exclude-common.xml index 6aa7eee9f75..96f0ce8b1f4 100644 --- a/src/main/resources/spotbugs-exclude-common.xml +++ b/src/main/resources/spotbugs-exclude-common.xml @@ -11,4 +11,83 @@ --> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +