Skip to content

Commit

Permalink
Virtual Threads: performance impact with Helidon integration fix (pin…
Browse files Browse the repository at this point in the history
…ning threads) (#2181)

Plus new Maven test module to test EclipseLink with Helidon
Skip Helidon tests for <JDK21 - JavaDoc generation

Signed-off-by: Radek Felcman <[email protected]>
  • Loading branch information
rfelcman authored Jul 15, 2024
1 parent 8c0a9ca commit 059428c
Show file tree
Hide file tree
Showing 25 changed files with 1,527 additions and 370 deletions.
4 changes: 2 additions & 2 deletions etc/jenkins/pr_verify.groovy
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//
// Copyright (c) 2021, 2023 Oracle and/or its affiliates. All rights reserved.
// Copyright (c) 2021, 2024 Oracle and/or its affiliates. All rights reserved.
//
// This program and the accompanying materials are made available under the
// terms of the Eclipse Public License v. 2.0 which is available at
Expand Down Expand Up @@ -194,7 +194,7 @@ spec:
container('el-build') {
sh """
mvn -B -V clean install -pl :eclipselink -P staging
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;
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;
"""
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 1998, 2021 Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1998, 2024 Oracle and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0 which is available at
Expand All @@ -24,6 +24,8 @@
import java.util.ListIterator;
import java.util.Spliterator;
import java.util.Vector;
import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReentrantLock;
import java.util.function.Consumer;
import java.util.function.Predicate;
import java.util.function.UnaryOperator;
Expand Down Expand Up @@ -98,6 +100,8 @@ public class IndirectList<E> extends Vector<E> implements CollectionChangeTracke
*/
private boolean useLazyInstantiation = true;

private final Lock instanceLock = new ReentrantLock();

/**
* PUBLIC:
* Construct an empty IndirectList so that its internal data array
Expand Down Expand Up @@ -350,13 +354,18 @@ public void clearDeferredChanges(){
before merging collections (again, "un-instantiated" collections are not merged).
*/
@Override
public synchronized Object clone() {
IndirectList<E> result = (IndirectList<E>)super.clone();
result.delegate = (Vector<E>)this.getDelegate().clone();
result.valueHolder = new ValueHolder<>(result.delegate);
result.attributeName = null;
result.changeListener = null;
return result;
public Object clone() {
instanceLock.lock();
try {
IndirectList<E> result = (IndirectList<E>)super.clone();
result.delegate = (Vector<E>)this.getDelegate().clone();
result.valueHolder = new ValueHolder<>(result.delegate);
result.attributeName = null;
result.changeListener = null;
return result;
} finally {
instanceLock.unlock();
}
}

/**
Expand Down Expand Up @@ -391,8 +400,13 @@ public boolean containsAll(Collection<?> c) {
* @see java.util.Vector#copyInto(java.lang.Object[])
*/
@Override
public synchronized void copyInto(Object[] anArray) {
getDelegate().copyInto(anArray);
public void copyInto(Object[] anArray) {
instanceLock.lock();
try {
getDelegate().copyInto(anArray);
} finally {
instanceLock.unlock();
}
}

/**
Expand Down Expand Up @@ -452,11 +466,14 @@ public E get(int index) {
protected Vector<E> getDelegate() {
Vector<E> v = this.delegate;
if (v == null) {
synchronized(this){
instanceLock.lock();
try {
v = this.delegate;
if (v == null) {
this.delegate = v = this.buildDelegate();
}
} finally {
instanceLock.unlock();
}
}
return v;
Expand All @@ -482,11 +499,14 @@ public ValueHolderInterface<List<E>> getValueHolder() {
ValueHolderInterface<List<E>> vh = this.valueHolder;
// PERF: lazy initialize value holder and vector as are normally set after creation.
if (vh == null) {
synchronized(this) {
instanceLock.lock();
try {
vh = this.valueHolder;
if (vh == null) {
this.valueHolder = vh = new ValueHolder<>(new Vector<>(this.initialCapacity, this.capacityIncrement));
}
} finally {
instanceLock.unlock();
}
}
return vh;
Expand Down Expand Up @@ -877,33 +897,43 @@ public Spliterator<E> spliterator() {
}

@Override
public synchronized void replaceAll(UnaryOperator<E> operator) {
// Must trigger remove/add events if tracked or uow.
if (hasBeenRegistered() || hasTrackedPropertyChangeListener()) {
List<E> del = getDelegate();
for (int i = 0; i < del.size(); i++) {
set(i, operator.apply(del.get(i)));
public void replaceAll(UnaryOperator<E> operator) {
instanceLock.lock();
try {
// Must trigger remove/add events if tracked or uow.
if (hasBeenRegistered() || hasTrackedPropertyChangeListener()) {
List<E> del = getDelegate();
for (int i = 0; i < del.size(); i++) {
set(i, operator.apply(del.get(i)));
}
} else {
getDelegate().replaceAll(operator);
}
} else {
getDelegate().replaceAll(operator);
} finally {
instanceLock.unlock();
}
}

@Override
public synchronized boolean removeIf(Predicate<? super E> filter) {
// Must trigger remove events if tracked or uow.
if (hasBeenRegistered() || hasTrackedPropertyChangeListener()) {
boolean hasChanged = false;
Iterator<E> objects = iterator();
while (objects.hasNext()) {
if (filter.test(objects.next())) {
objects.remove();
hasChanged |= true;
public boolean removeIf(Predicate<? super E> filter) {
instanceLock.lock();
try {
// Must trigger remove events if tracked or uow.
if (hasBeenRegistered() || hasTrackedPropertyChangeListener()) {
boolean hasChanged = false;
Iterator<E> objects = iterator();
while (objects.hasNext()) {
if (filter.test(objects.next())) {
objects.remove();
hasChanged |= true;
}
}
return hasChanged;
}
return hasChanged;
return getDelegate().removeIf(filter);
} finally {
instanceLock.unlock();
}
return getDelegate().removeIf(filter);
}

@Override
Expand Down
Loading

0 comments on commit 059428c

Please sign in to comment.