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

IllegalArgumentException when serialising Profile elements using Boolean #6

Closed
bradh opened this issue Sep 25, 2021 · 4 comments
Closed
Assignees
Labels
bug Something isn't working

Comments

@bradh
Copy link
Contributor

bradh commented Sep 25, 2021

Describe the bug

When serialising out a Profile with boolean values set, I get an IllegalArgumentException:

Exception in thread "main" java.lang.IllegalArgumentException: Class 'java.lang.Boolean' does not represent a Metaschema definition since it is missing a 'gov.nist.secauto.metaschema.binding.model.annotations.MetaschemaAssembly' or 'gov.nist.secauto.metaschema.binding.model.annotations.MetaschemaField' annotation.

Who is the bug affecting?

What is affected by this bug?

Breaks profile creation with Merge::setAsIs() and Import::setIncludeAll() calls.

When does this occur?

On serialisation.

How do we replicate the issue?

  1. Serialise out a Merge.

Expected behavior (i.e. solution)

Should serialise out cleanly.

Other Comments

{Add any other context about the problem here.}

@bradh bradh added the bug Something isn't working label Sep 25, 2021
@bradh
Copy link
Contributor Author

bradh commented Sep 25, 2021

Unit test to reproduce:

    @Test
    public void testSerialiseMerge(@TempDir Path tempDir) throws IOException, BindingException {
        File out = new File(tempDir.toFile(), "boolean.xml");
        MutableConfiguration config
                = new MutableConfiguration().enableFeature(Feature.SERIALIZE_ROOT);
        Profile profile = new Profile();
        LinkedList<Import> imports = new LinkedList<>();
        Import imp = new Import();
        imp.setIncludeAll(Boolean.TRUE);
        imports.add(imp);
        profile.setImports(imports);
        BindingContext context = BindingContext.newInstance();
        Serializer<Profile> serializer = context.newSerializer(Format.XML, Profile.class, config);
        serializer.serialize(profile, out);
    }

Produces:

java.lang.IllegalArgumentException: Class 'java.lang.Boolean' does not represent a Metaschema definition since it is missing a 'gov.nist.secauto.metaschema.binding.model.annotations.MetaschemaAssembly' or 'gov.nist.secauto.metaschema.binding.model.annotations.MetaschemaField' annotation.
	at gov.nist.secauto.oscal.java.BooleanSerialiseTest.testSerialiseMerge(BooleanSerialiseTest.java:65)

@bradh
Copy link
Contributor Author

bradh commented Sep 26, 2021

I couldn't reproduce the problem with Merge. Possibly only happens on the Import case, but I don't know why, or have a fix identified.

@david-waltermire
Copy link
Collaborator

@bradh Can you provide the boolean.xml used in the unit test above?

@david-waltermire
Copy link
Collaborator

This issue has been addressed by #7.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants