Remote Agent fails to connect to Bamboo if compression is enabled for text/plain

XMLWordPrintable

    • Type: Bug
    • Resolution: Fixed
    • Priority: High
    • 9.2.7, 9.3.5, 9.4.1
    • Affects Version/s: 9.4.0
    • Component/s: Agents
    • None
    • 1
    • Severity 2 - Major

      Problem

      Whenever a Remote Agent tries to connect to the Bamboo server, the connection fails with an error:

      org.apache.http.ConnectionClosedException: Premature end of Content-Length delimited message body (expected: 5.001; received: 42) 

      Environment

      • Bamboo 9.4.0 (not reproducible on 9.3.x and earlier)
      • Remote Agents, possibly ephemeral
      • HTTP compression is enabled on the Bamboo Server or Reverse Proxy/Load Balancer

      Steps to Reproduce

      1. Enable compression on the Tomcat connector in Bamboo:
        <Connector
            port="8085"
            protocol="HTTP/1.1"
        ...	
            compression="on"
        
      2. Make sure that text/plain is listed on the Connector's compressableMimeType property:
            compression="on"
            compressableMimeType="text/html,text/xml,text/plain,text/css,application/json,application/javascript,application/x-javascript"
        
      3. Point a Remote Agent to Bamboo and observe the logs

      Expected Results

      • The Agent should connect normally and understand compressed responses normally.

      Actual Results

      • The Agent expects the uncompressed response and fails in case it is compressed. It reports the following error and stack trace:
        INFO   | jvm 1    | 2023/10/28 22:41:48 | 2023-10-28 22:41:48,004 INFO [WrapperSimpleAppMain] [RemoteAgentHomeLocatorForBootstrap] Using agent home located at [/home/bamboo/bamboo-agent-home]
        INFO   | jvm 1    | 2023/10/28 22:42:48 | Exiting due to fatal exception.
        INFO   | jvm 1    | 2023/10/28 22:42:48 | org.apache.http.ConnectionClosedException: Premature end of Content-Length delimited message body (expected: 5.002; received: 43)
        INFO   | jvm 1    | 2023/10/28 22:42:48 | 	at org.apache.http.impl.io.ContentLengthInputStream.read(ContentLengthInputStream.java:178)
        INFO   | jvm 1    | 2023/10/28 22:42:48 | 	at org.apache.http.impl.io.ContentLengthInputStream.read(ContentLengthInputStream.java:198)
        INFO   | jvm 1    | 2023/10/28 22:42:48 | 	at org.apache.http.impl.io.ContentLengthInputStream.close(ContentLengthInputStream.java:101)
        INFO   | jvm 1    | 2023/10/28 22:42:48 | 	at org.apache.http.impl.execchain.ResponseEntityProxy.streamClosed(ResponseEntityProxy.java:142)
        INFO   | jvm 1    | 2023/10/28 22:42:48 | 	at org.apache.http.conn.EofSensorInputStream.checkClose(EofSensorInputStream.java:228)
        INFO   | jvm 1    | 2023/10/28 22:42:48 | 	at org.apache.http.conn.EofSensorInputStream.close(EofSensorInputStream.java:172)
        INFO   | jvm 1    | 2023/10/28 22:42:48 | 	at java.base/java.util.zip.InflaterInputStream.close(InflaterInputStream.java:231)
        INFO   | jvm 1    | 2023/10/28 22:42:48 | 	at java.base/java.util.zip.GZIPInputStream.close(GZIPInputStream.java:136)
        INFO   | jvm 1    | 2023/10/28 22:42:48 | 	at org.apache.http.client.entity.LazyDecompressingInputStream.close(LazyDecompressingInputStream.java:94)
        INFO   | jvm 1    | 2023/10/28 22:42:48 | 	at org.apache.http.util.EntityUtils.toString(EntityUtils.java:232)
        INFO   | jvm 1    | 2023/10/28 22:42:48 | 	at org.apache.http.util.EntityUtils.toString(EntityUtils.java:270)
        INFO   | jvm 1    | 2023/10/28 22:42:48 | 	at com.atlassian.bamboo.agent.bootstrap.ClasspathBuilder.lambda$testCaching$1(ClasspathBuilder.java:76)
        INFO   | jvm 1    | 2023/10/28 22:42:48 | 	at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:223)
        INFO   | jvm 1    | 2023/10/28 22:42:48 | 	at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:165)
        INFO   | jvm 1    | 2023/10/28 22:42:48 | 	at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:140)
        INFO   | jvm 1    | 2023/10/28 22:42:48 | 	at com.atlassian.bamboo.agent.bootstrap.ClasspathBuilder.testCaching(ClasspathBuilder.java:76)
        INFO   | jvm 1    | 2023/10/28 22:42:48 | 	at com.atlassian.bamboo.agent.bootstrap.ClasspathBuilder.getClassLoader(ClasspathBuilder.java:61)
        INFO   | jvm 1    | 2023/10/28 22:42:48 | 	at com.atlassian.bamboo.agent.bootstrap.AgentContext.newClassLoader(AgentContext.java:371)
        INFO   | jvm 1    | 2023/10/28 22:42:48 | 	at com.atlassian.bamboo.agent.bootstrap.AgentContext.run(AgentContext.java:121)
        INFO   | jvm 1    | 2023/10/28 22:42:48 | 	at com.atlassian.bamboo.agent.bootstrap.RemoteAgentBootstrap.run(RemoteAgentBootstrap.java:163)
        INFO   | jvm 1    | 2023/10/28 22:42:48 | 	at com.atlassian.bamboo.agent.bootstrap.RemoteAgentBootstrap.main(RemoteAgentBootstrap.java:71)
        INFO   | jvm 1    | 2023/10/28 22:42:48 | 	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        INFO   | jvm 1    | 2023/10/28 22:42:48 | 	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
        INFO   | jvm 1    | 2023/10/28 22:42:48 | 	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        INFO   | jvm 1    | 2023/10/28 22:42:48 | 	at java.base/java.lang.reflect.Method.invoke(Method.java:568)
        INFO   | jvm 1    | 2023/10/28 22:42:48 | 	at com.atlassian.bamboo.agent.bootstrap.AgentBootstrap.main(AgentBootstrap.java:21)
        INFO   | jvm 1    | 2023/10/28 22:42:48 | 	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        INFO   | jvm 1    | 2023/10/28 22:42:48 | 	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
        INFO   | jvm 1    | 2023/10/28 22:42:48 | 	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        INFO   | jvm 1    | 2023/10/28 22:42:48 | 	at java.base/java.lang.reflect.Method.invoke(Method.java:568)
        INFO   | jvm 1    | 2023/10/28 22:42:48 | 	at org.tanukisoftware.wrapper.WrapperSimpleApp.run(WrapperSimpleApp.java:349)
        INFO   | jvm 1    | 2023/10/28 22:42:48 | 	at java.base/java.lang.Thread.run(Thread.java:833)
        

      Workaround

      1. Either disable compression completely on server.xml or remove text/plain from the compressableMimeType property and restart the server.
        or
      2. As this issue is caused by an external bug/regression in Apache Tomcat 9.0.81, you can upgrade the Apache Tomcat version used by Bamboo to 9.0.82 or later manually to fix the issue until a Bamboo version is released with an updated Tomcat version.

      Notes

            Assignee:
            Eduardo Alvarenga (Inactive)
            Reporter:
            Eduardo Alvarenga (Inactive)
            Votes:
            1 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: