Uploaded image for project: 'JBoss Enterprise Application Platform'
  1. JBoss Enterprise Application Platform
  2. JBEAP-21418

[GSS](7.3.z) WEJBHTTP-58 - Wildfly Http Client HttpServerHelper should log initial exception

XMLWordPrintable

      It looks like an exception is thrown when unmarshalling, this ends up with HttpServerHelper.sendException, the Throwable e is going to be sent back, but at line 45 setStatusCode results in UndertowMessages.MESSAGES.responseAlreadyStarted , we should have sendException log the original Throwable e in some way, so that it is not lost.

      There may also be a question of why undertow is saying that the response is already started

      ERROR [org.wildfly.httpclient.common] [] WFHTTP000006: Failed to write exception: java.lang.IllegalStateException: UT000002: The response has already been started
      	at io.undertow.core@2.0.30.SP4-redhat-00001//io.undertow.server.HttpServerExchange.setStatusCode(HttpServerExchange.java:1406)
      	at org.wildfly.http-client.common@1.0.22.Final-redhat-00001//org.wildfly.httpclient.common.HttpServerHelper.sendException(HttpServerHelper.java:45)
      	at org.wildfly.http-client.ejb@1.0.22.Final-redhat-00001//org.wildfly.httpclient.ejb.HttpInvocationHandler.writeException(HttpInvocationHandler.java:270)
      	at org.jboss.as.ejb3@7.2.9.GA-redhat-00003//org.jboss.as.ejb3.remote.AssociationImpl.receiveInvocationRequest(AssociationImpl.java:138)
      	at org.wildfly.http-client.ejb@1.0.22.Final-redhat-00001//org.wildfly.httpclient.ejb.HttpInvocationHandler.lambda$handleInternal(HttpInvocationHandler.java:135)
      	at org.jboss.threads@2.3.3.Final-redhat-00001//org.jboss.threads.ContextClassLoaderSavingRunnable.run(ContextClassLoaderSavingRunnable.java:35)
      	at org.jboss.threads@2.3.3.Final-redhat-00001//org.jboss.threads.EnhancedQueueExecutor.safeRun(EnhancedQueueExecutor.java:1982)
      	at org.jboss.threads@2.3.3.Final-redhat-00001//org.jboss.threads.EnhancedQueueExecutor$ThreadBody.doRunTask(EnhancedQueueExecutor.java:1486)
      	at org.jboss.threads@2.3.3.Final-redhat-00001//org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1377)
      	at java.base/java.lang.Thread.run(Thread.java:834)
      

      org.wildfly.httpclient.common.HttpServerHelper

       43     public static void sendException(HttpServerExchange exchange, int status, Throwable e) {
       44         try {
       45             exchange.setStatusCode(status);
       46             exchange.getResponseHeaders().put(Headers.CONTENT_TYPE, "application/x-wf-jbmar-exception;version=1");
       47             final MarshallingConfiguration marshallingConfiguration = new MarshallingConfiguration();
       48             marshallingConfiguration.setVersion(2);
       49             final Marshaller marshaller = RIVER_MARSHALLER_FACTORY.createMarshaller(marshallingConfiguration);
       50             OutputStream outputStream = exchange.getOutputStream();
       51             final ByteOutput byteOutput = Marshalling.createByteOutput(outputStream);
       52             // start the marshaller
       53             marshaller.start(byteOutput);
       54             marshaller.writeObject(e);
       55             marshaller.write(0);
       56             marshaller.finish();
       57             marshaller.flush();
       58             exchange.endExchange();
       59         } catch (Exception ex) {
       60             HttpClientMessages.MESSAGES.failedToWriteException(ex);
       61             exchange.endExchange();
       62         }
       63     }
      

      In this catch above we should some how also log the Throwable e


      org.jboss.as.ejb3.remote.AssociationImpl

      135         try {
      136             requestContent = invocationRequest.getRequestContent(classLoader);
      137         } catch (IOException | ClassNotFoundException e) {
      138             invocationRequest.writeException(new EJBException(e));
      139             return CancelHandle.NULL;
      140         } finally {
      141             WildFlySecurityManager.setCurrentContextClassLoaderPrivileged(originalTccl);
      142         }
      

      org.wildfly.httpclient.ejb.HttpInvocationHandler

      265                 @Override
      266                 public void writeException(@NotNull Exception exception) {
      267                     if(identifier != null) {
      268                         cancellationFlags.remove(identifier);
      269                     }
      270                     HttpServerHelper.sendException(exchange, StatusCodes.INTERNAL_SERVER_ERROR, exception);
      271                 }
      

      io.undertow.server.HttpServerExchange

      1400     public HttpServerExchange setStatusCode(final int statusCode) {
      1401         if (statusCode < 0 || statusCode > 999) {
      1402             throw new IllegalArgumentException("Invalid response code");
      1403         }
      1404         int oldVal = state;
      1405         if (allAreSet(oldVal, FLAG_RESPONSE_SENT)) {
      1406             throw UndertowMessages.MESSAGES.responseAlreadyStarted();
      1407         }
      

              mshikalw Moulali Shikalwadi
              rhn-support-bmaxwell Brad Maxwell
              Votes:
              0 Vote for this issue
              Watchers:
              10 Start watching this issue

                Created:
                Updated:
                Resolved: