Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
58 commits
Select commit Hold shift + click to select a range
9f9c8c3
Add test: testExecute3OnHandleException
mercyblitz Feb 26, 2026
1547458
Add abstract parameterized LoggingTest
mercyblitz Feb 26, 2026
c00043c
Make ShutdownHookCallbacksThreadTest extend LoggingTest
mercyblitz Feb 26, 2026
6614752
Have test class extend LoggingTest
mercyblitz Feb 26, 2026
22f05dc
Extend ArtifactDetectorTest with LoggingTest
mercyblitz Feb 26, 2026
226fd8b
Guard trace logging with isTraceEnabled check
mercyblitz Feb 26, 2026
f7d89a6
Make JarUtilsTest extend LoggingTest
mercyblitz Feb 26, 2026
7ced9ea
Guard trace logs with isTraceEnabled checks
mercyblitz Feb 26, 2026
ed84b26
Make ClassUtilsTest extend LoggingTest
mercyblitz Feb 26, 2026
78dac16
Guard logger.trace with isTraceEnabled()
mercyblitz Feb 26, 2026
1049f2e
Make FieldUtilsTest extend LoggingTest
mercyblitz Feb 26, 2026
635ed52
Guard trace logging with isTraceEnabled
mercyblitz Feb 26, 2026
420dc40
Guard trace logs with isTraceEnabled()
mercyblitz Feb 26, 2026
ac64d1d
Extend resolver test with LoggingTest
mercyblitz Feb 26, 2026
8482399
Convert Loggable to interface; update tests
mercyblitz Feb 26, 2026
26b214c
Guard trace logging with isTraceEnabled
mercyblitz Feb 26, 2026
61cfb74
Guard trace logging with isTraceEnabled
mercyblitz Feb 26, 2026
26aa1da
Make IOUtilsTest extend LoggingTest
mercyblitz Feb 26, 2026
e2bd8ae
Guard trace logs with isTraceEnabled
mercyblitz Feb 26, 2026
c7d2163
Make StandardFileWatchServiceTest extend LoggingTest
mercyblitz Feb 26, 2026
1f2f4be
Guard trace logging with isTraceEnabled
mercyblitz Feb 26, 2026
aa2e719
Make test extend LoggingTest
mercyblitz Feb 26, 2026
5f51bf8
Guard trace log with isTraceEnabled
mercyblitz Feb 26, 2026
5b8a0d6
Make URLUtilsTest extend LoggingTest
mercyblitz Feb 26, 2026
1089014
Guard trace logging with isTraceEnabled
mercyblitz Feb 26, 2026
96e03aa
Make ClassicProcessIdResolverTest extend LoggingTest
mercyblitz Feb 26, 2026
2850982
Guard trace logging with isTraceEnabled
mercyblitz Feb 26, 2026
ef201f9
Extend ModernProcessIdResolverTest with LoggingTest
mercyblitz Feb 26, 2026
62ee6a3
Guard trace logging with isTraceEnabled()
mercyblitz Feb 26, 2026
d2bba53
Make ProcessExecutorTest extend LoggingTest
mercyblitz Feb 26, 2026
f7d5611
Guard trace logging with isTraceEnabled
mercyblitz Feb 26, 2026
2c6e3e1
Make VM process test extend LoggingTest
mercyblitz Feb 26, 2026
4cd9b50
Add addIfAbsent to ListUtils
mercyblitz Feb 26, 2026
72b5028
Add test for ListUtils.addIfAbsent
mercyblitz Feb 26, 2026
28c3398
Use addIfAbsent and length util in TypeFinder
mercyblitz Feb 26, 2026
cf531eb
Add tests for TypeFinder.getSuperTypes
mercyblitz Feb 26, 2026
db49d6b
Add tests for generic type helpers
mercyblitz Feb 26, 2026
6d572b2
Update FieldUtils.java
mercyblitz Feb 27, 2026
42f38c3
Use handleFieldException in FieldUtilsTest
mercyblitz Feb 27, 2026
9507cf4
Test JSONArray(JSONTokener) constructor
mercyblitz Feb 27, 2026
1b42d00
Remove redundant 'this.' in recursive scan call
mercyblitz Feb 27, 2026
d6ee1e6
Add tests for scanning empty directory and file
mercyblitz Feb 27, 2026
55f94b1
Add StackWalker & MethodHandle caller lookup
mercyblitz Mar 1, 2026
f4b3788
Enhance ReflectionUtilsTest for StackWalker
mercyblitz Mar 1, 2026
b93bf24
Refactor ReflectionUtils benchmark methods
mercyblitz Mar 1, 2026
550f41c
Make getCallerClass robust to large frames
mercyblitz Mar 1, 2026
fd6b000
Increase StackWalker depth and adjust caller offset
mercyblitz Mar 1, 2026
2f7daf2
Remove StackWalker logic from StackTraceUtils
mercyblitz Mar 1, 2026
afceab2
Reduce StackTraceUtilsTest to test getStackTrace
mercyblitz Mar 1, 2026
4cc004a
Remove StackTraceElementUtilsBenchmark test
mercyblitz Mar 1, 2026
54bb2ae
Add stack-trace based caller lookup utilities
mercyblitz Mar 1, 2026
46fcf6a
Add tests for StackTraceUtils caller methods
mercyblitz Mar 1, 2026
55b88a7
Refactor caller-class stack frame offsets
mercyblitz Mar 2, 2026
912807a
Use StackTraceUtils static import in benchmark
mercyblitz Mar 2, 2026
8a285d0
Use stack-trace caller lookup and increment frame
mercyblitz Mar 2, 2026
570c446
Increase caller depth in ClassLoaderUtils
mercyblitz Mar 2, 2026
da25f26
Add SecurityUtils and tests
mercyblitz Mar 2, 2026
3d2a2fa
Add class-load test policy granting AllPermission
mercyblitz Mar 2, 2026
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
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,9 @@ Artifact resolveArtifactMetaInfoInManifest(Manifest manifest, URL resourceURL) {
}
String version = resolveVersion(mainAttributes);
Artifact artifact = create(artifactId, version, resourceURL);
logger.trace("The artifactId was resolved from the resource URL['{}']: {}", artifactId, artifact);
if (logger.isTraceEnabled()) {
logger.trace("The artifactId was resolved from the resource URL['{}']: {}", artifactId, artifact);
}
return artifact;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,9 @@ public final Artifact resolve(URL resourceURL) {
Artifact artifact = null;
try {
if (archiveFile == null) {
logger.trace("The resourceURL['{}'] can't be resolved to be an archive file", resourceURL);
if (logger.isTraceEnabled()) {
logger.trace("The resourceURL['{}'] can't be resolved to be an archive file", resourceURL);
}
artifactMetadataData = readArtifactMetadataDataFromResource(resourceURL, classLoader);
} else {
artifactMetadataData = readArtifactMetadataDataFromArchiveFile(archiveFile);
Expand Down Expand Up @@ -149,7 +151,9 @@ protected InputStream readArtifactMetadataDataFromFile(File archiveFile) throws
JarFile jarFile = new JarFile(archiveFile);
JarEntry jarEntry = findArtifactMetadataEntry(jarFile);
if (jarEntry == null) {
logger.trace("The artifact metadata entry can't be resolved from the JarFile[path: '{}']", archiveFile);
if (logger.isTraceEnabled()) {
logger.trace("The artifact metadata entry can't be resolved from the JarFile[path: '{}']", archiveFile);
}
return null;
}
return jarFile.getInputStream(jarEntry);
Expand All @@ -159,7 +163,9 @@ protected InputStream readArtifactMetadataDataFromFile(File archiveFile) throws
protected InputStream readArtifactMetadataDataFromDirectory(File directory) throws IOException {
File artifactMetadataFile = findArtifactMetadata(directory);
if (artifactMetadataFile == null) {
logger.trace("The artifact metadata file can't be found in the directory[path: '{}']", directory);
if (logger.isTraceEnabled()) {
logger.trace("The artifact metadata file can't be found in the directory[path: '{}']", directory);
}
return null;
}
return new FileInputStream(artifactMetadataFile);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -668,6 +668,10 @@ public static <T> void forEach(List<T> values, Consumer<T> consumer) {
forEach(values, (i, e) -> consumer.accept(e));
}

public static <T> boolean addIfAbsent(List<T> values, T newValue) {
return values.contains(newValue) ? false : values.add(newValue);
}

private ListUtils() {
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,9 @@ public static boolean shutdown(ExecutorService executorService) {
if (!executorService.isShutdown()) {
executorService.shutdown();
}
logger.trace("The ExecutorService({}) has been shutdown", executorService);
if (logger.isTraceEnabled()) {
logger.trace("The ExecutorService({}) has been shutdown", executorService);
}
return true;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -367,7 +367,9 @@ public static int copy(InputStream in, OutputStream out) throws IOException {
byteCount += bytesRead;
}
out.flush();
logger.trace("Copied {} bytes[buffer size : {}] from InputStream[{}] to OutputStream[{}]", byteCount, BUFFER_SIZE, in, out);
if (logger.isTraceEnabled()) {
logger.trace("Copied {} bytes[buffer size : {}] from InputStream[{}] to OutputStream[{}]", byteCount, BUFFER_SIZE, in, out);
}
return byteCount;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,9 @@ private void dispatchFileChangedEvent(Path filePath, WatchEvent.Kind watchEventK
Kind kind = toKind(watchEventKind);
FileChangedEvent fileChangedEvent = new FileChangedEvent(file, kind);
eventDispatcher.dispatch(fileChangedEvent);
logger.trace("The {} was dispatched", fileChangedEvent);
if (logger.isTraceEnabled()) {
logger.trace("The {} was dispatched", fileChangedEvent);
}
}

private void registerDirectoriesToWatchService(WatchService watchService) throws Exception {
Expand All @@ -254,8 +256,10 @@ private void registerDirectoriesToWatchService(WatchService watchService) throws
FileChangedMetadata metadata = entry.getValue();
WatchEvent.Kind[] kinds = metadata.watchEventKinds;
directoryPath.register(watchService, kinds);
logger.trace("The directory[path : '{}' , event kinds : {}] registers the WatchService : {}",
directoryPath, arrayToString(kinds), watchService);
if (logger.isTraceEnabled()) {
logger.trace("The directory[path : '{}' , event kinds : {}] registers the WatchService : {}",
directoryPath, arrayToString(kinds), watchService);
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ public Set<File> scan(File rootDirectory, boolean recursive, IOFileFilter ioFile
filesSet.add(subFile);
}
if (recursive && subFile.isDirectory()) {
filesSet.addAll(this.scan(subFile, recursive, ioFileFilter));
filesSet.addAll(scan(subFile, recursive, ioFileFilter));
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,9 @@ URLStreamHandler createURLStreamHandler(Field defaultFactoryField, String protoc

URLStreamHandler createURLStreamHandlerFromDefaultFactory(Field defaultFactoryField, String protocol) {
if (defaultFactoryField == null) {
logger.trace("The 'defaultFactory' field can't be found in the class URL.");
if (logger.isTraceEnabled()) {
logger.trace("The 'defaultFactory' field can't be found in the class URL.");
}
return null;
}
URLStreamHandlerFactory factory = getStaticFieldValue(defaultFactoryField);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1184,7 +1184,9 @@ public static String resolveProtocol(String url) {
}
for (int i = 0; i <= indexOfColon; i++) {
if (isWhitespace(url.charAt(i))) {
logger.trace("The protocol content should not contain the whitespace[url : '{}' , index : {}]", url, i);
if (logger.isTraceEnabled()) {
logger.trace("The protocol content should not contain the whitespace[url : '{}' , index : {}]", url, i);
}
return null;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,9 @@ public boolean supports() {
@Override
public Long current() {
Long processId = valueOf(processIdValue);
logger.trace("The PID was resolved from the method 'java.lang.management.RuntimeMXBean#getName()' = {} : {}", runtimeName, processId);
if (logger.isTraceEnabled()) {
logger.trace("The PID was resolved from the method 'java.lang.management.RuntimeMXBean#getName()' = {} : {}", runtimeName, processId);
}
return processId;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,9 @@ public boolean supports() {
public Long current() {
Object processHandle = invokeStaticMethod(PROCESS_HANDLE_CLASS, "current");
Long pid = invokeMethod(processHandle, PROCESS_HANDLE_CLASS, "pid");
logger.trace("The PID was resolved from the method 'java.lang.ProcessHandle#pid()' : {}", pid);
if (logger.isTraceEnabled()) {
logger.trace("The PID was resolved from the method 'java.lang.ProcessHandle#pid()' : {}", pid);
}
return pid;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,9 @@ public void execute(OutputStream outputStream, long timeout, TimeUnit timeUnit)
}
} finally {
processManager.removeUnfinishedProcess(process, options);
logger.trace("The command['{}'] is executed with exit value : {}", commandLine, exitValue);
if (logger.isTraceEnabled()) {
logger.trace("The command['{}'] is executed with exit value : {}", commandLine, exitValue);
}
}
return targetOutputStream.toByteArray();
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,9 @@ public Long current() {
RuntimeMXBean runtimeMXBean = getRuntimeMXBean();
Object jvm = getFieldValue(runtimeMXBean, JVM_FIELD);
Integer processId = invokeMethod(jvm, GET_PROCESS_ID_METHOD_NAME);
logger.trace("The PID was resolved from the native method 'sun.management.VMManagementImpl#getProcessId()' : {}", processId);
if (logger.isTraceEnabled()) {
logger.trace("The PID was resolved from the native method 'sun.management.VMManagementImpl#getProcessId()' : {}", processId);
}
return valueOf(processId.longValue());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,9 @@ public static Field findField(Class<?> klass, String fieldName) {
// ignore, try the super class
field = findField(klass.getSuperclass(), fieldName);
}
logger.trace("To find the field[name :'{}'] from the class : '{}'", fieldName, klass);
if (logger.isTraceEnabled()) {
logger.trace("To find the field[name :'{}'] from the class : '{}'", fieldName, klass);
}
return field;
}

Expand Down Expand Up @@ -507,8 +509,6 @@ public static <V> V getFieldValue(Object instance, String fieldName, Class<V> fi
* @param instance The object instance from which to retrieve the field value
* @param field The {@link Field} object representing the field to retrieve
* @return The value of the field if found and accessible; otherwise, {@code null}
* @throws IllegalStateException if this Field object is enforcing Java language access control and the underlying
* field is inaccessible
* @throws IllegalArgumentException if the specified object is not an instance of the class or interface declaring
* the underlying field (or a subclass or implementor thereof)
*/
Expand All @@ -523,10 +523,9 @@ public static <V> V getFieldValue(Object instance, Field field) throws IllegalSt
try {
accessible = trySetAccessible(field);
fieldValue = (V) field.get(instance);
} catch (IllegalAccessException e) {
handleIllegalAccessException(e, instance, field, accessible);
} catch (IllegalArgumentException e) {
handleIllegalArgumentException(e, instance, field);
} catch (IllegalAccessException | IllegalArgumentException e) {
handleFieldException(e, instance, field);
throw new IllegalArgumentException(e);
}

return fieldValue;
Expand Down Expand Up @@ -610,7 +609,6 @@ public static <V> V setFieldValue(Object instance, String fieldName, V value) th
* @param field The {@link Field} object representing the field to modify
* @param value The new value to assign to the field
* @return The previous value of the field before modification, or {@code null} if the field was not found or inaccessible
* @throws IllegalStateException If this Field object is enforcing Java language access control and the underlying field is inaccessible
* @throws IllegalArgumentException If the specified object is not an instance of the class or interface declaring the underlying field
*/
@Nullable
Expand All @@ -620,17 +618,15 @@ public static <V> V setFieldValue(Object instance, Field field, V value) throws
}

V previousValue = null;
boolean accessible = false;
try {
accessible = trySetAccessible(field);
trySetAccessible(field);
previousValue = (V) field.get(instance);
if (!Objects.equals(previousValue, value)) {
field.set(instance, value);
}
} catch (IllegalAccessException e) {
handleIllegalAccessException(e, instance, field, accessible);
} catch (IllegalArgumentException e) {
handleIllegalArgumentException(e, instance, field);
} catch (IllegalAccessException | IllegalArgumentException e) {
handleFieldException(e, instance, field);
throw new IllegalArgumentException(e);
}

return previousValue;
Expand Down Expand Up @@ -679,18 +675,11 @@ public static void assertFieldMatchType(Object instance, String fieldName, Class
}
}

static void handleIllegalAccessException(IllegalAccessException e, Object instance, Field field, boolean accessible) {
String errorMessage = format("The instance [object : {} , class : {} ] can't access the field[name : '{}' , type : {} , accessible : {}]",
instance, getTypeName(instance.getClass()), field.getName(), getTypeName(field.getType()), accessible);
logger.trace(errorMessage);
throw new IllegalStateException(errorMessage, e);
}

static void handleIllegalArgumentException(IllegalArgumentException e, Object instance, Field field) {
String errorMessage = format("The instance[object : {} , class : {}] can't match the field[name : '{}' , type : {}]",
instance, getTypeName(instance.getClass()), field.getName(), getTypeName(field.getType()));
logger.trace(errorMessage);
throw new IllegalArgumentException(errorMessage, e);
static void handleFieldException(Exception e, Object instance, Field field) {
if (logger.isTraceEnabled()) {
logger.trace("The instance[object : {} , class : {}] can't match the field[name : '{}' , type : {}]",
instance, getTypeName(instance.getClass()), field.getName(), getTypeName(field.getType()), e);
}
}

private FieldUtils() {
Expand Down
Loading