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

FISH-8736 Fix for Web Services Engine Inconsistently Starting #6786

Merged
merged 4 commits into from
Jul 5, 2024

Conversation

Pandrex247
Copy link
Member

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 an InterfaceModel.
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.).

/**
 * Storage indexed by TYPE : interface | class | annotation and then by name.
 */
private final ConcurrentMap<Class, ConcurrentMap<String, TypeProxy<Type>>> storage=
        new ConcurrentHashMap<Class, ConcurrentMap<String, TypeProxy<Type>>>();

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 the InterfaceModel map first the application doesn’t get detected as containing a web service, if the entry in the AnnotationType 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 the Types.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!

…all of them.

This covers cases where an application is bundling the annotation class itself. In such a case you will end up with both an
InterfaceType and an AnnotationType; Types.getType(String name) simply returns the first found which isn't consistent.

This code returns the first found, under the assumption that there should only be one match for an AnnotationType as
the underlying storage mechanism for types is Map<Type, Map<String, TypeProxy<Type>>>

Signed-off-by: Andrew Pielage <[email protected]>
Signed-off-by: Andrew Pielage <[email protected]>
@Pandrex247 Pandrex247 merged commit 7422408 into payara:master Jul 5, 2024
1 check passed
@Pandrex247 Pandrex247 deleted the FISH-8736 branch July 5, 2024 10:39
Pandrex247 added a commit to Pandrex247/Payara that referenced this pull request Aug 13, 2024
FISH-8736 Fix for Web Services Engine Inconsistently Starting
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants