Payara Server is an open source middleware platform that supports reliable and secure deployments of Java EE (Jakarta EE) and MicroProfile applications in any environment: on premise, in the cloud or hybrid.
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!
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!