Blazebit / blaze-persistence

Rich Criteria API for JPA providers
https://persistence.blazebit.com
Apache License 2.0
725 stars 84 forks source link

Optimization of logging in the AnnotationUtils Utility Class #1897

Open ilxqx opened 5 months ago

ilxqx commented 5 months ago

Below is a code snippet from the class com.blazebit.annotation.AnnotationUtils:

public final class AnnotationUtils {

    private static Class<? extends Annotation> stereotypeAnnotationClass;

    static {
        try {
            stereotypeAnnotationClass = (Class<? extends Annotation>) Class.forName("javax.enterprise.inject.Stereotype");
        } catch (ClassNotFoundException ex) {
            Logger log = Logger.getLogger(AnnotationUtils.class.getName());
            log.log(Level.WARNING, "Stereotype annotation can not be found, skipping annotation inheritance via stereotype.");
        }
    }

    private AnnotationUtils() {
    }

    // ... omitted
}

I think the log printed here should be changed to the info level. Warnings give people an unacceptable illusion, and I am a perfectionist who dislikes warnings in logs for no reason.

My development environment is SpringBoot3.2, using blaze-persistence version 1.6.11.

Obviously, by default, the class javax.enterprise.inject.Stereotype is not in the classpath. I believe that in most development scenarios, this class does not exist either, and it is not an important issue worth noting or triggering warning log.

Thank you, I hope my suggestions can be adopted🙏.

ilxqx commented 5 months ago

The SpringBoot startup log contains the following log entry:

2024-04-26T14:33:14.417 WARN  36347 [     main] <userinfo unavailable> c.blazebit.annotation.AnnotationUtils    : Stereotype annotation can not be found, skipping annotation inheritance via stereotype.