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

NamedFactory uses wrong filter expression #582

Closed
tomaswolf opened this issue Aug 14, 2024 · 0 comments · Fixed by #583
Closed

NamedFactory uses wrong filter expression #582

tomaswolf opened this issue Aug 14, 2024 · 0 comments · Fixed by #583
Assignees
Labels
bug An issue describing a bug in the code
Milestone

Comments

@tomaswolf
Copy link
Member

tomaswolf commented Aug 14, 2024

Version

2.14.0-SNAPSHOT

Bug description

Split off from #525:

The implementations of NamedFactory.setupBuiltinFactories() and NamedFactory.setupTransformedFactories() use incorrect filter expressions to filter out algorithms not supported by the platform.

They use the expression ignoreUnsupported || f.isSupported() and expect that to be true for supported factories, and false for unsupported ones.

However, that is not correct. The parameter ignoreUnsupported actually implements the semantics of "include unsupported".

This needs to be fixed. The correct expression would be ignoreUnsupported ? f.isSupported() : true, or !ignoreUnsupported || f.isSupported().

This bug exists in the code since 2015.

Actual behavior

NamedFactory.setupBuiltinFactories(true, ...) includes factories for unsupported algorithms in the returned list.

Expected behavior

NamedFactory.setupBuiltinFactories(true, ...) includes only factories for supported algorithms in the returned list.

Relevant log output

No response

Other information

No response

@tomaswolf tomaswolf self-assigned this Aug 14, 2024
@tomaswolf tomaswolf added the bug An issue describing a bug in the code label Aug 14, 2024
@tomaswolf tomaswolf added this to the 2.14.0 milestone Aug 14, 2024
tomaswolf added a commit to tomaswolf/mina-sshd that referenced this issue Aug 14, 2024
Also give the methods some javadoc.

Note that "ignoreUnsupported ? f.isSupported : true" is the same as
"!ignoreUnsupported || f.isSupported()", but I find the former easier
to read and understand.

Bug: apache#582
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug An issue describing a bug in the code
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant