Skip to content

Commit

Permalink
Merge pull request #195 from SentryMan/modulePathCheck
Browse files Browse the repository at this point in the history
Check modulePath for plugin
  • Loading branch information
SentryMan authored Jan 10, 2024
2 parents 90c568f + 6898d01 commit c8f6bce
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.concurrent.atomic.AtomicBoolean;

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

try (var reader = getModuleInfoReader()) {

AtomicBoolean noInjectPlugin = new AtomicBoolean(injectPresent);
var moduleInfo = new ModuleInfoReader(module, reader);

boolean noInjectPlugin =
injectPresent && !moduleInfo.containsOnModulePath("io.avaje.jsonb.plugin");

var noProvides =
reader
.lines()
.map(
s -> {
if (injectPresent
&& (s.contains("io.avaje.jsonb.plugin") || s.contains("io.avaje.nima"))) {
noInjectPlugin.set(false);
}
return s;
})
moduleInfo.provides().stream()
.flatMap(s -> s.implementations().stream())
.noneMatch(s -> s.contains(fqn));

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

if (noInjectPlugin.get()) {
if (noInjectPlugin) {
logWarn(
module,
"`requires io.avaje.jsonb.plugin` must be explicity added or else avaje-inject may fail to detect and wire the default Jsonb instance",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,14 @@
import javax.lang.model.util.ElementFilter;

import io.avaje.prism.GenerateAPContext;
import io.avaje.prism.GenerateModuleInfoReader;

import java.io.IOException;
import java.util.*;
import java.util.function.Predicate;

@GenerateAPContext
@GenerateModuleInfoReader
@SupportedAnnotationTypes({
CustomAdapterPrism.PRISM_TYPE,
JSON,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,17 @@

import java.util.function.Supplier;

/**
* Strategy for recycling buffers used in parsing and generation.
*/
/** Strategy for recycling buffers used in parsing and generation. */
public enum BufferRecycleStrategy {

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

private final Supplier<BufferRecycler> supplier;

Expand Down

0 comments on commit c8f6bce

Please sign in to comment.