Skip to content

Commit c8f6bce

Browse files
authored
Merge pull request #195 from SentryMan/modulePathCheck
Check modulePath for plugin
2 parents 90c568f + 6898d01 commit c8f6bce

File tree

3 files changed

+17
-18
lines changed

3 files changed

+17
-18
lines changed

jsonb-generator/src/main/java/io/avaje/jsonb/generator/ProcessingContext.java

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
import java.util.List;
1313
import java.util.Map;
1414
import java.util.Optional;
15-
import java.util.concurrent.atomic.AtomicBoolean;
1615

1716
import javax.annotation.processing.ProcessingEnvironment;
1817
import javax.lang.model.element.Element;
@@ -86,26 +85,22 @@ static void validateModule(String fqn) {
8685

8786
try (var reader = getModuleInfoReader()) {
8887

89-
AtomicBoolean noInjectPlugin = new AtomicBoolean(injectPresent);
88+
var moduleInfo = new ModuleInfoReader(module, reader);
89+
90+
boolean noInjectPlugin =
91+
injectPresent && !moduleInfo.containsOnModulePath("io.avaje.jsonb.plugin");
92+
9093
var noProvides =
91-
reader
92-
.lines()
93-
.map(
94-
s -> {
95-
if (injectPresent
96-
&& (s.contains("io.avaje.jsonb.plugin") || s.contains("io.avaje.nima"))) {
97-
noInjectPlugin.set(false);
98-
}
99-
return s;
100-
})
94+
moduleInfo.provides().stream()
95+
.flatMap(s -> s.implementations().stream())
10196
.noneMatch(s -> s.contains(fqn));
10297

10398
if (noProvides) {
10499
logError(
105100
module, "Missing `provides io.avaje.jsonb.Jsonb.GeneratedComponent with %s;`", fqn);
106101
}
107102

108-
if (noInjectPlugin.get()) {
103+
if (noInjectPlugin) {
109104
logWarn(
110105
module,
111106
"`requires io.avaje.jsonb.plugin` must be explicity added or else avaje-inject may fail to detect and wire the default Jsonb instance",

jsonb-generator/src/main/java/io/avaje/jsonb/generator/Processor.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,14 @@
1414
import javax.lang.model.util.ElementFilter;
1515

1616
import io.avaje.prism.GenerateAPContext;
17+
import io.avaje.prism.GenerateModuleInfoReader;
1718

1819
import java.io.IOException;
1920
import java.util.*;
2021
import java.util.function.Predicate;
2122

2223
@GenerateAPContext
24+
@GenerateModuleInfoReader
2325
@SupportedAnnotationTypes({
2426
CustomAdapterPrism.PRISM_TYPE,
2527
JSON,

jsonb/src/main/java/io/avaje/jsonb/stream/BufferRecycleStrategy.java

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,17 @@
22

33
import java.util.function.Supplier;
44

5-
/**
6-
* Strategy for recycling buffers used in parsing and generation.
7-
*/
5+
/** Strategy for recycling buffers used in parsing and generation. */
86
public enum BufferRecycleStrategy {
97

10-
HYBRID_POOL(BufferRecycler::hybrid),
8+
/** Do not perform any sort of recycling. */
119
NO_RECYCLING(BufferRecycler::nonRecyclingPool),
10+
/** A lock free implementation designed for virtual thread use */
1211
LOCK_FREE(BufferRecycler::lockFreePool),
13-
THREAD_LOCAL(BufferRecycler::threadLocalPool);
12+
/** Use Thread Locals for recycling buffers */
13+
THREAD_LOCAL(BufferRecycler::threadLocalPool),
14+
/** Use 2 recyclers and switch between them depending on the nature of thread (virtual or not) */
15+
HYBRID_POOL(BufferRecycler::hybrid);
1416

1517
private final Supplier<BufferRecycler> supplier;
1618

0 commit comments

Comments
 (0)