Summary
Bamboo remote agent fails to update or install with a NullPointerException in Bamboo. This occurs when the HTTP response from the Bamboo Server to the agent does not contain the 'Content-Length' HTTP header. This can happen when connecting the agent to Bamboo via a reverse proxy which enables gzip / chunked transfer encoding.
Environment
- Reverse proxy between Bamboo Server and Remote Agent
Steps to Reproduce
- Enable gzip using mod_deflate on Apache HTTPD for Content-Type application/octet-stream
AddOutputFilterByType DEFLATE application/octet-stream
- Install a new Bamboo remote agent and connect it to the proxied Bamboo Server URL.
Expected Results
Agent installs / updates and connects successfully.
Actual Results
Agent installation / update fails. The agent does not connect.
The below exception is thrown in the atlassian-bamboo-agent.log file:
INFO | jvm 5 | 2017/12/19 11:58:38 | 2017-11-29 11:58:38,580 INFO [WrapperSimpleAppMain] [ClasspathBuilder] Syncing /opt/bamboo-agent-home with https://bamboo/agentServer/bootstrap/classpath/manifest INFO | jvm 5 | 2017/12/19 11:58:38 | 2017-11-29 11:58:38,782 INFO [WrapperSimpleAppMain] [ClasspathBuilder] Removing /opt/bamboo-agent-home/classpath/MANIFEST.DAT INFO | jvm 5 | 2017/12/19 11:58:38 | 2017-11-29 11:58:38,782 INFO [WrapperSimpleAppMain] [ClasspathBuilder] Server publishes 335 files, we need to download 1 ... INFO | jvm 5 | 2017/12/19 11:58:38 | 2017-12-19 11:58:38,614 DEBUG [AgentRunnerThread] [headers] http-outgoing-1 << HTTP/1.1 200 OK INFO | jvm 5 | 2017/12/19 11:58:38 | 2017-12-19 11:58:38,614 DEBUG [AgentRunnerThread] [headers] http-outgoing-1 << Date: Tue, 19 Dec 2017 00:58:38 GMT INFO | jvm 5 | 2017/12/19 11:58:38 | 2017-12-19 11:58:38,614 DEBUG [AgentRunnerThread] [headers] http-outgoing-1 << Server: Apache-Coyote/1.1 INFO | jvm 5 | 2017/12/19 11:58:38 | 2017-12-19 11:58:38,614 DEBUG [AgentRunnerThread] [headers] http-outgoing-1 << X-ASEN: SEN-500 INFO | jvm 5 | 2017/12/19 11:58:38 | 2017-12-19 11:58:38,614 DEBUG [AgentRunnerThread] [headers] http-outgoing-1 << X-Frame-Options: SAMEORIGIN INFO | jvm 5 | 2017/12/19 11:58:38 | 2017-12-19 11:58:38,614 DEBUG [AgentRunnerThread] [headers] http-outgoing-1 << Cache-Control: public, max-age=31536000 INFO | jvm 5 | 2017/12/19 11:58:38 | 2017-12-19 11:58:38,614 DEBUG [AgentRunnerThread] [headers] http-outgoing-1 << Last-Modified: Wed, 06 Dec 2017 16:43:16 GMT INFO | jvm 5 | 2017/12/19 11:58:38 | 2017-12-19 11:58:38,614 DEBUG [AgentRunnerThread] [headers] http-outgoing-1 << Content-Type: application/octet-stream INFO | jvm 5 | 2017/12/19 11:58:38 | 2017-12-19 11:58:38,614 DEBUG [AgentRunnerThread] [headers] http-outgoing-1 << Vary: Accept-Encoding INFO | jvm 5 | 2017/12/19 11:58:38 | 2017-12-19 11:58:38,614 DEBUG [AgentRunnerThread] [headers] http-outgoing-1 << Content-Encoding: gzip INFO | jvm 5 | 2017/12/19 11:58:38 | 2017-12-19 11:58:38,614 DEBUG [AgentRunnerThread] [headers] http-outgoing-1 << Keep-Alive: timeout=5, max=99 INFO | jvm 5 | 2017/12/19 11:58:38 | 2017-12-19 11:58:38,614 DEBUG [AgentRunnerThread] [headers] http-outgoing-1 << Connection: Keep-Alive INFO | jvm 5 | 2017/12/19 11:58:38 | 2017-12-19 11:58:38,614 DEBUG [AgentRunnerThread] [headers] http-outgoing-1 << Transfer-Encoding: chunked ... INFO | jvm 5 | 2017/12/19 11:58:38 | Exiting due to fatal exception. INFO | jvm 5 | 2017/12/19 11:58:38 | java.lang.NullPointerException INFO | jvm 5 | 2017/12/19 11:58:38 | at com.atlassian.bamboo.agent.bootstrap.ClasspathBuilder.lambda$download$9(ClasspathBuilder.java:167) INFO | jvm 5 | 2017/12/19 11:58:38 | at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:223) INFO | jvm 5 | 2017/12/19 11:58:38 | at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:165) INFO | jvm 5 | 2017/12/19 11:58:38 | at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:140) INFO | jvm 5 | 2017/12/19 11:58:38 | at com.atlassian.bamboo.agent.bootstrap.ClasspathBuilder.download(ClasspathBuilder.java:163) INFO | jvm 5 | 2017/12/19 11:58:38 | at com.atlassian.bamboo.agent.bootstrap.ClasspathBuilder.sync(ClasspathBuilder.java:111) INFO | jvm 5 | 2017/12/19 11:58:38 | at com.atlassian.bamboo.agent.bootstrap.ClasspathBuilder.getClassLoader(ClasspathBuilder.java:58) INFO | jvm 5 | 2017/12/19 11:58:38 | at com.atlassian.bamboo.agent.bootstrap.AgentContext.newClassLoader(AgentContext.java:329) INFO | jvm 5 | 2017/12/19 11:58:38 | at com.atlassian.bamboo.agent.bootstrap.AgentContext.run(AgentContext.java:93) INFO | jvm 5 | 2017/12/19 11:58:38 | at com.atlassian.bamboo.agent.bootstrap.AgentBootstrap.run(AgentBootstrap.java:111) INFO | jvm 5 | 2017/12/19 11:58:38 | at com.atlassian.bamboo.agent.bootstrap.AgentBootstrap.main(AgentBootstrap.java:50) INFO | jvm 5 | 2017/12/19 11:58:38 | at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) INFO | jvm 5 | 2017/12/19 11:58:38 | at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) INFO | jvm 5 | 2017/12/19 11:58:38 | at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) INFO | jvm 5 | 2017/12/19 11:58:38 | at java.lang.reflect.Method.invoke(Method.java:498) INFO | jvm 5 | 2017/12/19 11:58:38 | at org.tanukisoftware.wrapper.WrapperSimpleApp.run(WrapperSimpleApp.java:240) INFO | jvm 5 | 2017/12/19 11:58:38 | at java.lang.Thread.run(Thread.java:745) INFO | jvm 5 | 2017/12/19 11:58:38 | 2017-11-29 11:58:38,787 FATAL [WrapperSimpleAppMain] [AgentBootstrap] Exiting due to fatal exception. INFO | jvm 5 | 2017/12/19 11:58:38 | java.lang.NullPointerException INFO | jvm 5 | 2017/12/19 11:58:38 | at com.atlassian.bamboo.agent.bootstrap.ClasspathBuilder.lambda$download$9(ClasspathBuilder.java:167) INFO | jvm 5 | 2017/12/19 11:58:38 | at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:223) INFO | jvm 5 | 2017/12/19 11:58:38 | at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:165) INFO | jvm 5 | 2017/12/19 11:58:38 | at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:140) INFO | jvm 5 | 2017/12/19 11:58:38 | at com.atlassian.bamboo.agent.bootstrap.ClasspathBuilder.download(ClasspathBuilder.java:163) INFO | jvm 5 | 2017/12/19 11:58:38 | at com.atlassian.bamboo.agent.bootstrap.ClasspathBuilder.sync(ClasspathBuilder.java:111) INFO | jvm 5 | 2017/12/19 11:58:38 | at com.atlassian.bamboo.agent.bootstrap.ClasspathBuilder.getClassLoader(ClasspathBuilder.java:58) INFO | jvm 5 | 2017/12/19 11:58:38 | at com.atlassian.bamboo.agent.bootstrap.AgentContext.newClassLoader(AgentContext.java:329) INFO | jvm 5 | 2017/12/19 11:58:38 | at com.atlassian.bamboo.agent.bootstrap.AgentContext.run(AgentContext.java:93) INFO | jvm 5 | 2017/12/19 11:58:38 | at com.atlassian.bamboo.agent.bootstrap.AgentBootstrap.run(AgentBootstrap.java:111) INFO | jvm 5 | 2017/12/19 11:58:38 | at com.atlassian.bamboo.agent.bootstrap.AgentBootstrap.main(AgentBootstrap.java:50) INFO | jvm 5 | 2017/12/19 11:58:38 | at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) INFO | jvm 5 | 2017/12/19 11:58:38 | at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) INFO | jvm 5 | 2017/12/19 11:58:38 | at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) INFO | jvm 5 | 2017/12/19 11:58:38 | at java.lang.reflect.Method.invoke(Method.java:498) INFO | jvm 5 | 2017/12/19 11:58:38 | at org.tanukisoftware.wrapper.WrapperSimpleApp.run(WrapperSimpleApp.java:240) INFO | jvm 5 | 2017/12/19 11:58:38 | at java.lang.Thread.run(Thread.java:745)
Workaround
- Disable gzip on the reverse proxy for Content-Type: application/octet-stream.
- This configuration could be in a number of places but as an example, it could be in your deflate.conf. Default location on Ubuntu: /etc/apache2/mods-enabled/deflate.conf -> ../mods-available/deflate.conf
- Or, bypass reverse proxy completely by connecting directly to Bamboo through an unproxied address. The connection URL of the agent is stored in the <bamboo-agent-home>/conf/wrapper.conf. Example:
wrapper.app.parameter.2=http://bamboo:8085/agentServer/