beeme1mr / Dynatrace-Synthetic

Dynatrace plugin for Synthetic data
MIT License
0 stars 1 forks source link

'teardown()' closes connection manager; monitor fails with 'IllegalStateException: Connection pool shut down' #1

Open gabrielprioli opened 8 years ago

gabrielprioli commented 8 years ago

The issue

After a change in plugin properties (plugin name, username, password, test name, test type, etc.), the teardown() will be executed and the PoolingHttpClientConnectionManager (from the underlying library http-client) will be closed. The next execution of the plugin fails because the connection manager is shut down.

Please see captured log below with commentaries:

Last successful execution (before property change) (16:04):

(...)
2015-11-19 16:04:43 FINE [monitor@New Synthetic_0] Successfully received test data
2015-11-19 16:04:43 FINE [monitor@New Synthetic_0] Starting to summarize backbone data
2015-11-19 16:04:43 FINE [monitor@New Synthetic_0] This is a new location
2015-11-19 16:04:43 FINE [monitor@New Synthetic_0] Successfully created the summary object - saving time stamp
2015-11-19 16:04:43 FINE [monitor@New Synthetic_0] Finished the execute method

First execution (after property change) (16:09). The execution starts with calling teardown(), as seen by the "Shutting down Unirest" log message.

2015-11-19 16:09:43 FINE [monitor@New Synthetic_0] Shutting down Unirest
2015-11-19 16:09:43 FINE [PoolingHttpClientConnectionManager@New Synthetic_0] Connection manager is shutting down
2015-11-19 16:09:43 FINE [PoolingHttpClientConnectionManager@New Synthetic_0] Connection manager shut down

Now, the execute() begins, trying to authenticate. However, a Unirest exception is captured and the Connection pool shut down exception is thrown.

2015-11-19 16:09:43 FINE [monitor@New Synthetic_0] Starting the execute method
2015-11-19 16:09:43 FINE [monitor@New Synthetic_0] Attempting to authenticate gabriel.prioli@...
2015-11-19 16:09:43 FINE [PoolingHttpClientConnectionManager@New Synthetic_0] Connection request: [route: {}->http://127.0.0.1:81][total kept alive: 0; route allocated: 0 of 100; total allocated: 0 of 250]
2015-11-19 16:09:43 SEVERE [monitor@New Synthetic_0] A Unirest exception has been thrown while attempting to get test data
2015-11-19 16:09:43 SEVERE [monitor@New Synthetic_0] java.lang.IllegalStateException: Connection pool shut down

How to reproduce

gabrielprioli commented 8 years ago

I've attempted to solve it by adding Options.refresh() (which always sets a new connection manager - View file, line 72)

However, I don't really know if this is the correct fix as the plugin sometimes failed and removing it would make it work again. Perhaps some conflict with frequently creating new connection manager objects.