Can't serialize IdReferenceType due to non-transient Logger

Description

I can't serialize IdReferenceType using 1.0.0.M4-SNAPSHOT due to the non-transient Logger, e.g.:

java.io.NotSerializableException: org.ops4j.pax.logging.slf4j.Slf4jLogger
at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1180)[:1.7.0_15]

Environment

None

Activity

Show:
Florian Huonder
April 7, 2013, 7:55 AM

Hi Colm,

I just had a look at your patch and have a question.
The fields that you mark transient are static fields. In standard java serialization, static fields are ignored.
So why should they be marked transient?

Could you give me more context, or e.g. a Test-Case, so that I can see what the problem is?

Regards,
Florian

Colm O hEigeartaigh
April 8, 2013, 9:13 AM

Hi Florian,

I am in an OSGi environment. As you can see from the stacktrace, the container is replacing the SLF4J logger with a Pax Logging object:

java.io.NotSerializableException: org.ops4j.pax.logging.slf4j.Slf4jLogger
at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1180):1.7.0_15

Other classes use "transient" for the static Logger as well, for example "PolicyMarshaller".

Colm.

Florian Huonder
April 8, 2013, 9:59 AM
Edited

Hi Colm,

That's a little bit strange.
A static field is not intended to be transient.

The Java-Serialization-Mechanism ignores all static fields while serializing.
So in my opinion the cause of the problem is at another point.
I wrote a small test that serializes and deserializes the IdReferenceType without any problem

From my point of view it is also wrong when there are classes that have their logger static transient (e.g. in PolicyMarshaller).

What do you think?

Regards,
Florian

Colm O hEigeartaigh
April 8, 2013, 3:09 PM

Hi Florian,

It appears I may have been mistaken, and that the fix for has fixed the issue. Therefore, this issue can be resolved. Sorry for the noise...

Colm.

Florian Huonder
April 8, 2013, 3:15 PM

Hi Colm,

No matter.

Regards,
Florian

Assignee

Florian Huonder

Reporter

Colm O hEigeartaigh

Labels

None

Fix versions

Affects versions

Priority

Major
Configure