Skip to content

Commit 14ba6dd

Browse files
AXIS2-6099 add some unit tests and better Wildfly dep verification
1 parent 161d0b1 commit 14ba6dd

File tree

1 file changed

+53
-18
lines changed

1 file changed

+53
-18
lines changed

modules/transport-h2/src/main/java/org/apache/axis2/transport/h2/integration/moshi/UndertowAxis2BufferIntegration.java

Lines changed: 53 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -93,37 +93,54 @@ private static class WildFlyResourceCache {
9393
"io.undertow.servlet.XnioWorker", // Test compatibility - current expected name
9494
"io.undertow.xnio.worker", // Alternative WildFly name
9595
"org.wildfly.undertow.worker", // WildFly-specific name
96-
"undertow.xnio.worker" // Generic name
96+
"undertow.xnio.worker", // Generic name
97+
"io.undertow.XnioWorker", // Capitalized version
98+
"org.xnio.XnioWorker", // Direct XNIO
99+
"undertow.worker", // Simple name
100+
"wildfly.undertow.xnio.worker" // WildFly 32 specific
97101
};
98102

99103
String[] poolNames = {
100104
"io.undertow.servlet.BufferPool", // Test compatibility - current expected name
101105
"io.undertow.buffer-pool", // Alternative WildFly name
102106
"org.wildfly.undertow.buffer.pool", // WildFly-specific name
103-
"undertow.buffer.pool" // Generic name
107+
"undertow.buffer.pool", // Generic name
108+
"io.undertow.BufferPool", // Capitalized version
109+
"org.xnio.Pool", // Direct XNIO
110+
"undertow.pool", // Simple name
111+
"wildfly.undertow.buffer.pool" // WildFly 32 specific
104112
};
105113

106-
// Search for XNIO Worker
114+
// Search for XNIO Worker with detailed logging
115+
log.info("WildFly HTTP/2 Integration: Searching for XNIO Worker in servlet context...");
107116
for (String name : workerNames) {
108117
Object attr = servletContext.getAttribute(name);
118+
log.info(" Checking attribute '" + name + "': " +
119+
(attr != null ? attr.getClass().getName() + " (found)" : "null (not found)"));
109120
if (attr instanceof XnioWorker) {
110121
worker = (XnioWorker) attr;
111122
discovery.append("Found XnioWorker at '").append(name).append("', ");
123+
log.info(" *** XNIO Worker FOUND at '" + name + "': " + attr.getClass().getName());
112124
break;
113125
}
114126
}
115127

116-
// Search for Buffer Pool
128+
// Search for Buffer Pool with detailed logging
129+
log.info("WildFly HTTP/2 Integration: Searching for Buffer Pool in servlet context...");
117130
for (String name : poolNames) {
118131
Object attr = servletContext.getAttribute(name);
132+
log.info(" Checking attribute '" + name + "': " +
133+
(attr != null ? attr.getClass().getName() + " (found)" : "null (not found)"));
119134
if (attr instanceof Pool) {
120135
try {
121136
@SuppressWarnings("unchecked")
122137
Pool<ByteBuffer> bufferPool = (Pool<ByteBuffer>) attr;
123138
pool = bufferPool;
124139
discovery.append("Found BufferPool at '").append(name).append("', ");
140+
log.info(" *** Buffer Pool FOUND at '" + name + "': " + attr.getClass().getName());
125141
break;
126142
} catch (ClassCastException e) {
143+
log.info(" Found Pool at '" + name + "' but not ByteBuffer pool: " + e.getMessage());
127144
// Not a ByteBuffer pool, continue searching
128145
}
129146
}
@@ -134,39 +151,57 @@ private static class WildFlyResourceCache {
134151
this.integrationAvailable = (worker != null && pool != null);
135152
this.discoveryLog = discovery.toString();
136153

137-
// Log discovery results once
154+
// Always log discovery results and enumerate attributes for debugging
138155
if (integrationAvailable) {
139-
log.info("WildFly integration available: " + discoveryLog);
156+
log.info("WildFly HTTP/2 integration AVAILABLE: " + discoveryLog +
157+
"Worker found: " + (worker != null ? worker.getClass().getName() : "null") +
158+
", Pool found: " + (pool != null ? pool.getClass().getName() : "null"));
140159
} else {
141-
log.debug("WildFly integration not available: " + discoveryLog +
142-
"Worker=" + (worker != null) + ", Pool=" + (pool != null));
160+
log.warn("WildFly HTTP/2 integration NOT AVAILABLE: " + discoveryLog +
161+
"Worker=" + (worker != null) + ", Pool=" + (pool != null) + " - Enumerating all servlet context attributes...");
143162

144-
// Debug: enumerate all servlet context attributes to help discover correct names
145-
if (log.isDebugEnabled()) {
146-
enumerateServletContextAttributes(servletContext);
147-
}
163+
// Always enumerate servlet context attributes when integration fails to help debug
164+
enumerateServletContextAttributes(servletContext);
148165
}
149166
}
150167

151168
/**
152169
* Debug helper: enumerate all servlet context attributes to discover WildFly's actual attribute names.
153-
* Only called when debug logging is enabled and integration fails.
170+
* Always called to help debug integration issues in production.
154171
*/
155172
private void enumerateServletContextAttributes(ServletContext servletContext) {
156173
try {
157174
java.util.Enumeration<String> attributeNames = servletContext.getAttributeNames();
158-
StringBuilder allAttrs = new StringBuilder("All servlet context attributes: ");
175+
StringBuilder allAttrs = new StringBuilder("WildFly ServletContext attribute discovery:\n");
159176

177+
int count = 0;
160178
while (attributeNames.hasMoreElements()) {
161179
String name = attributeNames.nextElement();
162180
Object value = servletContext.getAttribute(name);
163-
String className = (value != null) ? value.getClass().getSimpleName() : "null";
164-
allAttrs.append(name).append("=").append(className).append(", ");
181+
String className = (value != null) ? value.getClass().getName() : "null";
182+
String simpleClassName = (value != null) ? value.getClass().getSimpleName() : "null";
183+
184+
allAttrs.append(" [").append(++count).append("] '").append(name).append("' = ")
185+
.append(simpleClassName).append(" (").append(className).append(")\n");
186+
187+
// Log detailed info for potentially relevant attributes
188+
if (name.toLowerCase().contains("undertow") ||
189+
name.toLowerCase().contains("xnio") ||
190+
name.toLowerCase().contains("buffer") ||
191+
name.toLowerCase().contains("worker") ||
192+
(value != null && (value.getClass().getName().contains("xnio") ||
193+
value.getClass().getName().contains("undertow") ||
194+
value.getClass().getName().contains("Buffer") ||
195+
value.getClass().getName().contains("Worker")))) {
196+
allAttrs.append(" *** POTENTIALLY RELEVANT: ").append(name).append(" -> ").append(className).append("\n");
197+
}
165198
}
166199

167-
log.debug(allAttrs.toString());
200+
// Always log this information - it's critical for debugging
201+
log.warn("WildFly HTTP/2 Integration Debug - " + allAttrs.toString());
202+
168203
} catch (Exception e) {
169-
log.debug("Failed to enumerate servlet context attributes: " + e.getMessage());
204+
log.error("Failed to enumerate servlet context attributes for WildFly integration debug: " + e.getMessage(), e);
170205
}
171206
}
172207
}

0 commit comments

Comments
 (0)