XMLFilter cannot be overridden cleanly due to mime type clash

Issue #361 resolved
Former user created an issue

Original issue 361 created by tol... on 2013-08-15T23:23:59.000Z:

If I want to subclass XMLFilter and use a different MIME type, things don't quite work out. The XMLFilter constructor hard-codes MimeTypeMapper.XML_MIME_TYPE as the mime type for resources created by the filter. But the encoderManager uses the subclass's getMimeType() to create the encoder mapping. This mismatch can result in un-encoded output in target files.

I suggest adding a constructor for subclasses that accepts the overridden mime type. Patch will be attached. An allternate approach would be to hard-code MimeTypeMapper.XML_MIME_TYPE in getEncoderManager. But the first seems more correct to me.

Comments (7)

  1. Former user Account Deleted

    Comment 4. originally posted by @ysavourel on 2013-08-17T09:49:00.000Z:

    public XMLFilter () {
    super(false, getMimeType(), IProcessor.DC_ALL);
    }
    Was obviously a dumb idea (too early in the morning...). Never mind.

    Andrew: The problem with using a constructor with a parameter is that I don't think it'll work with the dynamic creation we use in the Filter configuration mapper. But maybe that is not an issue for you.

    But I cannot think of any other way.

  2. Former user Account Deleted

    Comment 7. originally posted by tol... on 2013-08-26T19:49:16.000Z:

    Sorry for the late reply...

    I don't think this would be a problem for dynamic creation, since the constructor is protected and thus only for use by subclasses, which themselves can offer a no-arg constructor. Thanks for committing!

  3. Log in to comment