Skip to content

Commit 059428c

Browse files
authoredJul 15, 2024
Virtual Threads: performance impact with Helidon integration fix (pinning threads) (#2181)
Plus new Maven test module to test EclipseLink with Helidon Skip Helidon tests for <JDK21 - JavaDoc generation Signed-off-by: Radek Felcman <radek.felcman@oracle.com>
1 parent 8c0a9ca commit 059428c

File tree

25 files changed

+1527
-370
lines changed

25 files changed

+1527
-370
lines changed
 

‎etc/jenkins/pr_verify.groovy

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
//
2-
// Copyright (c) 2021, 2023 Oracle and/or its affiliates. All rights reserved.
2+
// Copyright (c) 2021, 2024 Oracle and/or its affiliates. All rights reserved.
33
//
44
// This program and the accompanying materials are made available under the
55
// terms of the Eclipse Public License v. 2.0 which is available at
@@ -194,7 +194,7 @@ spec:
194194
container('el-build') {
195195
sh """
196196
mvn -B -V clean install -pl :eclipselink -P staging
197-
mvn -B -V verify -pl :org.eclipse.persistence.jpa.modelgen.processor,:org.eclipse.persistence.jpa.jse.test,:org.eclipse.persistence.extension,:org.eclipse.persistence.jpa.jpql,:org.eclipse.persistence.jpa.wdf.test,:org.eclipse.persistence.jpars,:org.eclipse.persistence.dbws,:org.eclipse.persistence.dbws.builder,:eclipselink,:org.eclipse.persistence.distribution.tests -P staging,mysql;
197+
mvn -B -V verify -pl :org.eclipse.persistence.jpa.modelgen.processor,:org.eclipse.persistence.jpa.jse.test,:org.eclipse.persistence.jpa.helidon.test,:org.eclipse.persistence.extension,:org.eclipse.persistence.jpa.jpql,:org.eclipse.persistence.jpa.wdf.test,:org.eclipse.persistence.jpars,:org.eclipse.persistence.dbws,:org.eclipse.persistence.dbws.builder,:eclipselink,:org.eclipse.persistence.distribution.tests -P staging,mysql;
198198
"""
199199
}
200200
}

‎foundation/org.eclipse.persistence.core/src/main/java/org/eclipse/persistence/indirection/IndirectList.java

+61-31
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 1998, 2021 Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 1998, 2024 Oracle and/or its affiliates. All rights reserved.
33
*
44
* This program and the accompanying materials are made available under the
55
* terms of the Eclipse Public License v. 2.0 which is available at
@@ -24,6 +24,8 @@
2424
import java.util.ListIterator;
2525
import java.util.Spliterator;
2626
import java.util.Vector;
27+
import java.util.concurrent.locks.Lock;
28+
import java.util.concurrent.locks.ReentrantLock;
2729
import java.util.function.Consumer;
2830
import java.util.function.Predicate;
2931
import java.util.function.UnaryOperator;
@@ -98,6 +100,8 @@ public class IndirectList<E> extends Vector<E> implements CollectionChangeTracke
98100
*/
99101
private boolean useLazyInstantiation = true;
100102

