Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

com.thoughtworks.xstream.core.util is not exported in OSGI manifest #347

Open
laeubi opened this issue Sep 30, 2023 · 2 comments
Open

com.thoughtworks.xstream.core.util is not exported in OSGI manifest #347

laeubi opened this issue Sep 30, 2023 · 2 comments
Assignees
Labels

Comments

@laeubi
Copy link

laeubi commented Sep 30, 2023

com.thoughtworks.xstream.io.xml.PrettyPrintWriter uses com.thoughtworks.xstream.core.util.QuickWriter in the method:

PrettyPrintWriter#writeText but this type is not exported in the OSGi Manifest so one can't use this type in client code.

I'm using the latest release from here:
https://mvnrepository.com/artifact/com.thoughtworks.xstream/xstream

it seems it is explicitly removed from export here:

<bundle.export.package>!com.thoughtworks.xstream.core.util,com.thoughtworks.xstream.*;-noimport:=true</bundle.export.package>

but I wonder what is the purpose of that?

Instead of experting the package, it mit be possible to have some abstraction or move QuickWriter to the com.thoughtworks.xstream.io.xml package...

@joehni joehni self-assigned this Oct 24, 2023
@joehni
Copy link
Member

joehni commented Oct 24, 2023

Yes, that package is for private use and does not provide any API stability. So, what's your use case for QuickWriter apart from the fact that it is in a protected method?

@laeubi
Copy link
Author

laeubi commented Oct 25, 2023

If it is private I think it should only be used in private methods as otherwise it can drip into user-code anyways.
I'm currently using it to add a CDATA section into the emitted XML code like this:

CompactWriter compactWriter = new CompactWriter(writer) {
    boolean cdata = false;

    @Override
    public void startNode(String name, @SuppressWarnings("rawtypes") Class clazz) {
        super.startNode(name, clazz);
        cdata = name.equals("sectionText");
    }

    @Override
    protected void writeText(QuickWriter writer, String text) {
        if (cdata) {
            writer.write("<![CDATA[");
            writer.write(text);
            writer.write("]]>");
        } else {
            super.writeText(writer, text);
        }
    }
};

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants