MCPcopy Create free account
hub / github.com/apache/tomcat / upgrade

Method upgrade

java/org/apache/catalina/connector/Request.java:1894–1922  ·  view source on GitHub ↗
(Class<T> httpUpgradeHandlerClass)

Source from the content-addressed store, hash-verified

1892
1893
1894 @SuppressWarnings("unchecked")
1895 @Override
1896 public <T extends HttpUpgradeHandler> T upgrade(Class<T> httpUpgradeHandlerClass)
1897 throws IOException, ServletException {
1898 T handler;
1899 InstanceManager instanceManager = null;
1900 try {
1901 // Do not go through the instance manager for internal Tomcat classes since they don't
1902 // need injection
1903 if (InternalHttpUpgradeHandler.class.isAssignableFrom(httpUpgradeHandlerClass)) {
1904 handler = httpUpgradeHandlerClass.getConstructor().newInstance();
1905 } else {
1906 instanceManager = getContext().getInstanceManager();
1907 handler = (T) instanceManager.newInstance(httpUpgradeHandlerClass);
1908 }
1909 } catch (ReflectiveOperationException | NamingException | IllegalArgumentException | SecurityException e) {
1910 throw new ServletException(e);
1911 }
1912 UpgradeToken upgradeToken = new UpgradeToken(handler, getContext(), instanceManager,
1913 getUpgradeProtocolName(httpUpgradeHandlerClass));
1914
1915 coyoteRequest.action(ActionCode.UPGRADE, upgradeToken);
1916
1917 // Output required by RFC2616. Protocol specific headers should have
1918 // already been set.
1919 response.setStatus(HttpServletResponse.SC_SWITCHING_PROTOCOLS);
1920
1921 return handler;
1922 }
1923
1924
1925 private String getUpgradeProtocolName(Class<? extends HttpUpgradeHandler> httpUpgradeHandlerClass) {

Callers

nothing calls this directly

Calls 8

newInstanceMethod · 0.95
getContextMethod · 0.95
getInstanceManagerMethod · 0.65
actionMethod · 0.65
setStatusMethod · 0.65
isAssignableFromMethod · 0.45
getConstructorMethod · 0.45

Tested by

no test coverage detected