apache / incubator-fury

A blazingly fast multi-language serialization framework powered by JIT and zero-copy.

Home Page:https://fury.apache.org/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[Java] Cannot disable logging with ThreadSafeFury in native-image

alessiodf opened this issue · comments

Search before asking

  • I had searched in the issues and found no similar issues.

Version

Version: 0.5.0 (built from source)
OS: macOS
JDK: 22

After following the GraalVM guide by using a static class field for native-image compilation, I was able to disable logging with LoggerFactory.disableLogging() if a using a Fury. However, logging is not disabled if a ThreadSafeFury is used instead.

Component(s)

Java

Minimal reproduce step

import org.apache.fury.Fury;
import org.apache.fury.ThreadSafeFury;
import org.apache.fury.logging.LoggerFactory;
public class Main {
    static ThreadSafeFury fury;
    static {
        LoggerFactory.disableLogging();
        fury = new ThreadLocalFury(classLoader -> {
            return Fury.builder().build();
        });
        // Also tried: fury = Fury.builder().buildThreadSafeFury();
    }
    public static void main(String[] args) {
        fury.serialize(Main.class);
    }
}

What did you expect to see?

No output

What did you see instead?

2024-04-21 05:33:31 INFO Fury:144 [main] - Created new fury org.apache.fury.Fury@50c4ee77

Anything Else?

Correct behaviour is observed in the JVM with a ThreadSafeFury, i.e. when not compiled with native-image. Similarly, correct behaviour is observed in both the JVM and native-image when using a Fury instead of a ThreadSafeFury.

Are you willing to submit a PR?

  • I'm willing to submit a PR!

Hi @alessiodf , I tested it locally, I think maybe you init some classes at build time by accident. And those classes init Fury first without disable Logging

This is my test code, no logs are printed.
image
image