killme2008 / xmemcached

High performance, easy to use multithreaded memcached client in java.
http://fnil.net/xmemcached
Apache License 2.0
757 stars 280 forks source link

Exception trace output from BaseSerializingTranscoder if Objects no more compatible #63

Closed adrianbader closed 7 years ago

adrianbader commented 7 years ago

If a retrieved object from cache is no more "compatible" with the current class in the running application, memcachedClient.get(..) does correctly return null but also prints an exeption trace like:

10:19:48,504 ERROR [net.rubyeye.xmemcached.transcoders.BaseSerializingTranscoder] (default task-110) Caught IOException decoding 8002 bytes of data: java.io.InvalidClassException: com.my.package.my.class; local class incompatible: stream classdesc serialVersionUID = 7737855311941045290, local class serialVersionUID = -351616861165941259
    at java.io.ObjectStreamClass.initNonProxy(ObjectStreamClass.java:616)
    at java.io.ObjectInputStream.readNonProxyDesc(ObjectInputStream.java:1630)
    at java.io.ObjectInputStream.readClassDesc(ObjectInputStream.java:1521)
    at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1781)
    at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1353)
    at java.io.ObjectInputStream.readObject(ObjectInputStream.java:373)
    at java.util.ArrayList.readObject(ArrayList.java:791)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at java.io.ObjectStreamClass.invokeReadObject(ObjectStreamClass.java:1058)
    at java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1909)
    at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1808)
    at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1353)
    at java.io.ObjectInputStream.readObject(ObjectInputStream.java:373)
    at net.rubyeye.xmemcached.transcoders.BaseSerializingTranscoder.deserialize(BaseSerializingTranscoder.java:112)
    at net.rubyeye.xmemcached.transcoders.SerializingTranscoder.decode0(SerializingTranscoder.java:98)
    at net.rubyeye.xmemcached.transcoders.SerializingTranscoder.decode(SerializingTranscoder.java:90)
    at net.rubyeye.xmemcached.XMemcachedClient.fetch0(XMemcachedClient.java:669)
    at net.rubyeye.xmemcached.XMemcachedClient.get0(XMemcachedClient.java:1072)
    at net.rubyeye.xmemcached.XMemcachedClient.get(XMemcachedClient.java:1030)
    at net.rubyeye.xmemcached.XMemcachedClient.get(XMemcachedClient.java:1041)
    at net.rubyeye.xmemcached.XMemcachedClient.get(XMemcachedClient.java:1063)
    at xx.xx.CacheService.cacheGet(CacheService.java:1052)

There is no exception thrown to my code so that I could catch it around memcachedClient.get(..). This output comes from the client itself. How can I disable this?

I already have the following in my log4j.xml Configuration:

<Configuration >
    <Properties>
        <Property name="log4j.logger.net.rubyeye.xmemcached">false</Property>
        <Property name="log4j.logger.com.google.code.yanf4j">false</Property>
    </Properties>
...
</Configuration>

Edit: fixed styling.

killme2008 commented 7 years ago

Tried

https://stackoverflow.com/questions/25156812/turn-off-debug-or-log-messages-in-log4j-xml

adrianbader commented 7 years ago

Hmm, it is strange. I use Log4J2. The log4j2.xml looks now as attached. (-> renamed it to .txt here because .xml is not accepted).

    <Loggers>
        <Logger name="net.rubyeye.xmemcached.transcoders.BaseSerializingTranscoder" level="OFF"
                additivity="false">
            <Appender-ref ref="ConsoleAppender" level="OFF" />
        </Logger>
        <Root level="INFO">
            <AppenderRef ref="DatabaseAppender"/>
            <AppenderRef ref="ConsoleAppender"/>
        </Root>
    </Loggers>

But BaseSerializingTranscoder does still log errors. The following test shows the problem:

org.slf4j.Logger logger1 = LoggerFactory.getLogger(BaseSerializingTranscoder.class);
logger1.error("log test the same was as in memcachedclient");

org.apache.logging.log4j.Logger logger2 = LogManager.getLogger(BaseSerializingTranscoder.class);
logger2.error("log test with log4j ");

This outputs the first error. Doesn't this show that slf4j (as you use) does ignore my whole Log4j config? What can I do?

log4j2.txt

killme2008 commented 7 years ago

I am sorry ,i am not familiar with log4j configuration. Maybe you can ask the question on stackoverflow. Maybe you can try change OFF to lowercase off.

adrianbader commented 7 years ago

Thanks for your tipp. I already placed a question: https://stackoverflow.com/questions/46365134/slf4j-in-library-seems-to-ignore-my-log4j2-configuration

It seems to become hard...

One possibility to solve this is, if you would implement a method on memcachedclient to disable logging at all and depending on this, do no more logging. :)

killme2008 commented 7 years ago

Of course i can ,but i think disabling log4j package level logging is a better choice.

2017-09-22 21:57 GMT+08:00 adrianbader notifications@github.com:

Thanks for your tipp. I already placed a question: https://stackoverflow.com/questions/46365134/slf4j-in- library-seems-to-ignore-my-log4j2-configuration

It seems to become hard...

One possibility to solve this is, if you would implement a method on memcachedclient to disable logging at all and depending on this, do no more logging. :)

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/killme2008/xmemcached/issues/63#issuecomment-331454175, or mute the thread https://github.com/notifications/unsubscribe-auth/AAA3Pm-iYr3Q3xnnQvZTY3NDt7_6ijjyks5sk7zAgaJpZM4PgYxk .

-- 庄晓丹 Email: killme2008@gmail.com Site: http://fnil.net

不学习,毋宁死

adrianbader commented 7 years ago

With the help of Stackoverflow [https://stackoverflow.com/q/46365134/4106030] I was able to get a solution. The problem was that Wildfly includes implizitely log4j -> so over slf4J, this log4j with its config was taken; therefore, the own config has been ignored.