yuqi1129 opened a new issue, #13075:
URL: https://github.com/apache/gravitino/issues/13075
### Version
main branch and branch-1.3
### Describe what's wrong
Classloader cleanup can fail a catalog DISABLE request while inspecting an
unrelated thread. `runningWithClassLoader` uses `FieldUtils.readField(thread,
"target", true)`, which searches the thread's actual subclass before reaching
`Thread`. Reflecting on subclass fields can resolve an unavailable dependency
and throw `NoClassDefFoundError`. The cleanup guards only catch `Exception`, so
the error escapes.
A subclass declaring its own `target` field can also cause cleanup to
inspect the wrong runnable and misidentify thread ownership.
### Error message and/or stacktrace
`CatalogPaimonJdbcIT` failed during teardown in JDK17 deploy mode with
PostgreSQL:
```text
NoClassDefFoundError: org/apache/hadoop/security/SaslRpcClient
at java.lang.Class.getDeclaredFields0(Native Method)
at
org.apache.commons.lang3.reflect.FieldUtils.readField(FieldUtils.java:429)
at
org.apache.gravitino.utils.ClassLoaderResourceCleanerUtils.runningWithClassLoader(ClassLoaderResourceCleanerUtils.java:205)
at
org.apache.gravitino.catalog.lakehouse.paimon.PaimonCatalogOperations.close(PaimonCatalogOperations.java:567)
```
CI:
https://github.com/apache/gravitino/actions/runs/34427910247/job/102732403224
### How to reproduce
Load a `Thread` subclass through an isolated loader that cannot resolve one
of its field types. Give it a runnable owned by the loader being inspected,
clear its context classloader, and call `runningWithClassLoader`. Subclass
field reflection throws instead of identifying the runnable. This is reproduced
by a regression test against the current implementation.
### Additional context
The affected inspection was introduced in #12987 and backported to
branch-1.3 in #13028. Both branches contain the same implementation. Read the
field declared by `Thread` directly and tolerate `LinkageError` per thread
without swallowing fatal VM errors.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]