Skip to content

Commit

Permalink
Merge branch 'main' into mongodb-client-opentelemetry
Browse files Browse the repository at this point in the history
  • Loading branch information
vkn authored Apr 23, 2024
2 parents e537e79 + 0efd81a commit 9e109de
Show file tree
Hide file tree
Showing 17 changed files with 31 additions and 52 deletions.
2 changes: 1 addition & 1 deletion .github/native-tests.json
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@
{
"category": "Misc4",
"timeout": 130,
"test-modules": "picocli-native, gradle, micrometer-mp-metrics, micrometer-prometheus, logging-json, jaxp, jaxb, opentelemetry, opentelemetry-jdbc-instrumentation, opentelemetry-redis-instrumentation, webjars-locator",
"test-modules": "picocli-native, gradle, micrometer-mp-metrics, micrometer-prometheus, logging-json, jaxp, jaxb, opentelemetry, opentelemetry-jdbc-instrumentation, opentelemetry-redis-instrumentation, web-dependency-locator",
"os-name": "ubuntu-latest"
},
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,6 @@

public final class BytecodeTransformerBuildItem extends MultiBuildItem {

/**
* If this is true it means the class should be loaded eagerly by a thread pool in dev mode
* on multithreaded systems.
* <p>
* Transformation is expensive, so doing it this way can speed up boot time.
*/
final boolean eager;
final String classToTransform;
final BiFunction<String, ClassVisitor, ClassVisitor> visitorFunction;

Expand Down Expand Up @@ -75,7 +68,6 @@ public BytecodeTransformerBuildItem(boolean eager, String classToTransform,
BiFunction<String, ClassVisitor, ClassVisitor> visitorFunction, Set<String> requireConstPoolEntry,
boolean cacheable) {
Objects.requireNonNull(visitorFunction, "visitorFunction");
this.eager = eager;
this.classToTransform = classToTransform;
this.visitorFunction = visitorFunction;
this.requireConstPoolEntry = requireConstPoolEntry;
Expand All @@ -87,7 +79,6 @@ public BytecodeTransformerBuildItem(boolean eager, String classToTransform,
}

public BytecodeTransformerBuildItem(Builder builder) {
this.eager = builder.eager;
this.classToTransform = builder.classToTransform;
this.visitorFunction = builder.visitorFunction;
this.requireConstPoolEntry = builder.requireConstPoolEntry;
Expand All @@ -113,8 +104,9 @@ public Set<String> getRequireConstPoolEntry() {
return requireConstPoolEntry;
}

@Deprecated
public boolean isEager() {
return eager;
return false;
}

public boolean isCacheable() {
Expand Down Expand Up @@ -161,7 +153,6 @@ public static class Builder {
private String classToTransform;
private BiFunction<String, ClassVisitor, ClassVisitor> visitorFunction;
private Set<String> requireConstPoolEntry = null;
private boolean eager = false;
private boolean cacheable = false;
private int classReaderOptions = 0;
private int priority = 0;
Expand Down Expand Up @@ -191,8 +182,8 @@ public Builder setRequireConstPoolEntry(Set<String> requireConstPoolEntry) {
return this;
}

@Deprecated
public Builder setEager(boolean eager) {
this.eager = eager;
return this;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,13 +46,18 @@ public static class TransformedClass {
*/
private final byte[] data;
private final String fileName;
private final boolean eager;

@Deprecated
public TransformedClass(String className, byte[] data, String fileName, boolean eager) {
this.className = className;
this.data = data;
this.fileName = fileName;
this.eager = eager;
}

public TransformedClass(String className, byte[] data, String fileName) {
this.className = className;
this.data = data;
this.fileName = fileName;
}

public byte[] getData() {
Expand All @@ -67,8 +72,9 @@ public String getClassName() {
return className;
}

@Deprecated
public boolean isEager() {
return eager;
return false;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,6 @@ TransformedClassesBuildItem handleClassTransformation(List<BytecodeTransformerBu
bytecodeTransformerBuildItems.size());
Set<String> noConstScanning = new HashSet<>();
Map<String, Set<String>> constScanning = new HashMap<>();
Set<String> eager = new HashSet<>();
Set<String> nonCacheable = new HashSet<>();
Map<String, Integer> classReaderOptions = new HashMap<>();
for (BytecodeTransformerBuildItem i : bytecodeTransformerBuildItems) {
Expand All @@ -106,9 +105,6 @@ TransformedClassesBuildItem handleClassTransformation(List<BytecodeTransformerBu
constScanning.computeIfAbsent(i.getClassToTransform(), (s) -> new HashSet<>())
.addAll(i.getRequireConstPoolEntry());
}
if (i.isEager()) {
eager.add(i.getClassToTransform());
}
if (!i.isCacheable()) {
nonCacheable.add(i.getClassToTransform());
}
Expand Down Expand Up @@ -164,7 +160,7 @@ public byte[] apply(String className, byte[] originalBytes) {
classReaderOptions.getOrDefault(className, 0));
TransformedClassesBuildItem.TransformedClass transformedClass = new TransformedClassesBuildItem.TransformedClass(
className, data,
classFileName, eager.contains(className));
classFileName);
return transformedClass.getData();
} else {
return originalBytes;
Expand Down Expand Up @@ -241,7 +237,7 @@ public TransformedClassesBuildItem.TransformedClass call() throws Exception {
classReaderOptions.getOrDefault(className, 0));
TransformedClassesBuildItem.TransformedClass transformedClass = new TransformedClassesBuildItem.TransformedClass(
className, data,
classFileName, eager.contains(className));
classFileName);
if (cacheable && launchModeBuildItem.getLaunchMode() == LaunchMode.DEVELOPMENT
&& classData != null) {
transformedClassesCache.put(className, transformedClass);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
import java.nio.file.Files;
import java.nio.file.StandardOpenOption;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
Expand Down Expand Up @@ -60,8 +59,7 @@ public StartupActionImpl(CuratedApplication curatedApplication, BuildResult buil
this.devServicesProperties = extractDevServicesProperties(buildResult);
this.runtimeApplicationShutdownBuildItems = buildResult.consumeMulti(RuntimeApplicationShutdownBuildItem.class);

Set<String> eagerClasses = new HashSet<>();
Map<String, byte[]> transformedClasses = extractTransformers(buildResult, eagerClasses);
Map<String, byte[]> transformedClasses = extractTransformedClasses(buildResult);
QuarkusClassLoader baseClassLoader = curatedApplication.getBaseRuntimeClassLoader();
QuarkusClassLoader runtimeClassLoader;

Expand Down Expand Up @@ -347,16 +345,13 @@ private static Map<String, String> extractDevServicesProperties(BuildResult buil
return new HashMap<>(result.getConfig());
}

private static Map<String, byte[]> extractTransformers(BuildResult buildResult, Set<String> eagerClasses) {
private static Map<String, byte[]> extractTransformedClasses(BuildResult buildResult) {
Map<String, byte[]> ret = new HashMap<>();
TransformedClassesBuildItem transformers = buildResult.consume(TransformedClassesBuildItem.class);
for (Set<TransformedClassesBuildItem.TransformedClass> i : transformers.getTransformedClassesByJar().values()) {
for (TransformedClassesBuildItem.TransformedClass clazz : i) {
if (clazz.getData() != null) {
ret.put(clazz.getFileName(), clazz.getData());
if (clazz.isEager()) {
eagerClasses.add(clazz.getClassName());
}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,16 +39,6 @@ public class SplitPackageProcessor {

private static final Logger LOGGER = Logger.getLogger(SplitPackageProcessor.class);

private static final Predicate<String> IGNORE_PACKAGE = new Predicate<>() {

@Override
public boolean test(String packageName) {
// Remove the elements from this list when the original issue is fixed
// so that we can detect further issues.
return packageName.startsWith("io.fabric8.kubernetes");
}
};

@BuildStep
void splitPackageDetection(ApplicationArchivesBuildItem archivesBuildItem,
ArcConfig config,
Expand Down Expand Up @@ -82,9 +72,6 @@ void splitPackageDetection(ApplicationArchivesBuildItem archivesBuildItem,
// - "com.me.app.sub" found in [archiveA, archiveB]
StringBuilder splitPackagesWarning = new StringBuilder();
for (String packageName : packageToArchiveMap.keySet()) {
if (IGNORE_PACKAGE.test(packageName)) {
continue;
}

// skip packages based on pre-built predicates
boolean skipEvaluation = false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1217,7 +1217,11 @@ private void enhanceEntities(final JpaModelBuildItem jpaModel,
BuildProducer<GeneratedClassBuildItem> additionalClasses) {
HibernateEntityEnhancer hibernateEntityEnhancer = new HibernateEntityEnhancer();
for (String i : jpaModel.getManagedClassNames()) {
transformers.produce(new BytecodeTransformerBuildItem(true, i, hibernateEntityEnhancer, true));

transformers.produce(new BytecodeTransformerBuildItem.Builder()
.setClassToTransform(i)
.setVisitorFunction(hibernateEntityEnhancer)
.setCacheable(true).build());
}
Set<String> additionalClassNames = new HashSet<>();
for (AdditionalJpaModelBuildItem additionalJpaModel : additionalJpaModelBuildItems) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ void build(
for (PanacheEntityClassBuildItem entityClass : entityClasses) {
String entityClassName = entityClass.get().name().toString();
modelClasses.add(entityClassName);
transformers.produce(new BytecodeTransformerBuildItem(true, entityClassName, entityOperationsEnhancer));
transformers.produce(new BytecodeTransformerBuildItem(entityClassName, entityOperationsEnhancer));
}

panacheEntities.addAll(modelClasses);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ void build(CombinedIndexBuildItem index,
ReactiveJavaJpaTypeBundle.BUNDLE);
for (PanacheEntityClassBuildItem entityClass : entityClasses) {
String entityClassName = entityClass.get().name().toString();
transformers.produce(new BytecodeTransformerBuildItem(true, entityClassName, entityOperationsEnhancer));
transformers.produce(new BytecodeTransformerBuildItem(entityClassName, entityOperationsEnhancer));
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ void replaceFieldAccesses(CombinedIndexBuildItem index,
PanacheJpaEntityAccessorsEnhancer entityAccessorsEnhancer = new PanacheJpaEntityAccessorsEnhancer(index.getIndex(),
modelInfo);
for (String entityClassName : entitiesWithExternallyAccessibleFields) {
transformers.produce(new BytecodeTransformerBuildItem(true, entityClassName, entityAccessorsEnhancer));
transformers.produce(new BytecodeTransformerBuildItem(entityClassName, entityAccessorsEnhancer));
}

// Replace field access in application code with calls to accessors
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -755,7 +755,7 @@ private static void generateDefaultConstructors(BuildProducer<BytecodeTransforme

final String name = classInfo.name().toString();
transformers
.produce(new BytecodeTransformerBuildItem(true, name, new BiFunction<String, ClassVisitor, ClassVisitor>() {
.produce(new BytecodeTransformerBuildItem(name, new BiFunction<String, ClassVisitor, ClassVisitor>() {
@Override
public ClassVisitor apply(String className, ClassVisitor classVisitor) {
ClassVisitor cv = new ClassVisitor(Gizmo.ASM_API_VERSION, classVisitor) {
Expand Down
2 changes: 1 addition & 1 deletion integration-tests/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -340,7 +340,7 @@
<module>simple with space</module>
<module>picocli</module>
<module>picocli-native</module>
<module>webjars-locator</module>
<module>web-dependency-locator</module>
<module>devmode</module>
<module>ide-launcher</module>
<module>elasticsearch-rest-client</module>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@
<version>999-SNAPSHOT</version>
</parent>

<artifactId>quarkus-integration-test-webjars-locator</artifactId>
<artifactId>quarkus-integration-test-web-dependency-locator</artifactId>

<name>Quarkus - Integration Tests - WebJar Locator</name>
<name>Quarkus - Integration Tests - Web Dependency Locator</name>

<properties>
<!-- do not update these dependencies, they are only used for testing -->
Expand All @@ -27,7 +27,7 @@
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-webjars-locator</artifactId>
<artifactId>quarkus-web-dependency-locator</artifactId>
</dependency>
<dependency>
<groupId>org.webjars</groupId>
Expand Down Expand Up @@ -67,7 +67,7 @@
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-webjars-locator-deployment</artifactId>
<artifactId>quarkus-web-dependency-locator-deployment</artifactId>
<version>${project.version}</version>
<type>pom</type>
<scope>test</scope>
Expand Down

0 comments on commit 9e109de

Please sign in to comment.