103+
private final Lock instanceLock = new ReentrantLock();
104+
101105
/**
102106
* PUBLIC:
103107
* Construct an empty IndirectList so that its internal data array
@@ -350,13 +354,18 @@ public void clearDeferredChanges(){
350354
before merging collections (again, "un-instantiated" collections are not merged).
351355
*/
352356
@Override
353-
public synchronized Object clone() {
354-
IndirectList<E> result = (IndirectList<E>)super.clone();
355-
result.delegate = (Vector<E>)this.getDelegate().clone();
356-
result.valueHolder = new ValueHolder<>(result.delegate);
357-
result.attributeName = null;
358-
result.changeListener = null;
359-
return result;
357+
public Object clone() {
358+
instanceLock.lock();
359+
try {
360+
IndirectList<E> result = (IndirectList<E>)super.clone();
361+
result.delegate = (Vector<E>)this.getDelegate().clone();
362+
result.valueHolder = new ValueHolder<>(result.delegate);
363+
result.attributeName = null;
364+
result.changeListener = null;
365+
return result;
366+
} finally {
367+
instanceLock.unlock();
368+
}
360369
}
361370

362371
/**
@@ -391,8 +400,13 @@ public boolean containsAll(Collection<?> c) {
391400
* @see java.util.Vector#copyInto(java.lang.Object[])
392401
*/
393402
@Override
394-
public synchronized void copyInto(Object[] anArray) {
395-
getDelegate().copyInto(anArray);
403+
public void copyInto(Object[] anArray) {
404+
instanceLock.lock();
405+
try {
406+
getDelegate().copyInto(anArray);
407+
} finally {
408+
instanceLock.unlock();
409+
}
396410
}
397411

398412
/**
@@ -452,11 +466,14 @@ public E get(int index) {
452466
protected Vector<E> getDelegate() {
453467
Vector<E> v = this.delegate;
454468
if (v == null) {
455-
synchronized(this){
469+
instanceLock.lock();
470+
try {
456471
v = this.delegate;
457472
if (v == null) {
458473
this.delegate = v = this.buildDelegate();
459474
}
475+
} finally {
476+
instanceLock.unlock();
460477
}
461478
}
462479
return v;
@@ -482,11 +499,14 @@ public ValueHolderInterface<List<E>> getValueHolder() {
482499
ValueHolderInterface<List<E>> vh = this.valueHolder;
483500
// PERF: lazy initialize value holder and vector as are normally set after creation.
484501
if (vh == null) {
485-
synchronized(this) {
502+
instanceLock.lock();
503+
try {
486504
vh = this.valueHolder;
487505
if (vh == null) {
488506
this.valueHolder = vh = new ValueHolder<>(new Vector<>(this.initialCapacity, this.capacityIncrement));
489507
}
508+
} finally {
509+
instanceLock.unlock();
490510
}
491511
}
492512
return vh;
@@ -877,33 +897,43 @@ public Spliterator<E> spliterator() {
877897
}
878898

879899
@Override
880-
public synchronized void replaceAll(UnaryOperator<E> operator) {
881-
// Must trigger remove/add events if tracked or uow.
882-
if (hasBeenRegistered() || hasTrackedPropertyChangeListener()) {
883-
List<E> del = getDelegate();
884-
for (int i = 0; i < del.size(); i++) {
885-
set(i, operator.apply(del.get(i)));
900+
public void replaceAll(UnaryOperator<E> operator) {
901+
instanceLock.lock();
902+
try {
903+
// Must trigger remove/add events if tracked or uow.
904+
if (hasBeenRegistered() || hasTrackedPropertyChangeListener()) {
905+
List<E> del = getDelegate();
906+
for (int i = 0; i < del.size(); i++) {
907+
set(i, operator.apply(del.get(i)));
908+
}
909+
} else {
910+
getDelegate().replaceAll(operator);
886911
}
887-
} else {
888-
getDelegate().replaceAll(operator);
912+
} finally {
913+
instanceLock.unlock();
889914
}
890915
}
891916

892917
@Override
893-
public synchronized boolean removeIf(Predicate<? super E> filter) {
894-
// Must trigger remove events if tracked or uow.
895-
if (hasBeenRegistered() || hasTrackedPropertyChangeListener()) {
896-
boolean hasChanged = false;
897-
Iterator<E> objects = iterator();
898-
while (objects.hasNext()) {
899-
if (filter.test(objects.next())) {
900-
objects.remove();
901-
hasChanged |= true;
918+
public boolean removeIf(Predicate<? super E> filter) {
919+
instanceLock.lock();
920+
try {
921+
// Must trigger remove events if tracked or uow.
922+
if (hasBeenRegistered() || hasTrackedPropertyChangeListener()) {
923+
boolean hasChanged = false;
924+
Iterator<E> objects = iterator();
925+
while (objects.hasNext()) {
926+
if (filter.test(objects.next())) {
927+
objects.remove();
928+
hasChanged |= true;
929+
}
902930
}
931+
return hasChanged;
903932
}
904-
return hasChanged;
933+
return getDelegate().removeIf(filter);
934+
} finally {
935+
instanceLock.unlock();
905936
}
906-
return getDelegate().removeIf(filter);
907937
}
908938

909939
@Override

0 commit comments

Comments
 (0)