FISH-8736 Fix for Web Services Engine Inconsistently Starting #6786
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
Fixes the XML Web Services engine seemingly only starting inconsistently.
In the case that an application bundles its own version of Metro, the annotations that the Web Service Sniffer looks for will be detected by HK2 twice - once as an
AnnotationType
and once as anInterfaceModel
.Within HK2, both of these get stored in a Map of Maps with the same name (but in different maps). It’s a Map essentially indexed by the class name, but separated into separate Maps based on the model type (AnnotationType vs. InterfaceModel vs. EnumType etc.).
The
Types.getType(name)
method which we are invoking will simply return the first match found, and since this isn’t an ordered map it will not necessarily be consistent between runs. If it finds the entry in theInterfaceModel
map first the application doesn’t get detected as containing a web service, if the entry in theAnnotationType
map is found first it is.As the
Types
interface in HK2 doesn't provide a means of only searching through a map of a specific Type, I've reworked our integration to instead use theTypes.getAllTypes
method and filter the results.Important Info
Blockers
None
Testing
New tests
None
Testing Performed
Redeployed the customer application attached to the Jira issue 20 times - the web service sniffer correctly identifies as being required for the application.
The customer application requires that at the very least some dummy resources exist: see the Jira ticket for instructions, I've omitted them here for confidentiality (just in case).
Testing Environment
Windows 11, Zulu 11.
OpenSUSE Leap 15.6 WSL, Zulu 17.
Documentation
N/A
Notes for Reviewers
I haven't done any performance testing to determine if this is the most efficient way to search through the map of types, but I don't believe I've done anything particularly egregious. I don't believe that stream filter will iterate over the entire collection, it Should™ stop iterating once it's found the desired annotation. Without testing I don't know if it's quicker to collect all of the
AnnotationType
entries into a single list, and then iterate over it again searching for each of the desired annotation names - I suspect it depends on the same inconsistency of the collection ordering!