Skip to content

Qulice maven plugin 0.23.0 #415

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 60 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
60 commits
Select commit Hold shift + click to select a range
22cf949
Update qulice-maven-plugin to v0.23.0
uchitsa Nov 27, 2024
b794c6f
replace vulnerable dependency log4j
uchitsa Nov 27, 2024
f595182
fix quality violations
uchitsa Dec 5, 2024
0fc892a
fix quality violations
uchitsa Dec 5, 2024
688e10f
fix quality violations
uchitsa Dec 6, 2024
ab12f66
fix quality violations
uchitsa Dec 9, 2024
a15ff17
fix quality violations
uchitsa Dec 9, 2024
64c82a5
fix quality violations
uchitsa Dec 9, 2024
1f5825a
fix quality violations
uchitsa Dec 9, 2024
d0e2899
fix quality violations
uchitsa Dec 29, 2024
234ca0b
fix quality violations
uchitsa Jan 7, 2025
51ef07a
fix quality violations
uchitsa Jan 7, 2025
3e9a605
fix quality violations
uchitsa Jan 7, 2025
492d6ef
fix quality violations
uchitsa Jan 8, 2025
7689a0e
fix quality violations
uchitsa Jan 16, 2025
66cf551
fix quality violations
uchitsa Jan 16, 2025
ea0e71a
fix quality violations
uchitsa Jan 18, 2025
030f0a3
Merge remote-tracking branch 'origin/master' into qulice-maven-plugin…
uchitsa Jan 30, 2025
86f71b9
fix quality violations
uchitsa Jan 31, 2025
c05862e
fix quality violations
uchitsa Jan 31, 2025
b556b07
fix quality violations
uchitsa Jan 31, 2025
34d5f06
fix quality violations
uchitsa Jan 31, 2025
da3469e
fix quality violations
uchitsa Jan 31, 2025
5c6e82d
fix quality violations
uchitsa Jan 31, 2025
81a1c7a
fix quality violations
uchitsa Feb 1, 2025
40bcc68
fix quality violations
uchitsa Feb 1, 2025
76344ed
fix quality violations
uchitsa Feb 1, 2025
e0e92f9
fix quality violations
uchitsa Feb 2, 2025
2cda26e
fix quality violations
uchitsa Feb 2, 2025
f1fa467
fix quality violations
uchitsa Feb 2, 2025
84448eb
fix quality violations
uchitsa Feb 2, 2025
50276ba
fix quality violations
uchitsa Feb 2, 2025
c6c4bb2
fix quality violations
uchitsa Feb 4, 2025
3887ae4
fix quality violations
uchitsa Feb 4, 2025
c84ec1f
fix quality violations
uchitsa Feb 4, 2025
2156e9d
fix quality violations
uchitsa Feb 8, 2025
9e5bb34
fix quality violations
uchitsa Feb 8, 2025
5640041
fix quality violations
uchitsa Feb 8, 2025
422ef98
fix quality violations
uchitsa Feb 10, 2025
73479a2
fix quality violations
uchitsa Feb 10, 2025
a3eee30
fix quality violations
uchitsa Feb 10, 2025
88fd368
fix quality violations
uchitsa Feb 17, 2025
8d0c49b
fix quality violations
uchitsa Feb 20, 2025
8c05db3
fix quality violations
uchitsa Feb 20, 2025
6d287bd
fix quality violations
uchitsa Feb 21, 2025
dc860b1
fix quality violations
uchitsa Feb 21, 2025
48f72cd
fix quality violations
uchitsa Feb 21, 2025
c619898
fix quality violations
uchitsa Feb 21, 2025
8eba3ae
add copyrights
uchitsa Feb 24, 2025
b988672
fix quality violations
uchitsa Feb 24, 2025
f7c3de8
Merge remote-tracking branch 'origin/master' into qulice-maven-plugin…
uchitsa Feb 24, 2025
8b4b93a
update copyrights
uchitsa Feb 25, 2025
08167ef
update copyrights
uchitsa Feb 25, 2025
faa8c8f
update copyrights
uchitsa Feb 25, 2025
2bf563b
update copyrights
uchitsa Feb 25, 2025
e663abf
add copyrights
uchitsa Feb 25, 2025
8210200
update copyrights
uchitsa Feb 25, 2025
7228cb7
Merge remote-tracking branch 'origin/master' into qulice-maven-plugin…
uchitsa Mar 1, 2025
467c24c
Merge remote-tracking branch 'origin/master' into qulice-maven-plugin…
uchitsa Mar 15, 2025
8f46a14
Merge remote-tracking branch 'origin/master' into qulice-maven-plugin…
uchitsa Apr 8, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -109,9 +109,9 @@
<scope>test</scope>
</dependency>
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>1.2.17</version>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-core</artifactId>
<version>2.24.1</version>
<scope>test</scope>
</dependency>
<dependency>
Expand Down Expand Up @@ -209,7 +209,7 @@
<plugin>
<groupId>com.qulice</groupId>
<artifactId>qulice-maven-plugin</artifactId>
<version>0.22.0</version>
<version>0.23.0</version>
<configuration>
<excludes combine.children="append">
<exclude>checkstyle:/src/it.*</exclude>
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1,5 @@
#
# SPDX-FileCopyrightText: Copyright (c) 2012-2025 Yegor Bugayenko
# SPDX-License-Identifier: MIT
#
com.jcabi.aspects.FakeValidationProvider
2 changes: 1 addition & 1 deletion src/main/java/com/jcabi/aspects/aj/ExceptionsLogger.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
/**
* Logs all exceptions thrown out of a method.
*
* @since 0.1.10
* @see com.jcabi.aspects.LogExceptions
* @since 0.1.10
* @checkstyle IllegalThrows (100 lines)
* @checkstyle NonStaticMethodCheck (100 lines)
*/
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/com/jcabi/aspects/aj/MethodCacher.java
Original file line number Diff line number Diff line change
Expand Up @@ -161,9 +161,9 @@ private static boolean isCreateTunnel(final MethodCacher.Tunnel tunnel) {
* Flush cache.
* @param point Join point
* @return Value of the method
* @throws Throwable If something goes wrong inside
* @since 0.7.14
* @deprecated Since 0.7.17, and preflush() should be used
* @throws Throwable If something goes wrong inside
* @checkstyle IllegalThrows (4 lines)
* @checkstyle MethodsOrderCheck (3 lines)
*/
Expand Down
178 changes: 108 additions & 70 deletions src/main/java/com/jcabi/aspects/aj/MethodLogger.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,11 @@
@Aspect
@SuppressWarnings
(
{
"PMD.AvoidCatchingThrowable",
"PMD.TooManyMethods",
"PMD.CyclomaticComplexity"
}
{
"PMD.AvoidCatchingThrowable",
"PMD.TooManyMethods",
"PMD.CyclomaticComplexity"
}
)
public final class MethodLogger {

Expand All @@ -52,7 +52,8 @@ public final class MethodLogger {
@SuppressWarnings(
{
"PMD.DoNotUseThreads",
"PMD.ConstructorOnlyInitializesOrCallOtherConstructors"
"PMD.ConstructorOnlyInitializesOrCallOtherConstructors",
"PMD.CloseResource"
}
)
public MethodLogger() {
Expand Down Expand Up @@ -158,88 +159,125 @@ public Object wrapMethod(final ProceedingJoinPoint point) throws Throwable {
"PMD.AvoidThreadGroup",
"PMD.GuardLogStatement"
})
private Object wrap(final ProceedingJoinPoint point, final Method method,
final Loggable annotation) throws Throwable {
// @checkstyle IllegalCatchCheck (15 lines)
private Object wrap(
final ProceedingJoinPoint point,
final Method method,
final Loggable annotation
) throws Throwable {
this.checkThreadInterruption();
final long start = System.nanoTime();
final MethodLogger.Marker marker = new MethodLogger.Marker(point, annotation);
this.running.add(marker);
try {
logMethodEntry(point, method, annotation);
final Object result = point.proceed();
logMethodExit(point, method, annotation, result, start);
return result;
} catch (final Throwable exc) {
handleException(exc, point, method, annotation, start);
throw exc;
} finally {
this.running.remove(marker);
}
}

private void checkThreadInterruption() {
if (Thread.interrupted()) {
throw new IllegalStateException(
String.format(
"thread '%s' in group '%s' interrupted",
Thread.currentThread().getName(),
Thread.currentThread().getThreadGroup().getName()
"thread '%s' was interrupted",
Thread.currentThread().getName()
)
);
}
final long start = System.nanoTime();
final MethodLogger.Marker marker =
new MethodLogger.Marker(point, annotation);
this.running.add(marker);
int level = annotation.value();
try {
}

private static void logMethodEntry(
final ProceedingJoinPoint point,
final Method method,
final Loggable annotation
) {
if (annotation.prepend()) {
final Object logger = MethodLogger.logger(method, annotation.name());
if (annotation.prepend()) {
LogHelper.log(
annotation.value(),
logger,
new StringBuilder(
Mnemos.toText(
point,
annotation.trim(),
annotation.skipArgs(),
annotation.logThis()
)
).append(": entered").toString()
);
}
}

// @checkstyle ParameterNumberCheck (7 lines)
private static void logMethodExit(
final ProceedingJoinPoint point,
final Method method,
final Loggable annotation,
final Object result,
final long start
) {
final long nano = System.nanoTime() - start;
final Object logger = MethodLogger.logger(method, annotation.name());
int level = annotation.value();
if (LogHelper.enabled(level, logger) || MethodLogger.over(annotation, nano)) {
if (MethodLogger.over(annotation, nano)) {
level = Loggable.WARN;
}
LogHelper.log(
level, logger,
MethodLogger.message(point, method, annotation, result, nano)
);
}
}

// @checkstyle ParameterNumberCheck (7 lines)
private static void handleException(
final Throwable exc,
final ProceedingJoinPoint point,
final Method method,
final Loggable annotation,
final long start
) {
if (!MethodLogger.contains(annotation.ignore(), exc)
&& !exc.getClass().isAnnotationPresent(Loggable.Quiet.class)) {
final String origin = getExceptionOrigin(exc);
if (LogHelper.enabled(annotation.value(), method.getDeclaringClass())) {
LogHelper.log(
level,
logger,
new StringBuilder(
annotation.value(),
method.getDeclaringClass(),
Logger.format(
"%s: thrown %s out of %s in %[nano]s",
Mnemos.toText(
point,
annotation.trim(),
annotation.skipArgs(),
annotation.logThis()
)
).append(": entered").toString()
);
}
final Object result = point.proceed();
final long nano = System.nanoTime() - start;
if (LogHelper.enabled(level, logger)
|| MethodLogger.over(annotation, nano)) {
if (MethodLogger.over(annotation, nano)) {
level = Loggable.WARN;
}
LogHelper.log(
level, logger,
MethodLogger.message(point, method, annotation, result, nano)
),
Mnemos.toText(exc),
origin,
System.nanoTime() - start
)
);
}
return result;
// @checkstyle IllegalCatch (1 line)
} catch (final Throwable ex) {
if (!MethodLogger.contains(annotation.ignore(), ex)
&& !ex.getClass().isAnnotationPresent(Loggable.Quiet.class)) {
final StackTraceElement[] traces = ex.getStackTrace();
final String origin;
if (traces.length > 0) {
final StackTraceElement trace = traces[0];
origin = MethodLogger.oneText(trace);
} else {
origin = "somewhere";
}
if (LogHelper.enabled(level, method.getDeclaringClass())) {
LogHelper.log(
level,
method.getDeclaringClass(),
Logger.format(
"%s: thrown %s out of %s in %[nano]s",
Mnemos.toText(
point,
annotation.trim(),
annotation.skipArgs(),
annotation.logThis()
),
Mnemos.toText(ex),
origin,
System.nanoTime() - start
)
);
}
}
throw ex;
} finally {
this.running.remove(marker);
}
}

private static String getExceptionOrigin(final Throwable exc) {
final StackTraceElement[] traces = exc.getStackTrace();
String res = "somewhere";
if (traces.length > 0) {
res = MethodLogger.oneText(traces[0]);
}
return res;
}

/**
* Has time for method execution passed.
* @param annotation Loggable annotation.
Expand Down
8 changes: 6 additions & 2 deletions src/main/java/com/jcabi/aspects/aj/MethodValidator.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@
*
* <p>The class is thread-safe.
*
* @since 0.1.10
* @see <a href="http://beanvalidation.org/1.0/spec/#appendix-methodlevelvalidation">Appendix C</a>
* @see <a href="http://aspects.jcabi.com/jsr-303.html">How it works</a>
* @since 0.1.10
*/
@Aspect
@SuppressWarnings({ "PMD.CyclomaticComplexity", "PMD.TooManyMethods" })
Expand Down Expand Up @@ -73,7 +73,11 @@ public void beforeMethod(final JoinPoint point) {
* @param point Join point
* @checkstyle LineLength (3 lines)
*/
@Before("preinitialization(*.new(.., @(javax.validation.* || javax.validation.constraints.*) (*), ..))")
@Before(
// @checkstyle StringLiteralsConcatenation (2 lines)
"preinitialization(*.new(.., @(javax.validation.* || javax.validation.constraints.*)"
+ " (*), ..))"
)
public void beforeCtor(final JoinPoint point) {
if (this.validator != null) {
@SuppressWarnings("unchecked")
Expand Down
3 changes: 2 additions & 1 deletion src/main/java/com/jcabi/aspects/aj/Parallelizer.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@
/**
* Execute method in multiple threads.
*
* @since 0.10
* @see Parallel
* @since 0.10
* @checkstyle NonStaticMethodCheck (100 lines)
*/
@Aspect
Expand All @@ -46,6 +46,7 @@ public final class Parallelizer {
* @checkstyle IllegalThrowsCheck (4 lines)
*/
@Around("execution(@com.jcabi.aspects.Parallel * * (..))")
@SuppressWarnings("PMD.CloseResource")
public Object wrap(final ProceedingJoinPoint point)
throws Parallelizer.ParallelException {
final int total = ((MethodSignature) point.getSignature())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
/**
* Logs all exceptions thrown out of a method and swallow exception.
*
* @since 0.1.10
* @see com.jcabi.aspects.LogExceptions
* @since 0.1.10
* @checkstyle IllegalThrows (100 lines)
* @checkstyle NonStaticMethodCheck (100 lines)
*/
Expand Down
Loading
Loading