Skip to content

UnmarshallerImpl has an ineffective finalize() method #978

@Tomas-Kraus

Description

@Tomas-Kraus

During upgrading a web service we observed that a the Parallel new garbage collector was unable to achieve the previously seen thoughput when running with JAXB 2.2.5+

On investigation it seems the reason for this is the addition of the finalize() method on UnmarshallerImpl, this causes the object not to be collected but to be placed to to the finalizer queue. This is problematic for two reasons

  • it increases the contention on the finalizer queue
  • The last unmarshalled object (a large WS response object in our case) is retained until the finalizer invokes the finalize() method

In addition, the implementation of the finalize() method:

protected void finalize() throws Throwable {
        try {
            ClassFactory.cleanCache();
        } finally {
            super.finalize();
        }
    }

is broken because the ClassFactory.cleanCache() method needs to be called in the same thread as the original use of the Unmarshaller, but this won't be true as it will be called the Finalizer thread.

Will be posting a patch to remove the method to the dev mailing list.

Affected Versions

[2.2.4u2, 2.2.5, 2.2.6, 2.2.7]

Metadata

Metadata

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions