Log4j LogManager.getLogger gets stuck in an infinite loop

For some strange reason, I have a line of code that gets stuck in an infinite loop. This is the line:

this.logger = LogManager.getLogger(getClass().getName());

A small context may be useful:
I have a machine that stores all the code and java files .class. I access this device through sshfsand work directly with files .javathrough Eclipse.

If I log on to the remote computer and execute my class, the code runs:

$ ssh remote-machine
$ cd /path/to/eclipse-project
$ export CLASSPATH="..." # A bunch of required libraries, including
                         # log4j-api-2.0-beta7.jar and log4j-core-2.0-beta7.jar
$ java path.to.MyClass
Welcome, please do stuff
>>>

If I use the file system sshfsinstalled on my machine:

$ cd /mount-point/to/remote-machine
$ cd path/to/eclipse-project
$ export CLASSPATH="..."
$ java path.to.MyClass
<nothing happens>

I debugged through Eclipse what LogManager#getLoggeris the culprit. In fact, a little deeper, I saw that there is a cycle starting with index=2and ending only at class==null, at ClassLoaderContextSelector.java:86.

+1

Source: https://habr.com/ru/post/1672452/


All Articles