blob: 9c5b25793055745f59086a03569e3e63a83b8fd5 [file] [log] [blame]
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<title>Coverage Report</title>
<link title="Style" type="text/css" rel="stylesheet" href="css/main.css"/>
<script type="text/javascript" src="js/popup.js"></script>
</head>
<body>
<h5>Coverage Report - com.google.enterprise.adaptor.Application</h5>
<div class="separator">&nbsp;</div>
<table class="report">
<thead><tr> <td class="heading">Classes in this File</td> <td class="heading"><a class="dfn" href="help.html" onclick="popupwindow('help.html'); return false;">Line Coverage</a></td> <td class="heading"><a class="dfn" href="help.html" onclick="popupwindow('help.html'); return false;">Branch Coverage</a></td> <td class="heading"><a class="dfn" href="help.html" onclick="popupwindow('help.html'); return false;">Complexity</a></td></tr></thead>
<tr><td><a href="com.google.enterprise.adaptor.Application.html">Application</a></td><td><table cellpadding="0px" cellspacing="0px" class="percentgraph"><tr class="percentgraph"><td align="right" class="percentgraph" width="40">36</td><td class="percentgraph"><div class="percentgraph"><div class="greenbar" style="width:83px"><span class="text">177/213</span></div></div></td></tr></table></td><td><table cellpadding="0px" cellspacing="0px" class="percentgraph"><tr class="percentgraph"><td align="right" class="percentgraph" width="40">7</td><td class="percentgraph"><div class="percentgraph"><div class="greenbar" style="width:84px"><span class="text">37/44</span></div></div></td></tr></table></td><td class="value"><span class="hidden">3.1538461538461537;</span>3.154</td></tr>
<tr><td><a href="com.google.enterprise.adaptor.Application.html">Application$1</a></td><td><table cellpadding="0px" cellspacing="0px" class="percentgraph"><tr class="percentgraph"><td align="right" class="percentgraph" width="40">0</td><td class="percentgraph"><div class="percentgraph"><div class="greenbar" style="width:100px"><span class="text">7/7</span></div></div></td></tr></table></td><td><table cellpadding="0px" cellspacing="0px" class="percentgraph"><tr class="percentgraph"><td align="right" class="percentgraph" width="40"><a class="dfn" href="help.html" onclick="popupwindow('help.html'); return false;">N/A</a></td><td class="percentgraph"><div class="percentgraph"><div class="na" style="width:100px"><span class="text"><a class="dfn" href="help.html" onclick="popupwindow('help.html'); return false;">N/A</a></span></div></div></td></tr></table></td><td class="value"><span class="hidden">3.1538461538461537;</span>3.154</td></tr>
<tr><td><a href="com.google.enterprise.adaptor.Application.html">Application$2</a></td><td><table cellpadding="0px" cellspacing="0px" class="percentgraph"><tr class="percentgraph"><td align="right" class="percentgraph" width="40">0</td><td class="percentgraph"><div class="percentgraph"><div class="greenbar" style="width:100px"><span class="text">5/5</span></div></div></td></tr></table></td><td><table cellpadding="0px" cellspacing="0px" class="percentgraph"><tr class="percentgraph"><td align="right" class="percentgraph" width="40"><a class="dfn" href="help.html" onclick="popupwindow('help.html'); return false;">N/A</a></td><td class="percentgraph"><div class="percentgraph"><div class="na" style="width:100px"><span class="text"><a class="dfn" href="help.html" onclick="popupwindow('help.html'); return false;">N/A</a></span></div></div></td></tr></table></td><td class="value"><span class="hidden">3.1538461538461537;</span>3.154</td></tr>
<tr><td><a href="com.google.enterprise.adaptor.Application.html">Application$ConfigModListener</a></td><td><table cellpadding="0px" cellspacing="0px" class="percentgraph"><tr class="percentgraph"><td align="right" class="percentgraph" width="40">3</td><td class="percentgraph"><div class="percentgraph"><div class="greenbar" style="width:81px"><span class="text">13/16</span></div></div></td></tr></table></td><td><table cellpadding="0px" cellspacing="0px" class="percentgraph"><tr class="percentgraph"><td align="right" class="percentgraph" width="40">0</td><td class="percentgraph"><div class="percentgraph"><div class="greenbar" style="width:100px"><span class="text">4/4</span></div></div></td></tr></table></td><td class="value"><span class="hidden">3.1538461538461537;</span>3.154</td></tr>
<tr><td><a href="com.google.enterprise.adaptor.Application.html">Application$ShutdownHook</a></td><td><table cellpadding="0px" cellspacing="0px" class="percentgraph"><tr class="percentgraph"><td align="right" class="percentgraph" width="40">2</td><td class="percentgraph"><div class="percentgraph"><div class="greenbar" style="width:33px"><span class="text">1/3</span></div></div></td></tr></table></td><td><table cellpadding="0px" cellspacing="0px" class="percentgraph"><tr class="percentgraph"><td align="right" class="percentgraph" width="40"><a class="dfn" href="help.html" onclick="popupwindow('help.html'); return false;">N/A</a></td><td class="percentgraph"><div class="percentgraph"><div class="na" style="width:100px"><span class="text"><a class="dfn" href="help.html" onclick="popupwindow('help.html'); return false;">N/A</a></span></div></div></td></tr></table></td><td class="value"><span class="hidden">3.1538461538461537;</span>3.154</td></tr>
<tr><td><a href="com.google.enterprise.adaptor.Application.html">Application$SuggestHandlerAbortPolicy</a></td><td><table cellpadding="0px" cellspacing="0px" class="percentgraph"><tr class="percentgraph"><td align="right" class="percentgraph" width="40">5</td><td class="percentgraph"><div class="percentgraph"><div class="greenbar" style="width:44px"><span class="text">4/9</span></div></div></td></tr></table></td><td><table cellpadding="0px" cellspacing="0px" class="percentgraph"><tr class="percentgraph"><td align="right" class="percentgraph" width="40"><a class="dfn" href="help.html" onclick="popupwindow('help.html'); return false;">N/A</a></td><td class="percentgraph"><div class="percentgraph"><div class="na" style="width:100px"><span class="text"><a class="dfn" href="help.html" onclick="popupwindow('help.html'); return false;">N/A</a></span></div></div></td></tr></table></td><td class="value"><span class="hidden">3.1538461538461537;</span>3.154</td></tr>
</table>
<div class="separator">&nbsp;</div>
<table cellspacing="0" cellpadding="0" class="src">
<tr> <td class="numLine">&nbsp;1</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp;<span class="comment">// Copyright 2013 Google Inc. All Rights Reserved.</span></pre></td></tr>
<tr> <td class="numLine">&nbsp;2</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp;<span class="comment">//</span></pre></td></tr>
<tr> <td class="numLine">&nbsp;3</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp;<span class="comment">// Licensed under the Apache License, Version 2.0 (the "License");</span></pre></td></tr>
<tr> <td class="numLine">&nbsp;4</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp;<span class="comment">// you may not use this file except in compliance with the License.</span></pre></td></tr>
<tr> <td class="numLine">&nbsp;5</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp;<span class="comment">// You may obtain a copy of the License at</span></pre></td></tr>
<tr> <td class="numLine">&nbsp;6</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp;<span class="comment">//</span></pre></td></tr>
<tr> <td class="numLine">&nbsp;7</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp;<span class="comment">// http://www.apache.org/licenses/LICENSE-2.0</span></pre></td></tr>
<tr> <td class="numLine">&nbsp;8</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp;<span class="comment">//</span></pre></td></tr>
<tr> <td class="numLine">&nbsp;9</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp;<span class="comment">// Unless required by applicable law or agreed to in writing, software</span></pre></td></tr>
<tr> <td class="numLine">&nbsp;10</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp;<span class="comment">// distributed under the License is distributed on an "AS IS" BASIS,</span></pre></td></tr>
<tr> <td class="numLine">&nbsp;11</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp;<span class="comment">// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.</span></pre></td></tr>
<tr> <td class="numLine">&nbsp;12</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp;<span class="comment">// See the License for the specific language governing permissions and</span></pre></td></tr>
<tr> <td class="numLine">&nbsp;13</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp;<span class="comment">// limitations under the License.</span></pre></td></tr>
<tr> <td class="numLine">&nbsp;14</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr> <td class="numLine">&nbsp;15</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp;<span class="keyword">package</span> com.google.enterprise.adaptor;</pre></td></tr>
<tr> <td class="numLine">&nbsp;16</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr> <td class="numLine">&nbsp;17</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp;<span class="keyword">import</span> com.sun.net.httpserver.HttpServer;</pre></td></tr>
<tr> <td class="numLine">&nbsp;18</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp;<span class="keyword">import</span> com.sun.net.httpserver.HttpsConfigurator;</pre></td></tr>
<tr> <td class="numLine">&nbsp;19</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp;<span class="keyword">import</span> com.sun.net.httpserver.HttpsParameters;</pre></td></tr>
<tr> <td class="numLine">&nbsp;20</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp;<span class="keyword">import</span> com.sun.net.httpserver.HttpsServer;</pre></td></tr>
<tr> <td class="numLine">&nbsp;21</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr> <td class="numLine">&nbsp;22</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp;<span class="keyword">import</span> java.io.File;</pre></td></tr>
<tr> <td class="numLine">&nbsp;23</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp;<span class="keyword">import</span> java.io.FileInputStream;</pre></td></tr>
<tr> <td class="numLine">&nbsp;24</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp;<span class="keyword">import</span> java.io.IOException;</pre></td></tr>
<tr> <td class="numLine">&nbsp;25</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp;<span class="keyword">import</span> java.io.InputStream;</pre></td></tr>
<tr> <td class="numLine">&nbsp;26</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp;<span class="keyword">import</span> java.net.InetSocketAddress;</pre></td></tr>
<tr> <td class="numLine">&nbsp;27</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp;<span class="keyword">import</span> java.net.MalformedURLException;</pre></td></tr>
<tr> <td class="numLine">&nbsp;28</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp;<span class="keyword">import</span> java.net.URL;</pre></td></tr>
<tr> <td class="numLine">&nbsp;29</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp;<span class="keyword">import</span> java.net.URLConnection;</pre></td></tr>
<tr> <td class="numLine">&nbsp;30</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp;<span class="keyword">import</span> java.security.NoSuchAlgorithmException;</pre></td></tr>
<tr> <td class="numLine">&nbsp;31</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp;<span class="keyword">import</span> java.util.Arrays;</pre></td></tr>
<tr> <td class="numLine">&nbsp;32</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp;<span class="keyword">import</span> java.util.HashSet;</pre></td></tr>
<tr> <td class="numLine">&nbsp;33</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp;<span class="keyword">import</span> java.util.List;</pre></td></tr>
<tr> <td class="numLine">&nbsp;34</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp;<span class="keyword">import</span> java.util.Locale;</pre></td></tr>
<tr> <td class="numLine">&nbsp;35</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp;<span class="keyword">import</span> java.util.Map.Entry;</pre></td></tr>
<tr> <td class="numLine">&nbsp;36</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp;<span class="keyword">import</span> java.util.Properties;</pre></td></tr>
<tr> <td class="numLine">&nbsp;37</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp;<span class="keyword">import</span> java.util.Set;</pre></td></tr>
<tr> <td class="numLine">&nbsp;38</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp;<span class="keyword">import</span> java.util.concurrent.ArrayBlockingQueue;</pre></td></tr>
<tr> <td class="numLine">&nbsp;39</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp;<span class="keyword">import</span> java.util.concurrent.BlockingQueue;</pre></td></tr>
<tr> <td class="numLine">&nbsp;40</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp;<span class="keyword">import</span> java.util.concurrent.Executor;</pre></td></tr>
<tr> <td class="numLine">&nbsp;41</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp;<span class="keyword">import</span> java.util.concurrent.ExecutorService;</pre></td></tr>
<tr> <td class="numLine">&nbsp;42</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp;<span class="keyword">import</span> java.util.concurrent.LinkedBlockingQueue;</pre></td></tr>
<tr> <td class="numLine">&nbsp;43</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp;<span class="keyword">import</span> java.util.concurrent.RejectedExecutionHandler;</pre></td></tr>
<tr> <td class="numLine">&nbsp;44</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp;<span class="keyword">import</span> java.util.concurrent.Semaphore;</pre></td></tr>
<tr> <td class="numLine">&nbsp;45</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp;<span class="keyword">import</span> java.util.concurrent.ThreadPoolExecutor;</pre></td></tr>
<tr> <td class="numLine">&nbsp;46</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp;<span class="keyword">import</span> java.util.concurrent.TimeUnit;</pre></td></tr>
<tr> <td class="numLine">&nbsp;47</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp;<span class="keyword">import</span> java.util.logging.Level;</pre></td></tr>
<tr> <td class="numLine">&nbsp;48</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp;<span class="keyword">import</span> java.util.logging.Logger;</pre></td></tr>
<tr> <td class="numLine">&nbsp;49</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr> <td class="numLine">&nbsp;50</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp;<span class="keyword">import</span> javax.net.ssl.SSLContext;</pre></td></tr>
<tr> <td class="numLine">&nbsp;51</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp;<span class="keyword">import</span> javax.net.ssl.SSLParameters;</pre></td></tr>
<tr> <td class="numLine">&nbsp;52</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr> <td class="numLine">&nbsp;53</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp;<span class="comment">/**</span></pre></td></tr>
<tr> <td class="numLine">&nbsp;54</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp;<span class="comment"> * Provides framework for adaptors to act as a stand-alone application. This</span></pre></td></tr>
<tr> <td class="numLine">&nbsp;55</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp;<span class="comment"> * entails creating well-configured HttpServer instances, argument parsing,</span></pre></td></tr>
<tr> <td class="numLine">&nbsp;56</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp;<span class="comment"> * shutdown handling, and more.</span></pre></td></tr>
<tr> <td class="numLine">&nbsp;57</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp;<span class="comment"> */</span></pre></td></tr>
<tr> <td class="numLineCover">&nbsp;58</td> <td class="nbHitsCovered">&nbsp;24</td> <td class="src"><pre class="src">&nbsp;<span class="keyword">public</span> <span class="keyword">final</span> <span class="keyword">class</span> Application {</pre></td></tr>
<tr> <td class="numLine">&nbsp;59</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp; <span class="keyword">private</span> <span class="keyword">static</span> <span class="keyword">final</span> String SLEEP_PATH = <span class="string">"/sleep"</span>;</pre></td></tr>
<tr> <td class="numLine">&nbsp;60</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp; <span class="keyword">static</span> <span class="keyword">final</span> String DEFAULT_CONFIG_FILE</pre></td></tr>
<tr> <td class="numLine">&nbsp;61</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp; = <span class="string">"adaptor-config.properties"</span>;</pre></td></tr>
<tr> <td class="numLine">&nbsp;62</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr> <td class="numLineCover">&nbsp;63</td> <td class="nbHitsCovered">&nbsp;1</td> <td class="src"><pre class="src">&nbsp; <span class="keyword">private</span> <span class="keyword">static</span> <span class="keyword">final</span> Logger log</pre></td></tr>
<tr> <td class="numLine">&nbsp;64</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp; = Logger.getLogger(Application.<span class="keyword">class</span>.getName());</pre></td></tr>
<tr> <td class="numLine">&nbsp;65</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr> <td class="numLine">&nbsp;66</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp; <span class="keyword">private</span> <span class="keyword">final</span> Config config;</pre></td></tr>
<tr> <td class="numLine">&nbsp;67</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp; <span class="keyword">private</span> <span class="keyword">final</span> GsaCommunicationHandler gsa;</pre></td></tr>
<tr> <td class="numLineCover">&nbsp;68</td> <td class="nbHitsCovered">&nbsp;19</td> <td class="src"><pre class="src">&nbsp; <span class="keyword">private</span> <span class="keyword">final</span> ConfigModificationListener configModListener</pre></td></tr>
<tr> <td class="numLine">&nbsp;69</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp; = <span class="keyword">new</span> ConfigModListener();</pre></td></tr>
<tr> <td class="numLine">&nbsp;70</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp; <span class="comment">/**</span></pre></td></tr>
<tr> <td class="numLine">&nbsp;71</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp;<span class="comment"> * An "inverted" semaphore that has permits available when stop() is running;</span></pre></td></tr>
<tr> <td class="numLine">&nbsp;72</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp;<span class="comment"> * at all other times it has no permits. This allows start() to sleep on the</span></pre></td></tr>
<tr> <td class="numLine">&nbsp;73</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp;<span class="comment"> * semaphore and be woken when stop() is called.</span></pre></td></tr>
<tr> <td class="numLine">&nbsp;74</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp;<span class="comment"> */</span></pre></td></tr>
<tr> <td class="numLineCover">&nbsp;75</td> <td class="nbHitsCovered">&nbsp;19</td> <td class="src"><pre class="src">&nbsp; <span class="keyword">private</span> <span class="keyword">final</span> Semaphore shutdownSemaphore = <span class="keyword">new</span> Semaphore(0);</pre></td></tr>
<tr> <td class="numLine">&nbsp;76</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp; <span class="keyword">private</span> Thread shutdownHook;</pre></td></tr>
<tr> <td class="numLine">&nbsp;77</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp; <span class="keyword">private</span> HttpServer primaryServer;</pre></td></tr>
<tr> <td class="numLine">&nbsp;78</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp; <span class="keyword">private</span> HttpServer dashboardServer;</pre></td></tr>
<tr> <td class="numLine">&nbsp;79</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr> <td class="numLineCover">&nbsp;80</td> <td class="nbHitsCovered">&nbsp;19</td> <td class="src"><pre class="src">&nbsp; <span class="keyword">public</span> Application(Adaptor adaptor, Config config) {</pre></td></tr>
<tr> <td class="numLineCover">&nbsp;81</td> <td class="nbHitsCovered">&nbsp;19</td> <td class="src"><pre class="src">&nbsp; <span class="keyword">this</span>.config = config;</pre></td></tr>
<tr> <td class="numLine">&nbsp;82</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr> <td class="numLineCover">&nbsp;83</td> <td class="nbHitsCovered">&nbsp;19</td> <td class="src"><pre class="src">&nbsp; gsa = <span class="keyword">new</span> GsaCommunicationHandler(adaptor, config);</pre></td></tr>
<tr> <td class="numLineCover">&nbsp;84</td> <td class="nbHitsCovered">&nbsp;19</td> <td class="src"><pre class="src">&nbsp; }</pre></td></tr>
<tr> <td class="numLine">&nbsp;85</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr> <td class="numLine">&nbsp;86</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp; <span class="comment">/**</span></pre></td></tr>
<tr> <td class="numLine">&nbsp;87</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp;<span class="comment"> * Start necessary services for receiving requests and managing background</span></pre></td></tr>
<tr> <td class="numLine">&nbsp;88</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp;<span class="comment"> * tasks. Non-daemon threads are created, so call {@link #stop} for graceful</span></pre></td></tr>
<tr> <td class="numLine">&nbsp;89</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp;<span class="comment"> * manual shutdown. A shutdown hook is automatically installed that calls</span></pre></td></tr>
<tr> <td class="numLine">&nbsp;90</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp;<span class="comment"> * {@code stop()}.</span></pre></td></tr>
<tr> <td class="numLine">&nbsp;91</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp;<span class="comment"> */</span></pre></td></tr>
<tr> <td class="numLine">&nbsp;92</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp; <span class="keyword">public</span> <span class="keyword">synchronized</span> <span class="keyword">void</span> start() <span class="keyword">throws</span> IOException, InterruptedException {</pre></td></tr>
<tr> <td class="numLineCover">&nbsp;93</td> <td class="nbHitsCovered">&nbsp;10</td> <td class="src"><pre class="src">&nbsp; <span class="keyword">synchronized</span> (<span class="keyword">this</span>) {</pre></td></tr>
<tr> <td class="numLineCover">&nbsp;94</td> <td class="nbHitsCovered">&nbsp;10</td> <td class="src"><pre class="src">&nbsp; daemonInit();</pre></td></tr>
<tr> <td class="numLine">&nbsp;95</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr> <td class="numLine">&nbsp;96</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp; <span class="comment">// The shutdown hook is purposefully not part of the deamon methods,</span></pre></td></tr>
<tr> <td class="numLine">&nbsp;97</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp; <span class="comment">// because it should only be done when running from the command line.</span></pre></td></tr>
<tr> <td class="numLineCover">&nbsp;98</td> <td class="nbHitsCovered">&nbsp;10</td> <td class="src"><pre class="src">&nbsp; shutdownHook = <span class="keyword">new</span> Thread(<span class="keyword">new</span> ShutdownHook(), <span class="string">"gsacomm-shutdown"</span>);</pre></td></tr>
<tr> <td class="numLineCover">&nbsp;99</td> <td class="nbHitsCovered">&nbsp;10</td> <td class="src"><pre class="src">&nbsp; Runtime.getRuntime().addShutdownHook(shutdownHook);</pre></td></tr>
<tr> <td class="numLineCover">&nbsp;100</td> <td class="nbHitsCovered">&nbsp;10</td> <td class="src"><pre class="src">&nbsp; }</pre></td></tr>
<tr> <td class="numLine">&nbsp;101</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr> <td class="numLineCover">&nbsp;102</td> <td class="nbHitsCovered">&nbsp;10</td> <td class="src"><pre class="src">&nbsp; <span class="keyword">boolean</span> success = <span class="keyword">false</span>;</pre></td></tr>
<tr> <td class="numLine">&nbsp;103</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp; <span class="keyword">try</span> {</pre></td></tr>
<tr> <td class="numLineCover">&nbsp;104</td> <td class="nbHitsCovered">&nbsp;10</td> <td class="src"><pre class="src">&nbsp; daemonStart();</pre></td></tr>
<tr> <td class="numLineCover">&nbsp;105</td> <td class="nbHitsCovered">&nbsp;9</td> <td class="src"><pre class="src">&nbsp; success = <span class="keyword">true</span>;</pre></td></tr>
<tr> <td class="numLine">&nbsp;106</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp; } <span class="keyword">finally</span> {</pre></td></tr>
<tr> <td class="numLineCover">&nbsp;107</td> <td class="nbHitsCovered"><a title="Line 107: Conditional coverage 100% (2/2).">&nbsp;10</a></td> <td class="src"><pre class="src">&nbsp;<a title="Line 107: Conditional coverage 100% (2/2)."> <span class="keyword">if</span> (!success) {</a></pre></td></tr>
<tr> <td class="numLine">&nbsp;108</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp; <span class="comment">// Call daemonDestroy() and remove shutdown hook.</span></pre></td></tr>
<tr> <td class="numLineCover">&nbsp;109</td> <td class="nbHitsCovered">&nbsp;1</td> <td class="src"><pre class="src">&nbsp; stop(0, TimeUnit.SECONDS);</pre></td></tr>
<tr> <td class="numLine">&nbsp;110</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp; }</pre></td></tr>
<tr> <td class="numLine">&nbsp;111</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp; }</pre></td></tr>
<tr> <td class="numLineCover">&nbsp;112</td> <td class="nbHitsCovered">&nbsp;9</td> <td class="src"><pre class="src">&nbsp; }</pre></td></tr>
<tr> <td class="numLine">&nbsp;113</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr> <td class="numLine">&nbsp;114</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp; <span class="comment">/**</span></pre></td></tr>
<tr> <td class="numLine">&nbsp;115</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp;<span class="comment"> * Reserves resources for later use. This may be run with different</span></pre></td></tr>
<tr> <td class="numLine">&nbsp;116</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp;<span class="comment"> * permissions (like as root), to reserve ports or other things that need</span></pre></td></tr>
<tr> <td class="numLine">&nbsp;117</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp;<span class="comment"> * elevated privileges.</span></pre></td></tr>
<tr> <td class="numLine">&nbsp;118</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp;<span class="comment"> */</span></pre></td></tr>
<tr> <td class="numLine">&nbsp;119</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp; <span class="keyword">synchronized</span> <span class="keyword">void</span> daemonInit() <span class="keyword">throws</span> IOException {</pre></td></tr>
<tr> <td class="numLineCover">&nbsp;120</td> <td class="nbHitsUncovered"><a title="Line 120: Conditional coverage 50% (1/2).">&nbsp;12</a></td> <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 120: Conditional coverage 50% (1/2)."> <span class="keyword">if</span> (primaryServer != <span class="keyword">null</span>) {</a></span></pre></td></tr>
<tr> <td class="numLineCover">&nbsp;121</td> <td class="nbHitsUncovered">&nbsp;0</td> <td class="src"><pre class="src"><span class="srcUncovered">&nbsp; <span class="keyword">throw</span> <span class="keyword">new</span> IllegalStateException(<span class="string">"Already started"</span>);</span></pre></td></tr>
<tr> <td class="numLine">&nbsp;122</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp; }</pre></td></tr>
<tr> <td class="numLineCover">&nbsp;123</td> <td class="nbHitsCovered">&nbsp;12</td> <td class="src"><pre class="src">&nbsp; <span class="keyword">boolean</span> success = <span class="keyword">false</span>;</pre></td></tr>
<tr> <td class="numLine">&nbsp;124</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp; <span class="keyword">try</span> {</pre></td></tr>
<tr> <td class="numLineCover">&nbsp;125</td> <td class="nbHitsCovered">&nbsp;12</td> <td class="src"><pre class="src">&nbsp; primaryServer = createHttpServer(config);</pre></td></tr>
<tr> <td class="numLineCover">&nbsp;126</td> <td class="nbHitsCovered">&nbsp;12</td> <td class="src"><pre class="src">&nbsp; dashboardServer = createDashboardHttpServer(config);</pre></td></tr>
<tr> <td class="numLine">&nbsp;127</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp; <span class="comment">// Because once stopped the server can't be reused, we can't reuse its</span></pre></td></tr>
<tr> <td class="numLine">&nbsp;128</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp; <span class="comment">// bind()ed socket if we stop it. So although ideally we would start/stop</span></pre></td></tr>
<tr> <td class="numLine">&nbsp;129</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp; <span class="comment">// in daemonStart/daemonStop, we instead must do it in</span></pre></td></tr>
<tr> <td class="numLine">&nbsp;130</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp; <span class="comment">// daemonInit/daemonDestroy.</span></pre></td></tr>
<tr> <td class="numLineCover">&nbsp;131</td> <td class="nbHitsCovered">&nbsp;12</td> <td class="src"><pre class="src">&nbsp; primaryServer.start();</pre></td></tr>
<tr> <td class="numLineCover">&nbsp;132</td> <td class="nbHitsCovered">&nbsp;12</td> <td class="src"><pre class="src">&nbsp; dashboardServer.start();</pre></td></tr>
<tr> <td class="numLineCover">&nbsp;133</td> <td class="nbHitsCovered">&nbsp;12</td> <td class="src"><pre class="src">&nbsp; success = <span class="keyword">true</span>;</pre></td></tr>
<tr> <td class="numLine">&nbsp;134</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp; } <span class="keyword">finally</span> {</pre></td></tr>
<tr> <td class="numLineCover">&nbsp;135</td> <td class="nbHitsUncovered"><a title="Line 135: Conditional coverage 50% (1/2).">&nbsp;12</a></td> <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 135: Conditional coverage 50% (1/2)."> <span class="keyword">if</span> (!success) {</a></span></pre></td></tr>
<tr> <td class="numLineCover">&nbsp;136</td> <td class="nbHitsUncovered">&nbsp;0</td> <td class="src"><pre class="src"><span class="srcUncovered">&nbsp; daemonDestroy(0, TimeUnit.SECONDS);</span></pre></td></tr>
<tr> <td class="numLine">&nbsp;137</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp; }</pre></td></tr>
<tr> <td class="numLine">&nbsp;138</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp; }</pre></td></tr>
<tr> <td class="numLineCover">&nbsp;139</td> <td class="nbHitsCovered">&nbsp;12</td> <td class="src"><pre class="src">&nbsp; }</pre></td></tr>
<tr> <td class="numLine">&nbsp;140</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr> <td class="numLine">&nbsp;141</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp; <span class="comment">/**</span></pre></td></tr>
<tr> <td class="numLine">&nbsp;142</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp;<span class="comment"> * Really start. This must be called after a successful {@link #daemonInit}.</span></pre></td></tr>
<tr> <td class="numLine">&nbsp;143</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp;<span class="comment"> */</span></pre></td></tr>
<tr> <td class="numLine">&nbsp;144</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp; <span class="keyword">synchronized</span> <span class="keyword">void</span> daemonStart() <span class="keyword">throws</span> IOException, InterruptedException {</pre></td></tr>
<tr> <td class="numLineCover">&nbsp;145</td> <td class="nbHitsCovered">&nbsp;12</td> <td class="src"><pre class="src">&nbsp; <span class="keyword">boolean</span> success = <span class="keyword">false</span>;</pre></td></tr>
<tr> <td class="numLine">&nbsp;146</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp; <span class="keyword">try</span> {</pre></td></tr>
<tr> <td class="numLineCover">&nbsp;147</td> <td class="nbHitsCovered">&nbsp;12</td> <td class="src"><pre class="src">&nbsp; realDaemonStart();</pre></td></tr>
<tr> <td class="numLineCover">&nbsp;148</td> <td class="nbHitsCovered">&nbsp;11</td> <td class="src"><pre class="src">&nbsp; success = <span class="keyword">true</span>;</pre></td></tr>
<tr> <td class="numLine">&nbsp;149</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp; } <span class="keyword">finally</span> {</pre></td></tr>
<tr> <td class="numLineCover">&nbsp;150</td> <td class="nbHitsCovered"><a title="Line 150: Conditional coverage 100% (2/2).">&nbsp;12</a></td> <td class="src"><pre class="src">&nbsp;<a title="Line 150: Conditional coverage 100% (2/2)."> <span class="keyword">if</span> (!success) {</a></pre></td></tr>
<tr> <td class="numLineCover">&nbsp;151</td> <td class="nbHitsCovered">&nbsp;1</td> <td class="src"><pre class="src">&nbsp; daemonStop(0, TimeUnit.SECONDS);</pre></td></tr>
<tr> <td class="numLine">&nbsp;152</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp; }</pre></td></tr>
<tr> <td class="numLine">&nbsp;153</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp; }</pre></td></tr>
<tr> <td class="numLineCover">&nbsp;154</td> <td class="nbHitsCovered">&nbsp;11</td> <td class="src"><pre class="src">&nbsp; }</pre></td></tr>
<tr> <td class="numLine">&nbsp;155</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr> <td class="numLine">&nbsp;156</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp; <span class="keyword">private</span> <span class="keyword">synchronized</span> <span class="keyword">void</span> realDaemonStart() <span class="keyword">throws</span> IOException,</pre></td></tr>
<tr> <td class="numLine">&nbsp;157</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp; InterruptedException {</pre></td></tr>
<tr> <td class="numLineCover">&nbsp;158</td> <td class="nbHitsCovered">&nbsp;12</td> <td class="src"><pre class="src">&nbsp; AdaptorContext context = gsa.setup(primaryServer, dashboardServer, <span class="keyword">null</span>);</pre></td></tr>
<tr> <td class="numLine">&nbsp;159</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr> <td class="numLineCover">&nbsp;160</td> <td class="nbHitsCovered">&nbsp;12</td> <td class="src"><pre class="src">&nbsp; <span class="keyword">long</span> sleepDurationMillis = 8000;</pre></td></tr>
<tr> <td class="numLine">&nbsp;161</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp; <span class="comment">// An hour.</span></pre></td></tr>
<tr> <td class="numLineCover">&nbsp;162</td> <td class="nbHitsCovered">&nbsp;12</td> <td class="src"><pre class="src">&nbsp; <span class="keyword">long</span> maxSleepDurationMillis = 60 * 60 * 1000;</pre></td></tr>
<tr> <td class="numLine">&nbsp;163</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp; <span class="comment">// Loop until 1) the adaptor starts successfully, 2) an unrecoverable</span></pre></td></tr>
<tr> <td class="numLine">&nbsp;164</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp; <span class="comment">// StartupException is thrown, 3) stop() is called, or 4) Thread.interrupt()</span></pre></td></tr>
<tr> <td class="numLine">&nbsp;165</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp; <span class="comment">// is called on this thread (which we don't do).</span></pre></td></tr>
<tr> <td class="numLine">&nbsp;166</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp; <span class="comment">// Retrying to start the adaptor is helpful in cases where it needs</span></pre></td></tr>
<tr> <td class="numLine">&nbsp;167</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp; <span class="comment">// initialization data from a repository that is temporarily down; if the</span></pre></td></tr>
<tr> <td class="numLine">&nbsp;168</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp; <span class="comment">// adaptor is running as a service, we don't want to stop starting simply</span></pre></td></tr>
<tr> <td class="numLine">&nbsp;169</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp; <span class="comment">// because another computer is down while we start (which would easily be</span></pre></td></tr>
<tr> <td class="numLine">&nbsp;170</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp; <span class="comment">// the case after a power failure).</span></pre></td></tr>
<tr> <td class="numLine">&nbsp;171</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp; <span class="keyword">while</span> (<span class="keyword">true</span>) {</pre></td></tr>
<tr> <td class="numLine">&nbsp;172</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp; <span class="keyword">try</span> {</pre></td></tr>
<tr> <td class="numLineCover">&nbsp;173</td> <td class="nbHitsCovered">&nbsp;13</td> <td class="src"><pre class="src">&nbsp; gsa.tryToPutVersionIntoConfig();</pre></td></tr>
<tr> <td class="numLineCover">&nbsp;174</td> <td class="nbHitsCovered">&nbsp;13</td> <td class="src"><pre class="src">&nbsp; String adaptorType = gsa.getAdaptor().getClass().getName();</pre></td></tr>
<tr> <td class="numLineCover">&nbsp;175</td> <td class="nbHitsCovered">&nbsp;13</td> <td class="src"><pre class="src">&nbsp; log.log(Level.INFO, <span class="string">"about to init {0}"</span>, adaptorType); </pre></td></tr>
<tr> <td class="numLineCover">&nbsp;176</td> <td class="nbHitsCovered">&nbsp;13</td> <td class="src"><pre class="src">&nbsp; gsa.getAdaptor().init(context);</pre></td></tr>
<tr> <td class="numLineCover">&nbsp;177</td> <td class="nbHitsCovered">&nbsp;10</td> <td class="src"><pre class="src">&nbsp; <span class="keyword">break</span>;</pre></td></tr>
<tr> <td class="numLineCover">&nbsp;178</td> <td class="nbHitsUncovered">&nbsp;0</td> <td class="src"><pre class="src"><span class="srcUncovered">&nbsp; } <span class="keyword">catch</span> (InterruptedException ex) {</span></pre></td></tr>
<tr> <td class="numLineCover">&nbsp;179</td> <td class="nbHitsUncovered">&nbsp;0</td> <td class="src"><pre class="src"><span class="srcUncovered">&nbsp; <span class="keyword">throw</span> ex;</span></pre></td></tr>
<tr> <td class="numLineCover">&nbsp;180</td> <td class="nbHitsCovered">&nbsp;1</td> <td class="src"><pre class="src">&nbsp; } <span class="keyword">catch</span> (StartupException ex) { </pre></td></tr>
<tr> <td class="numLineCover">&nbsp;181</td> <td class="nbHitsCovered">&nbsp;1</td> <td class="src"><pre class="src">&nbsp; <span class="keyword">throw</span> <span class="keyword">new</span> RuntimeException(<span class="string">"Failed to initialize adaptor"</span>, ex);</pre></td></tr>
<tr> <td class="numLineCover">&nbsp;182</td> <td class="nbHitsCovered">&nbsp;2</td> <td class="src"><pre class="src">&nbsp; } <span class="keyword">catch</span> (Exception ex) {</pre></td></tr>
<tr> <td class="numLineCover">&nbsp;183</td> <td class="nbHitsCovered">&nbsp;2</td> <td class="src"><pre class="src">&nbsp; log.log(Level.WARNING, <span class="string">"Failed to initialize adaptor"</span>, ex);</pre></td></tr>
<tr> <td class="numLineCover">&nbsp;184</td> <td class="nbHitsCovered"><a title="Line 184: Conditional coverage 100% (2/2).">&nbsp;2</a></td> <td class="src"><pre class="src">&nbsp;<a title="Line 184: Conditional coverage 100% (2/2)."> <span class="keyword">if</span> (shutdownSemaphore.tryAcquire(sleepDurationMillis,</a></pre></td></tr>
<tr> <td class="numLine">&nbsp;185</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp; TimeUnit.MILLISECONDS)) {</pre></td></tr>
<tr> <td class="numLineCover">&nbsp;186</td> <td class="nbHitsCovered">&nbsp;1</td> <td class="src"><pre class="src">&nbsp; shutdownSemaphore.release();</pre></td></tr>
<tr> <td class="numLine">&nbsp;187</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp; <span class="comment">// Shutdown initiated.</span></pre></td></tr>
<tr> <td class="numLineCover">&nbsp;188</td> <td class="nbHitsCovered">&nbsp;1</td> <td class="src"><pre class="src">&nbsp; <span class="keyword">return</span>;</pre></td></tr>
<tr> <td class="numLine">&nbsp;189</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp; }</pre></td></tr>
<tr> <td class="numLineCover">&nbsp;190</td> <td class="nbHitsCovered">&nbsp;1</td> <td class="src"><pre class="src">&nbsp; sleepDurationMillis</pre></td></tr>
<tr> <td class="numLine">&nbsp;191</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp; = Math.min(sleepDurationMillis * 2, maxSleepDurationMillis);</pre></td></tr>
<tr> <td class="numLineCover">&nbsp;192</td> <td class="nbHitsCovered">&nbsp;1</td> <td class="src"><pre class="src">&nbsp; gsa.ensureLatestConfigLoaded();</pre></td></tr>
<tr> <td class="numLineCover">&nbsp;193</td> <td class="nbHitsCovered">&nbsp;1</td> <td class="src"><pre class="src">&nbsp; }</pre></td></tr>
<tr> <td class="numLine">&nbsp;194</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp; }</pre></td></tr>
<tr> <td class="numLine">&nbsp;195</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr> <td class="numLineCover">&nbsp;196</td> <td class="nbHitsCovered">&nbsp;10</td> <td class="src"><pre class="src">&nbsp; config.addConfigModificationListener(configModListener);</pre></td></tr>
<tr> <td class="numLineCover">&nbsp;197</td> <td class="nbHitsCovered">&nbsp;10</td> <td class="src"><pre class="src">&nbsp; gsa.start();</pre></td></tr>
<tr> <td class="numLineCover">&nbsp;198</td> <td class="nbHitsCovered">&nbsp;10</td> <td class="src"><pre class="src">&nbsp; }</pre></td></tr>
<tr> <td class="numLine">&nbsp;199</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr> <td class="numLine">&nbsp;200</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp; <span class="comment">/**</span></pre></td></tr>
<tr> <td class="numLine">&nbsp;201</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp;<span class="comment"> * Stop processing incoming requests and background tasks, allowing graceful</span></pre></td></tr>
<tr> <td class="numLine">&nbsp;202</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp;<span class="comment"> * shutdown.</span></pre></td></tr>
<tr> <td class="numLine">&nbsp;203</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp;<span class="comment"> */</span></pre></td></tr>
<tr> <td class="numLine">&nbsp;204</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp; <span class="keyword">public</span> <span class="keyword">void</span> stop(<span class="keyword">long</span> time, TimeUnit unit) {</pre></td></tr>
<tr> <td class="numLineCover">&nbsp;205</td> <td class="nbHitsCovered">&nbsp;19</td> <td class="src"><pre class="src">&nbsp; daemonStop(time, unit);</pre></td></tr>
<tr> <td class="numLineCover">&nbsp;206</td> <td class="nbHitsCovered">&nbsp;10</td> <td class="src"><pre class="src">&nbsp; daemonDestroy(time, unit);</pre></td></tr>
<tr> <td class="numLineCover">&nbsp;207</td> <td class="nbHitsCovered">&nbsp;10</td> <td class="src"><pre class="src">&nbsp; <span class="keyword">synchronized</span> (<span class="keyword">this</span>) {</pre></td></tr>
<tr> <td class="numLineCover">&nbsp;208</td> <td class="nbHitsUncovered"><a title="Line 208: Conditional coverage 50% (1/2).">&nbsp;10</a></td> <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 208: Conditional coverage 50% (1/2)."> <span class="keyword">if</span> (shutdownHook != <span class="keyword">null</span>) {</a></span></pre></td></tr>
<tr> <td class="numLine">&nbsp;209</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp; <span class="keyword">try</span> {</pre></td></tr>
<tr> <td class="numLineCover">&nbsp;210</td> <td class="nbHitsCovered">&nbsp;10</td> <td class="src"><pre class="src">&nbsp; Runtime.getRuntime().removeShutdownHook(shutdownHook);</pre></td></tr>
<tr> <td class="numLineCover">&nbsp;211</td> <td class="nbHitsUncovered">&nbsp;0</td> <td class="src"><pre class="src"><span class="srcUncovered">&nbsp; } <span class="keyword">catch</span> (IllegalStateException ex) {</span></pre></td></tr>
<tr> <td class="numLine">&nbsp;212</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp; <span class="comment">// Already executing hook.</span></pre></td></tr>
<tr> <td class="numLineCover">&nbsp;213</td> <td class="nbHitsCovered">&nbsp;10</td> <td class="src"><pre class="src">&nbsp; }</pre></td></tr>
<tr> <td class="numLineCover">&nbsp;214</td> <td class="nbHitsCovered">&nbsp;10</td> <td class="src"><pre class="src">&nbsp; shutdownHook = <span class="keyword">null</span>;</pre></td></tr>
<tr> <td class="numLine">&nbsp;215</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp; }</pre></td></tr>
<tr> <td class="numLineCover">&nbsp;216</td> <td class="nbHitsCovered">&nbsp;10</td> <td class="src"><pre class="src">&nbsp; }</pre></td></tr>
<tr> <td class="numLineCover">&nbsp;217</td> <td class="nbHitsCovered">&nbsp;10</td> <td class="src"><pre class="src">&nbsp; }</pre></td></tr>
<tr> <td class="numLine">&nbsp;218</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr> <td class="numLine">&nbsp;219</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp; <span class="comment">/**</span></pre></td></tr>
<tr> <td class="numLine">&nbsp;220</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp;<span class="comment"> * Stop all the services we provide. This is the opposite of {@link</span></pre></td></tr>
<tr> <td class="numLine">&nbsp;221</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp;<span class="comment"> * #daemonStart}.</span></pre></td></tr>
<tr> <td class="numLine">&nbsp;222</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp;<span class="comment"> */</span></pre></td></tr>
<tr> <td class="numLine">&nbsp;223</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp; <span class="keyword">void</span> daemonStop(<span class="keyword">long</span> time, TimeUnit unit) {</pre></td></tr>
<tr> <td class="numLineCover">&nbsp;224</td> <td class="nbHitsCovered">&nbsp;22</td> <td class="src"><pre class="src">&nbsp; shutdownSemaphore.release();</pre></td></tr>
<tr> <td class="numLine">&nbsp;225</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp; <span class="keyword">try</span> {</pre></td></tr>
<tr> <td class="numLineCover">&nbsp;226</td> <td class="nbHitsCovered">&nbsp;22</td> <td class="src"><pre class="src">&nbsp; <span class="keyword">synchronized</span> (<span class="keyword">this</span>) {</pre></td></tr>
<tr> <td class="numLineCover">&nbsp;227</td> <td class="nbHitsCovered"><a title="Line 227: Conditional coverage 100% (2/2).">&nbsp;22</a></td> <td class="src"><pre class="src">&nbsp;<a title="Line 227: Conditional coverage 100% (2/2)."> <span class="keyword">if</span> (primaryServer == <span class="keyword">null</span>) {</a></pre></td></tr>
<tr> <td class="numLineCover">&nbsp;228</td> <td class="nbHitsCovered">&nbsp;9</td> <td class="src"><pre class="src">&nbsp; <span class="keyword">throw</span> <span class="keyword">new</span> IllegalStateException(<span class="string">"Already stopped"</span>);</pre></td></tr>
<tr> <td class="numLine">&nbsp;229</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp; }</pre></td></tr>
<tr> <td class="numLineCover">&nbsp;230</td> <td class="nbHitsCovered">&nbsp;13</td> <td class="src"><pre class="src">&nbsp; config.removeConfigModificationListener(configModListener);</pre></td></tr>
<tr> <td class="numLineCover">&nbsp;231</td> <td class="nbHitsCovered">&nbsp;13</td> <td class="src"><pre class="src">&nbsp; gsa.stop(time, unit);</pre></td></tr>
<tr> <td class="numLine">&nbsp;232</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp; <span class="keyword">try</span> {</pre></td></tr>
<tr> <td class="numLineCover">&nbsp;233</td> <td class="nbHitsCovered">&nbsp;13</td> <td class="src"><pre class="src">&nbsp; gsa.getAdaptor().destroy();</pre></td></tr>
<tr> <td class="numLine">&nbsp;234</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp; } <span class="keyword">finally</span> {</pre></td></tr>
<tr> <td class="numLineCover">&nbsp;235</td> <td class="nbHitsCovered">&nbsp;13</td> <td class="src"><pre class="src">&nbsp; gsa.teardown();</pre></td></tr>
<tr> <td class="numLineCover">&nbsp;236</td> <td class="nbHitsCovered">&nbsp;13</td> <td class="src"><pre class="src">&nbsp; }</pre></td></tr>
<tr> <td class="numLineCover">&nbsp;237</td> <td class="nbHitsCovered">&nbsp;13</td> <td class="src"><pre class="src">&nbsp; }</pre></td></tr>
<tr> <td class="numLine">&nbsp;238</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp; } <span class="keyword">finally</span> {</pre></td></tr>
<tr> <td class="numLineCover">&nbsp;239</td> <td class="nbHitsCovered">&nbsp;22</td> <td class="src"><pre class="src">&nbsp; <span class="keyword">boolean</span> interrupted = <span class="keyword">false</span>;</pre></td></tr>
<tr> <td class="numLine">&nbsp;240</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp; <span class="keyword">while</span> (<span class="keyword">true</span>) {</pre></td></tr>
<tr> <td class="numLine">&nbsp;241</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp; <span class="keyword">try</span> {</pre></td></tr>
<tr> <td class="numLineCover">&nbsp;242</td> <td class="nbHitsCovered">&nbsp;22</td> <td class="src"><pre class="src">&nbsp; shutdownSemaphore.acquire();</pre></td></tr>
<tr> <td class="numLineCover">&nbsp;243</td> <td class="nbHitsCovered">&nbsp;22</td> <td class="src"><pre class="src">&nbsp; <span class="keyword">break</span>;</pre></td></tr>
<tr> <td class="numLineCover">&nbsp;244</td> <td class="nbHitsUncovered">&nbsp;0</td> <td class="src"><pre class="src"><span class="srcUncovered">&nbsp; } <span class="keyword">catch</span> (InterruptedException ex) {</span></pre></td></tr>
<tr> <td class="numLineCover">&nbsp;245</td> <td class="nbHitsUncovered">&nbsp;0</td> <td class="src"><pre class="src"><span class="srcUncovered">&nbsp; interrupted = <span class="keyword">true</span>;</span></pre></td></tr>
<tr> <td class="numLineCover">&nbsp;246</td> <td class="nbHitsUncovered">&nbsp;0</td> <td class="src"><pre class="src"><span class="srcUncovered">&nbsp; }</span></pre></td></tr>
<tr> <td class="numLine">&nbsp;247</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp; }</pre></td></tr>
<tr> <td class="numLineCover">&nbsp;248</td> <td class="nbHitsUncovered"><a title="Line 248: Conditional coverage 50% (1/2).">&nbsp;22</a></td> <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 248: Conditional coverage 50% (1/2)."> <span class="keyword">if</span> (interrupted) {</a></span></pre></td></tr>
<tr> <td class="numLineCover">&nbsp;249</td> <td class="nbHitsUncovered">&nbsp;0</td> <td class="src"><pre class="src"><span class="srcUncovered">&nbsp; Thread.currentThread().interrupt();</span></pre></td></tr>
<tr> <td class="numLine">&nbsp;250</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp; }</pre></td></tr>
<tr> <td class="numLineCover">&nbsp;251</td> <td class="nbHitsCovered">&nbsp;22</td> <td class="src"><pre class="src">&nbsp; }</pre></td></tr>
<tr> <td class="numLineCover">&nbsp;252</td> <td class="nbHitsCovered">&nbsp;13</td> <td class="src"><pre class="src">&nbsp; }</pre></td></tr>
<tr> <td class="numLine">&nbsp;253</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr> <td class="numLine">&nbsp;254</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp; <span class="comment">/**</span></pre></td></tr>
<tr> <td class="numLine">&nbsp;255</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp;<span class="comment"> * Release reserved resources. This is the opposite of {@link</span></pre></td></tr>
<tr> <td class="numLine">&nbsp;256</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp;<span class="comment"> * #daemonInit}.</span></pre></td></tr>
<tr> <td class="numLine">&nbsp;257</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp;<span class="comment"> */</span></pre></td></tr>
<tr> <td class="numLine">&nbsp;258</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp; <span class="keyword">synchronized</span> <span class="keyword">void</span> daemonDestroy(<span class="keyword">long</span> time, TimeUnit unit) {</pre></td></tr>
<tr> <td class="numLineCover">&nbsp;259</td> <td class="nbHitsCovered">&nbsp;12</td> <td class="src"><pre class="src">&nbsp; httpServerShutdown(primaryServer, time, unit);</pre></td></tr>
<tr> <td class="numLineCover">&nbsp;260</td> <td class="nbHitsCovered">&nbsp;12</td> <td class="src"><pre class="src">&nbsp; log.finer(<span class="string">"Completed primary server stop"</span>);</pre></td></tr>
<tr> <td class="numLineCover">&nbsp;261</td> <td class="nbHitsCovered">&nbsp;12</td> <td class="src"><pre class="src">&nbsp; primaryServer = <span class="keyword">null</span>;</pre></td></tr>
<tr> <td class="numLine">&nbsp;262</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr> <td class="numLineCover">&nbsp;263</td> <td class="nbHitsCovered">&nbsp;12</td> <td class="src"><pre class="src">&nbsp; httpServerShutdown(dashboardServer, time, unit);</pre></td></tr>
<tr> <td class="numLineCover">&nbsp;264</td> <td class="nbHitsCovered">&nbsp;12</td> <td class="src"><pre class="src">&nbsp; log.finer(<span class="string">"Completed dashboard stop"</span>);</pre></td></tr>
<tr> <td class="numLineCover">&nbsp;265</td> <td class="nbHitsCovered">&nbsp;12</td> <td class="src"><pre class="src">&nbsp; dashboardServer = <span class="keyword">null</span>;</pre></td></tr>
<tr> <td class="numLineCover">&nbsp;266</td> <td class="nbHitsCovered">&nbsp;12</td> <td class="src"><pre class="src">&nbsp; }</pre></td></tr>
<tr> <td class="numLine">&nbsp;267</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr> <td class="numLine">&nbsp;268</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp; <span class="keyword">static</span> <span class="keyword">void</span> httpServerShutdown(HttpServer server, <span class="keyword">long</span> time,</pre></td></tr>
<tr> <td class="numLine">&nbsp;269</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp; TimeUnit unit) {</pre></td></tr>
<tr> <td class="numLine">&nbsp;270</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp; <span class="comment">// Workaround Java Bug 7105369.</span></pre></td></tr>
<tr> <td class="numLineCover">&nbsp;271</td> <td class="nbHitsCovered">&nbsp;24</td> <td class="src"><pre class="src">&nbsp; SleepHandler sleepHandler = <span class="keyword">new</span> SleepHandler(100 <span class="comment">/* millis */</span>);</pre></td></tr>
<tr> <td class="numLineCover">&nbsp;272</td> <td class="nbHitsCovered">&nbsp;24</td> <td class="src"><pre class="src">&nbsp; server.createContext(SLEEP_PATH, sleepHandler);</pre></td></tr>
<tr> <td class="numLineCover">&nbsp;273</td> <td class="nbHitsCovered">&nbsp;24</td> <td class="src"><pre class="src">&nbsp; issueSleepGetRequest(server.getAddress(), server <span class="keyword">instanceof</span> HttpsServer);</pre></td></tr>
<tr> <td class="numLine">&nbsp;274</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr> <td class="numLineCover">&nbsp;275</td> <td class="nbHitsCovered">&nbsp;24</td> <td class="src"><pre class="src">&nbsp; server.stop((<span class="keyword">int</span>) unit.toSeconds(time));</pre></td></tr>
<tr> <td class="numLineCover">&nbsp;276</td> <td class="nbHitsCovered">&nbsp;24</td> <td class="src"><pre class="src">&nbsp; ((ExecutorService) server.getExecutor()).shutdownNow();</pre></td></tr>
<tr> <td class="numLineCover">&nbsp;277</td> <td class="nbHitsCovered">&nbsp;24</td> <td class="src"><pre class="src">&nbsp; }</pre></td></tr>
<tr> <td class="numLine">&nbsp;278</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr> <td class="numLine">&nbsp;279</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp; <span class="comment">/**</span></pre></td></tr>
<tr> <td class="numLine">&nbsp;280</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp;<span class="comment"> * Issues a GET request to a SleepHandler. This is used to workaround Java</span></pre></td></tr>
<tr> <td class="numLine">&nbsp;281</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp;<span class="comment"> * Bug 7105369.</span></pre></td></tr>
<tr> <td class="numLine">&nbsp;282</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp;<span class="comment"> *</span></pre></td></tr>
<tr> <td class="numLine">&nbsp;283</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp;<span class="comment"> * &lt;p&gt;The bug is an issue with HttpServer where stop() waits the full amount</span></pre></td></tr>
<tr> <td class="numLine">&nbsp;284</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp;<span class="comment"> * of allotted time if the serve is idle. However, if a request is being</span></pre></td></tr>
<tr> <td class="numLine">&nbsp;285</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp;<span class="comment"> * handled when stop() is called, then it will return as soon as all requests</span></pre></td></tr>
<tr> <td class="numLine">&nbsp;286</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp;<span class="comment"> * are processed, or the allotted time is reached.</span></pre></td></tr>
<tr> <td class="numLine">&nbsp;287</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp;<span class="comment"> *</span></pre></td></tr>
<tr> <td class="numLine">&nbsp;288</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp;<span class="comment"> * &lt;p&gt;Thus, this workaround tries to force a request to be in-procees when</span></pre></td></tr>
<tr> <td class="numLine">&nbsp;289</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp;<span class="comment"> * stop() is called, so that it can return sooner. We issue a request to a</span></pre></td></tr>
<tr> <td class="numLine">&nbsp;290</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp;<span class="comment"> * SleepHandler that takes a fixed amount of time to process the request</span></pre></td></tr>
<tr> <td class="numLine">&nbsp;291</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp;<span class="comment"> * before calling stop(). In the event everything goes as planned, the request</span></pre></td></tr>
<tr> <td class="numLine">&nbsp;292</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp;<span class="comment"> * completes after stop() has been called and allows stop() to exit quickly.</span></pre></td></tr>
<tr> <td class="numLine">&nbsp;293</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp;<span class="comment"> */</span></pre></td></tr>
<tr> <td class="numLine">&nbsp;294</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp; <span class="keyword">private</span> <span class="keyword">static</span> <span class="keyword">void</span> issueSleepGetRequest(InetSocketAddress address,</pre></td></tr>
<tr> <td class="numLine">&nbsp;295</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp; <span class="keyword">boolean</span> isHttps) {</pre></td></tr>
<tr> <td class="numLine">&nbsp;296</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp; URL url;</pre></td></tr>
<tr> <td class="numLine">&nbsp;297</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp; <span class="keyword">try</span> {</pre></td></tr>
<tr> <td class="numLineCover">&nbsp;298</td> <td class="nbHitsCovered"><a title="Line 298: Conditional coverage 100% (2/2).">&nbsp;24</a></td> <td class="src"><pre class="src">&nbsp;<a title="Line 298: Conditional coverage 100% (2/2)."> url = <span class="keyword">new</span> URL(isHttps ? <span class="string">"https"</span> : <span class="string">"http"</span>,</a></pre></td></tr>
<tr> <td class="numLine">&nbsp;299</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp; address.getAddress().getHostAddress(), address.getPort(), SLEEP_PATH);</pre></td></tr>
<tr> <td class="numLineCover">&nbsp;300</td> <td class="nbHitsUncovered">&nbsp;0</td> <td class="src"><pre class="src"><span class="srcUncovered">&nbsp; } <span class="keyword">catch</span> (MalformedURLException ex) {</span></pre></td></tr>
<tr> <td class="numLineCover">&nbsp;301</td> <td class="nbHitsUncovered">&nbsp;0</td> <td class="src"><pre class="src"><span class="srcUncovered">&nbsp; log.log(Level.WARNING,</span></pre></td></tr>
<tr> <td class="numLine">&nbsp;302</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp; <span class="string">"Unexpected error. Shutting down will be slow."</span>, ex);</pre></td></tr>
<tr> <td class="numLineCover">&nbsp;303</td> <td class="nbHitsUncovered">&nbsp;0</td> <td class="src"><pre class="src"><span class="srcUncovered">&nbsp; <span class="keyword">return</span>;</span></pre></td></tr>
<tr> <td class="numLineCover">&nbsp;304</td> <td class="nbHitsCovered">&nbsp;24</td> <td class="src"><pre class="src">&nbsp; }</pre></td></tr>
<tr> <td class="numLine">&nbsp;305</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr> <td class="numLine">&nbsp;306</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp; <span class="keyword">final</span> URLConnection conn;</pre></td></tr>
<tr> <td class="numLine">&nbsp;307</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp; <span class="keyword">try</span> {</pre></td></tr>
<tr> <td class="numLineCover">&nbsp;308</td> <td class="nbHitsCovered">&nbsp;24</td> <td class="src"><pre class="src">&nbsp; conn = url.openConnection();</pre></td></tr>
<tr> <td class="numLineCover">&nbsp;309</td> <td class="nbHitsCovered">&nbsp;24</td> <td class="src"><pre class="src">&nbsp; conn.connect();</pre></td></tr>
<tr> <td class="numLineCover">&nbsp;310</td> <td class="nbHitsCovered">&nbsp;2</td> <td class="src"><pre class="src">&nbsp; } <span class="keyword">catch</span> (IOException ex) {</pre></td></tr>
<tr> <td class="numLineCover">&nbsp;311</td> <td class="nbHitsCovered">&nbsp;2</td> <td class="src"><pre class="src">&nbsp; log.log(Level.WARNING, <span class="string">"Error performing shutdown GET"</span>, ex);</pre></td></tr>
<tr> <td class="numLineCover">&nbsp;312</td> <td class="nbHitsCovered">&nbsp;2</td> <td class="src"><pre class="src">&nbsp; <span class="keyword">return</span>;</pre></td></tr>
<tr> <td class="numLineCover">&nbsp;313</td> <td class="nbHitsCovered">&nbsp;22</td> <td class="src"><pre class="src">&nbsp; }</pre></td></tr>
<tr> <td class="numLine">&nbsp;314</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp; <span class="keyword">try</span> {</pre></td></tr>
<tr> <td class="numLine">&nbsp;315</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp; <span class="comment">// Provide some time for the connect() to be processed on the server.</span></pre></td></tr>
<tr> <td class="numLineCover">&nbsp;316</td> <td class="nbHitsCovered">&nbsp;22</td> <td class="src"><pre class="src">&nbsp; Thread.sleep(15);</pre></td></tr>
<tr> <td class="numLineCover">&nbsp;317</td> <td class="nbHitsUncovered">&nbsp;0</td> <td class="src"><pre class="src"><span class="srcUncovered">&nbsp; } <span class="keyword">catch</span> (InterruptedException ex) {</span></pre></td></tr>
<tr> <td class="numLineCover">&nbsp;318</td> <td class="nbHitsUncovered">&nbsp;0</td> <td class="src"><pre class="src"><span class="srcUncovered">&nbsp; Thread.currentThread().interrupt();</span></pre></td></tr>
<tr> <td class="numLineCover">&nbsp;319</td> <td class="nbHitsCovered">&nbsp;22</td> <td class="src"><pre class="src">&nbsp; }</pre></td></tr>
<tr> <td class="numLineCover">&nbsp;320</td> <td class="nbHitsCovered">&nbsp;22</td> <td class="src"><pre class="src">&nbsp; <span class="keyword">new</span> Thread(<span class="keyword">new</span> Runnable() {</pre></td></tr>
<tr> <td class="numLine">&nbsp;321</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp; @Override</pre></td></tr>
<tr> <td class="numLine">&nbsp;322</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp; <span class="keyword">public</span> <span class="keyword">void</span> run() {</pre></td></tr>
<tr> <td class="numLine">&nbsp;323</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp; <span class="keyword">try</span> {</pre></td></tr>
<tr> <td class="numLineCover">&nbsp;324</td> <td class="nbHitsCovered">&nbsp;22</td> <td class="src"><pre class="src">&nbsp; conn.getInputStream().close();</pre></td></tr>
<tr> <td class="numLineCover">&nbsp;325</td> <td class="nbHitsCovered">&nbsp;6</td> <td class="src"><pre class="src">&nbsp; log.finer(<span class="string">"Closed shutdown GET"</span>);</pre></td></tr>
<tr> <td class="numLineCover">&nbsp;326</td> <td class="nbHitsCovered">&nbsp;16</td> <td class="src"><pre class="src">&nbsp; } <span class="keyword">catch</span> (IOException ex) {</pre></td></tr>
<tr> <td class="numLineCover">&nbsp;327</td> <td class="nbHitsCovered">&nbsp;16</td> <td class="src"><pre class="src">&nbsp; log.log(Level.WARNING, <span class="string">"Error closing stream of shutdown GET"</span>, ex);</pre></td></tr>
<tr> <td class="numLineCover">&nbsp;328</td> <td class="nbHitsCovered">&nbsp;6</td> <td class="src"><pre class="src">&nbsp; }</pre></td></tr>
<tr> <td class="numLineCover">&nbsp;329</td> <td class="nbHitsCovered">&nbsp;22</td> <td class="src"><pre class="src">&nbsp; }</pre></td></tr>
<tr> <td class="numLine">&nbsp;330</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp; }).start();</pre></td></tr>
<tr> <td class="numLineCover">&nbsp;331</td> <td class="nbHitsCovered">&nbsp;22</td> <td class="src"><pre class="src">&nbsp; }</pre></td></tr>
<tr> <td class="numLine">&nbsp;332</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr> <td class="numLine">&nbsp;333</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp; <span class="keyword">static</span> HttpServer createHttpServer(Config config) <span class="keyword">throws</span> IOException {</pre></td></tr>
<tr> <td class="numLine">&nbsp;334</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp; HttpServer server;</pre></td></tr>
<tr> <td class="numLineCover">&nbsp;335</td> <td class="nbHitsCovered"><a title="Line 335: Conditional coverage 100% (2/2).">&nbsp;12</a></td> <td class="src"><pre class="src">&nbsp;<a title="Line 335: Conditional coverage 100% (2/2)."> <span class="keyword">if</span> (!config.isServerSecure()) {</a></pre></td></tr>
<tr> <td class="numLineCover">&nbsp;336</td> <td class="nbHitsCovered">&nbsp;11</td> <td class="src"><pre class="src">&nbsp; server = HttpServer.create();</pre></td></tr>
<tr> <td class="numLine">&nbsp;337</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp; } <span class="keyword">else</span> {</pre></td></tr>
<tr> <td class="numLineCover">&nbsp;338</td> <td class="nbHitsCovered">&nbsp;1</td> <td class="src"><pre class="src">&nbsp; server = HttpsServer.create();</pre></td></tr>
<tr> <td class="numLine">&nbsp;339</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp; <span class="keyword">try</span> {</pre></td></tr>
<tr> <td class="numLineCover">&nbsp;340</td> <td class="nbHitsCovered">&nbsp;1</td> <td class="src"><pre class="src">&nbsp; HttpsConfigurator httpsConf</pre></td></tr>
<tr> <td class="numLineCover">&nbsp;341</td> <td class="nbHitsCovered">&nbsp;1</td> <td class="src"><pre class="src">&nbsp; = <span class="keyword">new</span> HttpsConfigurator(SSLContext.getDefault()) {</pre></td></tr>
<tr> <td class="numLine">&nbsp;342</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp; <span class="keyword">public</span> <span class="keyword">void</span> configure(HttpsParameters params) {</pre></td></tr>
<tr> <td class="numLineCover">&nbsp;343</td> <td class="nbHitsCovered">&nbsp;2</td> <td class="src"><pre class="src">&nbsp; SSLParameters sslParams</pre></td></tr>
<tr> <td class="numLine">&nbsp;344</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp; = getSSLContext().getDefaultSSLParameters();</pre></td></tr>
<tr> <td class="numLine">&nbsp;345</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp; <span class="comment">// Allow verifying the GSA and other trusted computers.</span></pre></td></tr>
<tr> <td class="numLineCover">&nbsp;346</td> <td class="nbHitsCovered">&nbsp;2</td> <td class="src"><pre class="src">&nbsp; sslParams.setWantClientAuth(<span class="keyword">true</span>);</pre></td></tr>
<tr> <td class="numLineCover">&nbsp;347</td> <td class="nbHitsCovered">&nbsp;2</td> <td class="src"><pre class="src">&nbsp; params.setSSLParameters(sslParams);</pre></td></tr>
<tr> <td class="numLineCover">&nbsp;348</td> <td class="nbHitsCovered">&nbsp;2</td> <td class="src"><pre class="src">&nbsp; }</pre></td></tr>
<tr> <td class="numLine">&nbsp;349</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp; };</pre></td></tr>
<tr> <td class="numLineCover">&nbsp;350</td> <td class="nbHitsCovered">&nbsp;1</td> <td class="src"><pre class="src">&nbsp; ((HttpsServer) server).setHttpsConfigurator(httpsConf);</pre></td></tr>
<tr> <td class="numLineCover">&nbsp;351</td> <td class="nbHitsUncovered">&nbsp;0</td> <td class="src"><pre class="src"><span class="srcUncovered">&nbsp; } <span class="keyword">catch</span> (java.security.NoSuchAlgorithmException ex) {</span></pre></td></tr>
<tr> <td class="numLineCover">&nbsp;352</td> <td class="nbHitsUncovered">&nbsp;0</td> <td class="src"><pre class="src"><span class="srcUncovered">&nbsp; <span class="keyword">throw</span> <span class="keyword">new</span> RuntimeException(ex);</span></pre></td></tr>
<tr> <td class="numLineCover">&nbsp;353</td> <td class="nbHitsCovered">&nbsp;1</td> <td class="src"><pre class="src">&nbsp; }</pre></td></tr>
<tr> <td class="numLine">&nbsp;354</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp; }</pre></td></tr>
<tr> <td class="numLine">&nbsp;355</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr> <td class="numLineCover">&nbsp;356</td> <td class="nbHitsCovered">&nbsp;12</td> <td class="src"><pre class="src">&nbsp; <span class="keyword">int</span> maxThreads = config.getServerMaxWorkerThreads();</pre></td></tr>
<tr> <td class="numLineCover">&nbsp;357</td> <td class="nbHitsCovered">&nbsp;12</td> <td class="src"><pre class="src">&nbsp; <span class="keyword">int</span> queueCapacity = config.getServerQueueCapacity();</pre></td></tr>
<tr> <td class="numLineCover">&nbsp;358</td> <td class="nbHitsCovered">&nbsp;12</td> <td class="src"><pre class="src">&nbsp; BlockingQueue&lt;Runnable&gt; blockingQueue</pre></td></tr>
<tr> <td class="numLine">&nbsp;359</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp; = <span class="keyword">new</span> ArrayBlockingQueue&lt;Runnable&gt;(queueCapacity);</pre></td></tr>
<tr> <td class="numLine">&nbsp;360</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp; <span class="comment">// The Executor can't reject jobs directly, because HttpServer does not</span></pre></td></tr>
<tr> <td class="numLine">&nbsp;361</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp; <span class="comment">// appear to handle that case.</span></pre></td></tr>
<tr> <td class="numLineCover">&nbsp;362</td> <td class="nbHitsCovered">&nbsp;12</td> <td class="src"><pre class="src">&nbsp; RejectedExecutionHandler policy</pre></td></tr>
<tr> <td class="numLine">&nbsp;363</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp; = <span class="keyword">new</span> SuggestHandlerAbortPolicy(HttpExchanges.abortImmediately);</pre></td></tr>
<tr> <td class="numLineCover">&nbsp;364</td> <td class="nbHitsCovered">&nbsp;12</td> <td class="src"><pre class="src">&nbsp; Executor executor = <span class="keyword">new</span> ThreadPoolExecutor(maxThreads, maxThreads,</pre></td></tr>
<tr> <td class="numLine">&nbsp;365</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp; 1, TimeUnit.MINUTES, blockingQueue, policy);</pre></td></tr>
<tr> <td class="numLineCover">&nbsp;366</td> <td class="nbHitsCovered">&nbsp;12</td> <td class="src"><pre class="src">&nbsp; server.setExecutor(executor);</pre></td></tr>
<tr> <td class="numLine">&nbsp;367</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr> <td class="numLineCover">&nbsp;368</td> <td class="nbHitsCovered">&nbsp;12</td> <td class="src"><pre class="src">&nbsp; server.bind(<span class="keyword">new</span> InetSocketAddress(config.getServerPort()), 0);</pre></td></tr>
<tr> <td class="numLineCover">&nbsp;369</td> <td class="nbHitsCovered">&nbsp;12</td> <td class="src"><pre class="src">&nbsp; log.info(<span class="string">"GSA host name: "</span> + config.getGsaHostname());</pre></td></tr>
<tr> <td class="numLineCover">&nbsp;370</td> <td class="nbHitsCovered">&nbsp;12</td> <td class="src"><pre class="src">&nbsp; log.info(<span class="string">"server is listening on port #"</span> + server.getAddress().getPort());</pre></td></tr>
<tr> <td class="numLineCover">&nbsp;371</td> <td class="nbHitsCovered">&nbsp;12</td> <td class="src"><pre class="src">&nbsp; <span class="keyword">return</span> server;</pre></td></tr>
<tr> <td class="numLine">&nbsp;372</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp; }</pre></td></tr>
<tr> <td class="numLine">&nbsp;373</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr> <td class="numLine">&nbsp;374</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp; <span class="keyword">static</span> HttpServer createDashboardHttpServer(Config config)</pre></td></tr>
<tr> <td class="numLine">&nbsp;375</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp; <span class="keyword">throws</span> IOException {</pre></td></tr>
<tr> <td class="numLineCover">&nbsp;376</td> <td class="nbHitsCovered">&nbsp;12</td> <td class="src"><pre class="src">&nbsp; <span class="keyword">boolean</span> secure = config.isServerSecure();</pre></td></tr>
<tr> <td class="numLine">&nbsp;377</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp; HttpServer server;</pre></td></tr>
<tr> <td class="numLineCover">&nbsp;378</td> <td class="nbHitsCovered"><a title="Line 378: Conditional coverage 100% (2/2).">&nbsp;12</a></td> <td class="src"><pre class="src">&nbsp;<a title="Line 378: Conditional coverage 100% (2/2)."> <span class="keyword">if</span> (!secure) {</a></pre></td></tr>
<tr> <td class="numLineCover">&nbsp;379</td> <td class="nbHitsCovered">&nbsp;11</td> <td class="src"><pre class="src">&nbsp; server = HttpServer.create();</pre></td></tr>
<tr> <td class="numLine">&nbsp;380</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp; } <span class="keyword">else</span> {</pre></td></tr>
<tr> <td class="numLineCover">&nbsp;381</td> <td class="nbHitsCovered">&nbsp;1</td> <td class="src"><pre class="src">&nbsp; server = HttpsServer.create();</pre></td></tr>
<tr> <td class="numLine">&nbsp;382</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp; SSLContext defaultSslContext;</pre></td></tr>
<tr> <td class="numLine">&nbsp;383</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp; <span class="keyword">try</span> {</pre></td></tr>
<tr> <td class="numLineCover">&nbsp;384</td> <td class="nbHitsCovered">&nbsp;1</td> <td class="src"><pre class="src">&nbsp; defaultSslContext = SSLContext.getDefault();</pre></td></tr>
<tr> <td class="numLineCover">&nbsp;385</td> <td class="nbHitsUncovered">&nbsp;0</td> <td class="src"><pre class="src"><span class="srcUncovered">&nbsp; } <span class="keyword">catch</span> (NoSuchAlgorithmException ex) {</span></pre></td></tr>
<tr> <td class="numLineCover">&nbsp;386</td> <td class="nbHitsUncovered">&nbsp;0</td> <td class="src"><pre class="src"><span class="srcUncovered">&nbsp; <span class="keyword">throw</span> <span class="keyword">new</span> RuntimeException(ex);</span></pre></td></tr>
<tr> <td class="numLineCover">&nbsp;387</td> <td class="nbHitsCovered">&nbsp;1</td> <td class="src"><pre class="src">&nbsp; }</pre></td></tr>
<tr> <td class="numLineCover">&nbsp;388</td> <td class="nbHitsCovered">&nbsp;1</td> <td class="src"><pre class="src">&nbsp; HttpsConfigurator httpsConf = <span class="keyword">new</span> HttpsConfigurator(defaultSslContext);</pre></td></tr>
<tr> <td class="numLineCover">&nbsp;389</td> <td class="nbHitsCovered">&nbsp;1</td> <td class="src"><pre class="src">&nbsp; ((HttpsServer) server).setHttpsConfigurator(httpsConf);</pre></td></tr>
<tr> <td class="numLine">&nbsp;390</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp; }</pre></td></tr>
<tr> <td class="numLine">&nbsp;391</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp; <span class="comment">// The Dashboard is on a separate port to prevent malicious HTML documents</span></pre></td></tr>
<tr> <td class="numLine">&nbsp;392</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp; <span class="comment">// in the user's repository from performing admin actions with</span></pre></td></tr>
<tr> <td class="numLine">&nbsp;393</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp; <span class="comment">// XMLHttpRequest or the like, as the HTML page will then be blocked by</span></pre></td></tr>
<tr> <td class="numLine">&nbsp;394</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp; <span class="comment">// same-origin policies.</span></pre></td></tr>
<tr> <td class="numLineCover">&nbsp;395</td> <td class="nbHitsCovered">&nbsp;12</td> <td class="src"><pre class="src">&nbsp; server.bind(<span class="keyword">new</span> InetSocketAddress(config.getServerDashboardPort()), 0);</pre></td></tr>
<tr> <td class="numLine">&nbsp;396</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr> <td class="numLine">&nbsp;397</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp; <span class="comment">// Use separate Executor for Dashboard to allow the administrator to</span></pre></td></tr>
<tr> <td class="numLine">&nbsp;398</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp; <span class="comment">// investigate why things are going wrong without waiting on the normal work</span></pre></td></tr>
<tr> <td class="numLine">&nbsp;399</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp; <span class="comment">// queue.</span></pre></td></tr>
<tr> <td class="numLineCover">&nbsp;400</td> <td class="nbHitsCovered">&nbsp;12</td> <td class="src"><pre class="src">&nbsp; <span class="keyword">int</span> maxThreads = 4;</pre></td></tr>
<tr> <td class="numLineCover">&nbsp;401</td> <td class="nbHitsCovered">&nbsp;12</td> <td class="src"><pre class="src">&nbsp; Executor executor = <span class="keyword">new</span> ThreadPoolExecutor(maxThreads, maxThreads,</pre></td></tr>
<tr> <td class="numLine">&nbsp;402</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp; 10, TimeUnit.MINUTES, <span class="keyword">new</span> LinkedBlockingQueue&lt;Runnable&gt;());</pre></td></tr>
<tr> <td class="numLineCover">&nbsp;403</td> <td class="nbHitsCovered">&nbsp;12</td> <td class="src"><pre class="src">&nbsp; server.setExecutor(executor);</pre></td></tr>
<tr> <td class="numLine">&nbsp;404</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr> <td class="numLineCover">&nbsp;405</td> <td class="nbHitsCovered">&nbsp;12</td> <td class="src"><pre class="src">&nbsp; log.info(<span class="string">"dashboard is listening on port #"</span></pre></td></tr>
<tr> <td class="numLine">&nbsp;406</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp; + server.getAddress().getPort());</pre></td></tr>
<tr> <td class="numLine">&nbsp;407</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr> <td class="numLineCover">&nbsp;408</td> <td class="nbHitsCovered">&nbsp;12</td> <td class="src"><pre class="src">&nbsp; <span class="keyword">return</span> server;</pre></td></tr>
<tr> <td class="numLine">&nbsp;409</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp; }</pre></td></tr>
<tr> <td class="numLine">&nbsp;410</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr> <td class="numLine">&nbsp;411</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp; <span class="comment">/** Returns the {@link GsaCommunicationHandler} used by this instance. */</span></pre></td></tr>
<tr> <td class="numLine">&nbsp;412</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp; <span class="keyword">public</span> GsaCommunicationHandler getGsaCommunicationHandler() {</pre></td></tr>
<tr> <td class="numLineCover">&nbsp;413</td> <td class="nbHitsCovered">&nbsp;1</td> <td class="src"><pre class="src">&nbsp; <span class="keyword">return</span> gsa;</pre></td></tr>
<tr> <td class="numLine">&nbsp;414</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp; }</pre></td></tr>
<tr> <td class="numLine">&nbsp;415</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr> <td class="numLine">&nbsp;416</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp; <span class="comment">/** Returns the {@link Config} used by this instance. */</span></pre></td></tr>
<tr> <td class="numLine">&nbsp;417</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp; <span class="keyword">public</span> Config getConfig() {</pre></td></tr>
<tr> <td class="numLineCover">&nbsp;418</td> <td class="nbHitsCovered">&nbsp;1</td> <td class="src"><pre class="src">&nbsp; <span class="keyword">return</span> config;</pre></td></tr>
<tr> <td class="numLine">&nbsp;419</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp; }</pre></td></tr>
<tr> <td class="numLine">&nbsp;420</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr> <td class="numLine">&nbsp;421</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp; <span class="comment">/**</span></pre></td></tr>
<tr> <td class="numLine">&nbsp;422</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp;<span class="comment"> * Load default configuration file and parse command line options.</span></pre></td></tr>
<tr> <td class="numLine">&nbsp;423</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp;<span class="comment"> *</span></pre></td></tr>
<tr> <td class="numLine">&nbsp;424</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp;<span class="comment"> * @return unused command line arguments</span></pre></td></tr>
<tr> <td class="numLine">&nbsp;425</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp;<span class="comment"> * @throws IllegalStateException when not all configuration keys have values</span></pre></td></tr>
<tr> <td class="numLine">&nbsp;426</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp;<span class="comment"> */</span></pre></td></tr>
<tr> <td class="numLine">&nbsp;427</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp; <span class="keyword">static</span> String[] autoConfig(Config config, String[] args, File configFile) {</pre></td></tr>
<tr> <td class="numLineCover">&nbsp;428</td> <td class="nbHitsCovered">&nbsp;7</td> <td class="src"><pre class="src">&nbsp; File sysPropertiesAdditions = <span class="keyword">null</span>;</pre></td></tr>
<tr> <td class="numLine">&nbsp;429</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp; <span class="keyword">int</span> i;</pre></td></tr>
<tr> <td class="numLineCover">&nbsp;430</td> <td class="nbHitsCovered"><a title="Line 430: Conditional coverage 100% (2/2).">&nbsp;20</a></td> <td class="src"><pre class="src">&nbsp;<a title="Line 430: Conditional coverage 100% (2/2)."> <span class="keyword">for</span> (i = 0; i &lt; args.length; i++) {</a></pre></td></tr>
<tr> <td class="numLineCover">&nbsp;431</td> <td class="nbHitsUncovered"><a title="Line 431: Conditional coverage 50% (1/2).">&nbsp;13</a></td> <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 431: Conditional coverage 50% (1/2)."> <span class="keyword">if</span> (!args[i].startsWith(<span class="string">"-D"</span>)) {</a></span></pre></td></tr>
<tr> <td class="numLineCover">&nbsp;432</td> <td class="nbHitsUncovered">&nbsp;0</td> <td class="src"><pre class="src"><span class="srcUncovered">&nbsp; <span class="keyword">break</span>;</span></pre></td></tr>
<tr> <td class="numLine">&nbsp;433</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp; }</pre></td></tr>
<tr> <td class="numLineCover">&nbsp;434</td> <td class="nbHitsCovered">&nbsp;13</td> <td class="src"><pre class="src">&nbsp; String arg = args[i].substring(2);</pre></td></tr>
<tr> <td class="numLineCover">&nbsp;435</td> <td class="nbHitsCovered">&nbsp;13</td> <td class="src"><pre class="src">&nbsp; String[] parts = arg.split(<span class="string">"="</span>, 2);</pre></td></tr>
<tr> <td class="numLineCover">&nbsp;436</td> <td class="nbHitsUncovered"><a title="Line 436: Conditional coverage 50% (1/2).">&nbsp;13</a></td> <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 436: Conditional coverage 50% (1/2)."> <span class="keyword">if</span> (parts.length &lt; 2) {</a></span></pre></td></tr>
<tr> <td class="numLineCover">&nbsp;437</td> <td class="nbHitsUncovered">&nbsp;0</td> <td class="src"><pre class="src"><span class="srcUncovered">&nbsp; <span class="keyword">break</span>;</span></pre></td></tr>
<tr> <td class="numLine">&nbsp;438</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp; }</pre></td></tr>
<tr> <td class="numLineCover">&nbsp;439</td> <td class="nbHitsCovered"><a title="Line 439: Conditional coverage 100% (2/2).">&nbsp;13</a></td> <td class="src"><pre class="src">&nbsp;<a title="Line 439: Conditional coverage 100% (2/2)."> <span class="keyword">if</span> (<span class="string">"adaptor.configfile"</span>.equals(parts[0])) {</a></pre></td></tr>
<tr> <td class="numLineCover">&nbsp;440</td> <td class="nbHitsCovered">&nbsp;2</td> <td class="src"><pre class="src">&nbsp; configFile = <span class="keyword">new</span> File(parts[1]);</pre></td></tr>
<tr> <td class="numLineCover">&nbsp;441</td> <td class="nbHitsCovered"><a title="Line 441: Conditional coverage 100% (2/2).">&nbsp;11</a></td> <td class="src"><pre class="src">&nbsp;<a title="Line 441: Conditional coverage 100% (2/2)."> } <span class="keyword">else</span> <span class="keyword">if</span> (<span class="string">"sys.properties.file"</span>.equals(parts[0])) {</a></pre></td></tr>
<tr> <td class="numLineCover">&nbsp;442</td> <td class="nbHitsCovered">&nbsp;1</td> <td class="src"><pre class="src">&nbsp; sysPropertiesAdditions = <span class="keyword">new</span> File(parts[1]);</pre></td></tr>
<tr> <td class="numLine">&nbsp;443</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp; } <span class="keyword">else</span> {</pre></td></tr>
<tr> <td class="numLineCover">&nbsp;444</td> <td class="nbHitsCovered">&nbsp;10</td> <td class="src"><pre class="src">&nbsp; config.setValue(parts[0], parts[1]);</pre></td></tr>
<tr> <td class="numLine">&nbsp;445</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp; }</pre></td></tr>
<tr> <td class="numLine">&nbsp;446</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp; }</pre></td></tr>
<tr> <td class="numLineCover">&nbsp;447</td> <td class="nbHitsCovered">&nbsp;7</td> <td class="src"><pre class="src">&nbsp; processSystemProperties(sysPropertiesAdditions);</pre></td></tr>
<tr> <td class="numLineCover">&nbsp;448</td> <td class="nbHitsCovered">&nbsp;7</td> <td class="src"><pre class="src">&nbsp; loadConfigFile(config, configFile);</pre></td></tr>
<tr> <td class="numLineCover">&nbsp;449</td> <td class="nbHitsCovered">&nbsp;7</td> <td class="src"><pre class="src">&nbsp; config.validate();</pre></td></tr>
<tr> <td class="numLineCover">&nbsp;450</td> <td class="nbHitsCovered"><a title="Line 450: Conditional coverage 100% (2/2).">&nbsp;6</a></td> <td class="src"><pre class="src">&nbsp;<a title="Line 450: Conditional coverage 100% (2/2)."> <span class="keyword">if</span> (i == 0) {</a></pre></td></tr>
<tr> <td class="numLineCover">&nbsp;451</td> <td class="nbHitsCovered">&nbsp;1</td> <td class="src"><pre class="src">&nbsp; <span class="keyword">return</span> args;</pre></td></tr>
<tr> <td class="numLine">&nbsp;452</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp; } <span class="keyword">else</span> {</pre></td></tr>
<tr> <td class="numLineCover">&nbsp;453</td> <td class="nbHitsCovered">&nbsp;5</td> <td class="src"><pre class="src">&nbsp; <span class="keyword">return</span> Arrays.copyOfRange(args, i, args.length);</pre></td></tr>
<tr> <td class="numLine">&nbsp;454</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp; }</pre></td></tr>
<tr> <td class="numLine">&nbsp;455</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp; }</pre></td></tr>
<tr> <td class="numLine">&nbsp;456</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr> <td class="numLine">&nbsp;457</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp; <span class="keyword">private</span> <span class="keyword">static</span> <span class="keyword">void</span> processSystemProperties(File extraProps) {</pre></td></tr>
<tr> <td class="numLineCover">&nbsp;458</td> <td class="nbHitsCovered"><a title="Line 458: Conditional coverage 100% (2/2).">&nbsp;7</a></td> <td class="src"><pre class="src">&nbsp;<a title="Line 458: Conditional coverage 100% (2/2)."> <span class="keyword">if</span> (<span class="keyword">null</span> == extraProps) {</a></pre></td></tr>
<tr> <td class="numLineCover">&nbsp;459</td> <td class="nbHitsCovered">&nbsp;6</td> <td class="src"><pre class="src">&nbsp; log.log(Level.CONFIG, <span class="string">"no extra system properties to load"</span>);</pre></td></tr>
<tr> <td class="numLineCover">&nbsp;460</td> <td class="nbHitsCovered">&nbsp;6</td> <td class="src"><pre class="src">&nbsp; <span class="keyword">return</span>;</pre></td></tr>
<tr> <td class="numLine">&nbsp;461</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp; }</pre></td></tr>
<tr> <td class="numLine">&nbsp;462</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp; <span class="keyword">try</span> {</pre></td></tr>
<tr> <td class="numLineCover">&nbsp;463</td> <td class="nbHitsCovered">&nbsp;1</td> <td class="src"><pre class="src">&nbsp; FileInputStream extras = <span class="keyword">new</span> FileInputStream(extraProps);</pre></td></tr>
<tr> <td class="numLineCover">&nbsp;464</td> <td class="nbHitsCovered">&nbsp;1</td> <td class="src"><pre class="src">&nbsp; processSystemProperties(extras);</pre></td></tr>
<tr> <td class="numLineCover">&nbsp;465</td> <td class="nbHitsCovered">&nbsp;1</td> <td class="src"><pre class="src">&nbsp; extras.close();</pre></td></tr>
<tr> <td class="numLineCover">&nbsp;466</td> <td class="nbHitsUncovered">&nbsp;0</td> <td class="src"><pre class="src"><span class="srcUncovered">&nbsp; } <span class="keyword">catch</span> (IOException e) {</span></pre></td></tr>
<tr> <td class="numLineCover">&nbsp;467</td> <td class="nbHitsUncovered">&nbsp;0</td> <td class="src"><pre class="src"><span class="srcUncovered">&nbsp; log.log(Level.CONFIG, <span class="string">"could not read system properties file {0}"</span>,</span></pre></td></tr>
<tr> <td class="numLine">&nbsp;468</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp; extraProps.getAbsolutePath());</pre></td></tr>
<tr> <td class="numLineCover">&nbsp;469</td> <td class="nbHitsCovered">&nbsp;1</td> <td class="src"><pre class="src">&nbsp; }</pre></td></tr>
<tr> <td class="numLineCover">&nbsp;470</td> <td class="nbHitsCovered">&nbsp;1</td> <td class="src"><pre class="src">&nbsp; }</pre></td></tr>
<tr> <td class="numLine">&nbsp;471</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr> <td class="numLine">&nbsp;472</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp; <span class="keyword">private</span> <span class="keyword">static</span> <span class="keyword">void</span> processSystemProperties(InputStream extraProps) </pre></td></tr>
<tr> <td class="numLine">&nbsp;473</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp; <span class="keyword">throws</span> IOException {</pre></td></tr>
<tr> <td class="numLineCover">&nbsp;474</td> <td class="nbHitsCovered">&nbsp;1</td> <td class="src"><pre class="src">&nbsp; Properties extra = <span class="keyword">new</span> Properties();</pre></td></tr>
<tr> <td class="numLineCover">&nbsp;475</td> <td class="nbHitsCovered">&nbsp;1</td> <td class="src"><pre class="src">&nbsp; extra.load(extraProps);</pre></td></tr>
<tr> <td class="numLineCover">&nbsp;476</td> <td class="nbHitsCovered"><a title="Line 476: Conditional coverage 100% (2/2).">&nbsp;1</a></td> <td class="src"><pre class="src">&nbsp;<a title="Line 476: Conditional coverage 100% (2/2)."> <span class="keyword">for</span> (Entry&lt;Object, Object&gt; e : extra.entrySet()) {</a></pre></td></tr>
<tr> <td class="numLineCover">&nbsp;477</td> <td class="nbHitsCovered">&nbsp;2</td> <td class="src"><pre class="src">&nbsp; String previous = System.setProperty(<span class="string">""</span> + e.getKey(), <span class="string">""</span> + e.getValue());</pre></td></tr>
<tr> <td class="numLineCover">&nbsp;478</td> <td class="nbHitsCovered">&nbsp;2</td> <td class="src"><pre class="src">&nbsp; log.log(Level.FINE, <span class="string">"sys property {0} set to {1}; was {2}"</span>,</pre></td></tr>
<tr> <td class="numLine">&nbsp;479</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp; <span class="keyword">new</span> Object[] {e.getKey(), e.getValue(), previous}); </pre></td></tr>
<tr> <td class="numLineCover">&nbsp;480</td> <td class="nbHitsCovered">&nbsp;2</td> <td class="src"><pre class="src">&nbsp; }</pre></td></tr>
<tr> <td class="numLineCover">&nbsp;481</td> <td class="nbHitsCovered">&nbsp;1</td> <td class="src"><pre class="src">&nbsp; }</pre></td></tr>
<tr> <td class="numLine">&nbsp;482</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr> <td class="numLine">&nbsp;483</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp; <span class="comment">/**</span></pre></td></tr>
<tr> <td class="numLine">&nbsp;484</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp;<span class="comment"> * Loads the provided config file, if it exists. It squelches any errors so</span></pre></td></tr>
<tr> <td class="numLine">&nbsp;485</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp;<span class="comment"> * that you are free to call it without error handling, since this is</span></pre></td></tr>
<tr> <td class="numLine">&nbsp;486</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp;<span class="comment"> * typically non-fatal.</span></pre></td></tr>
<tr> <td class="numLine">&nbsp;487</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp;<span class="comment"> */</span></pre></td></tr>
<tr> <td class="numLine">&nbsp;488</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp; <span class="keyword">private</span> <span class="keyword">static</span> <span class="keyword">void</span> loadConfigFile(Config config, File configFile) {</pre></td></tr>
<tr> <td class="numLineCover">&nbsp;489</td> <td class="nbHitsUncovered"><a title="Line 489: Conditional coverage 83% (5/6) [each condition: 100%, 100%, 50%].">&nbsp;7</a></td> <td class="src"><pre class="src"><span class="srcUncovered">&nbsp;<a title="Line 489: Conditional coverage 83% (5/6) [each condition: 100%, 100%, 50%]."> <span class="keyword">if</span> (<span class="keyword">null</span> != configFile &amp;&amp; configFile.exists() &amp;&amp; configFile.isFile()) {</a></span></pre></td></tr>
<tr> <td class="numLine">&nbsp;490</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp; <span class="keyword">try</span> {</pre></td></tr>
<tr> <td class="numLineCover">&nbsp;491</td> <td class="nbHitsCovered">&nbsp;2</td> <td class="src"><pre class="src">&nbsp; config.load(configFile);</pre></td></tr>
<tr> <td class="numLineCover">&nbsp;492</td> <td class="nbHitsUncovered">&nbsp;0</td> <td class="src"><pre class="src"><span class="srcUncovered">&nbsp; } <span class="keyword">catch</span> (IOException ex) {</span></pre></td></tr>
<tr> <td class="numLineCover">&nbsp;493</td> <td class="nbHitsUncovered">&nbsp;0</td> <td class="src"><pre class="src"><span class="srcUncovered">&nbsp; System.err.println(<span class="string">"Exception when reading "</span> + configFile);</span></pre></td></tr>
<tr> <td class="numLineCover">&nbsp;494</td> <td class="nbHitsUncovered">&nbsp;0</td> <td class="src"><pre class="src"><span class="srcUncovered">&nbsp; ex.printStackTrace(System.err);</span></pre></td></tr>
<tr> <td class="numLineCover">&nbsp;495</td> <td class="nbHitsCovered">&nbsp;2</td> <td class="src"><pre class="src">&nbsp; }</pre></td></tr>
<tr> <td class="numLine">&nbsp;496</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp; }</pre></td></tr>
<tr> <td class="numLineCover">&nbsp;497</td> <td class="nbHitsCovered">&nbsp;7</td> <td class="src"><pre class="src">&nbsp; }</pre></td></tr>
<tr> <td class="numLine">&nbsp;498</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr> <td class="numLine">&nbsp;499</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp; <span class="comment">/**</span></pre></td></tr>
<tr> <td class="numLine">&nbsp;500</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp;<span class="comment"> * Main for adaptors to utilize when wanting to act as an application. This</span></pre></td></tr>
<tr> <td class="numLine">&nbsp;501</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp;<span class="comment"> * method primarily parses arguments and creates an application instance</span></pre></td></tr>
<tr> <td class="numLine">&nbsp;502</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp;<span class="comment"> * before calling it's {@link #start}.</span></pre></td></tr>
<tr> <td class="numLine">&nbsp;503</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp;<span class="comment"> *</span></pre></td></tr>
<tr> <td class="numLine">&nbsp;504</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp;<span class="comment"> * @return the application instance in use</span></pre></td></tr>
<tr> <td class="numLine">&nbsp;505</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp;<span class="comment"> */</span></pre></td></tr>
<tr> <td class="numLine">&nbsp;506</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp; <span class="keyword">public</span> <span class="keyword">static</span> Application main(Adaptor adaptor, String[] args) {</pre></td></tr>
<tr> <td class="numLineCover">&nbsp;507</td> <td class="nbHitsUncovered">&nbsp;0</td> <td class="src"><pre class="src"><span class="srcUncovered">&nbsp; log.info(<span class="keyword">new</span> Dashboard.JavaVersionStatusSource().retrieveStatus()</span></pre></td></tr>
<tr> <td class="numLine">&nbsp;508</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp; .getMessage(Locale.ENGLISH));</pre></td></tr>
<tr> <td class="numLineCover">&nbsp;509</td> <td class="nbHitsUncovered">&nbsp;0</td> <td class="src"><pre class="src"><span class="srcUncovered">&nbsp; Application app = daemonMain(adaptor, args);</span></pre></td></tr>
<tr> <td class="numLine">&nbsp;510</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr> <td class="numLine">&nbsp;511</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp; <span class="comment">// Setup providing content.</span></pre></td></tr>
<tr> <td class="numLine">&nbsp;512</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp; <span class="keyword">try</span> {</pre></td></tr>
<tr> <td class="numLineCover">&nbsp;513</td> <td class="nbHitsUncovered">&nbsp;0</td> <td class="src"><pre class="src"><span class="srcUncovered">&nbsp; app.start();</span></pre></td></tr>
<tr> <td class="numLineCover">&nbsp;514</td> <td class="nbHitsUncovered">&nbsp;0</td> <td class="src"><pre class="src"><span class="srcUncovered">&nbsp; log.info(<span class="string">"doc content serving started"</span>);</span></pre></td></tr>
<tr> <td class="numLineCover">&nbsp;515</td> <td class="nbHitsUncovered">&nbsp;0</td> <td class="src"><pre class="src"><span class="srcUncovered">&nbsp; } <span class="keyword">catch</span> (InterruptedException e) {</span></pre></td></tr>
<tr> <td class="numLineCover">&nbsp;516</td> <td class="nbHitsUncovered">&nbsp;0</td> <td class="src"><pre class="src"><span class="srcUncovered">&nbsp; Thread.currentThread().interrupt();</span></pre></td></tr>
<tr> <td class="numLineCover">&nbsp;517</td> <td class="nbHitsUncovered">&nbsp;0</td> <td class="src"><pre class="src"><span class="srcUncovered">&nbsp; <span class="keyword">throw</span> <span class="keyword">new</span> RuntimeException(<span class="string">"could not start serving"</span>, e);</span></pre></td></tr>
<tr> <td class="numLineCover">&nbsp;518</td> <td class="nbHitsUncovered">&nbsp;0</td> <td class="src"><pre class="src"><span class="srcUncovered">&nbsp; } <span class="keyword">catch</span> (IOException e) {</span></pre></td></tr>
<tr> <td class="numLineCover">&nbsp;519</td> <td class="nbHitsUncovered">&nbsp;0</td> <td class="src"><pre class="src"><span class="srcUncovered">&nbsp; <span class="keyword">throw</span> <span class="keyword">new</span> RuntimeException(<span class="string">"could not start serving"</span>, e);</span></pre></td></tr>
<tr> <td class="numLineCover">&nbsp;520</td> <td class="nbHitsUncovered">&nbsp;0</td> <td class="src"><pre class="src"><span class="srcUncovered">&nbsp; }</span></pre></td></tr>
<tr> <td class="numLineCover">&nbsp;521</td> <td class="nbHitsUncovered">&nbsp;0</td> <td class="src"><pre class="src"><span class="srcUncovered">&nbsp; <span class="keyword">return</span> app;</span></pre></td></tr>
<tr> <td class="numLine">&nbsp;522</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp; }</pre></td></tr>
<tr> <td class="numLine">&nbsp;523</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr> <td class="numLine">&nbsp;524</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp; <span class="comment">/**</span></pre></td></tr>
<tr> <td class="numLine">&nbsp;525</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp;<span class="comment"> * Performs basic bootstrapping like normal {@link #main}, but does not start</span></pre></td></tr>
<tr> <td class="numLine">&nbsp;526</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp;<span class="comment"> * the application.</span></pre></td></tr>
<tr> <td class="numLine">&nbsp;527</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp;<span class="comment"> */</span></pre></td></tr>
<tr> <td class="numLine">&nbsp;528</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp; <span class="keyword">static</span> Application daemonMain(Adaptor adaptor, String[] args) {</pre></td></tr>
<tr> <td class="numLineCover">&nbsp;529</td> <td class="nbHitsCovered">&nbsp;2</td> <td class="src"><pre class="src">&nbsp; Config config = <span class="keyword">new</span> Config();</pre></td></tr>
<tr> <td class="numLineCover">&nbsp;530</td> <td class="nbHitsCovered">&nbsp;2</td> <td class="src"><pre class="src">&nbsp; adaptor.initConfig(config);</pre></td></tr>
<tr> <td class="numLineCover">&nbsp;531</td> <td class="nbHitsCovered">&nbsp;2</td> <td class="src"><pre class="src">&nbsp; autoConfig(config, args, <span class="keyword">new</span> File(DEFAULT_CONFIG_FILE));</pre></td></tr>
<tr> <td class="numLineCover">&nbsp;532</td> <td class="nbHitsCovered">&nbsp;2</td> <td class="src"><pre class="src">&nbsp; <span class="keyword">return</span> <span class="keyword">new</span> Application(adaptor, config);</pre></td></tr>
<tr> <td class="numLine">&nbsp;533</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp; }</pre></td></tr>
<tr> <td class="numLine">&nbsp;534</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr> <td class="numLineCover">&nbsp;535</td> <td class="nbHitsCovered">&nbsp;20</td> <td class="src"><pre class="src">&nbsp; <span class="keyword">private</span> <span class="keyword">class</span> ShutdownHook <span class="keyword">implements</span> Runnable {</pre></td></tr>
<tr> <td class="numLine">&nbsp;536</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp; @Override</pre></td></tr>
<tr> <td class="numLine">&nbsp;537</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp; <span class="keyword">public</span> <span class="keyword">void</span> run() {</pre></td></tr>
<tr> <td class="numLineCover">&nbsp;538</td> <td class="nbHitsUncovered">&nbsp;0</td> <td class="src"><pre class="src"><span class="srcUncovered">&nbsp; stop(3, TimeUnit.SECONDS);</span></pre></td></tr>
<tr> <td class="numLineCover">&nbsp;539</td> <td class="nbHitsUncovered">&nbsp;0</td> <td class="src"><pre class="src"><span class="srcUncovered">&nbsp; }</span></pre></td></tr>
<tr> <td class="numLine">&nbsp;540</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp; }</pre></td></tr>
<tr> <td class="numLine">&nbsp;541</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr> <td class="numLine">&nbsp;542</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp; <span class="comment">/**</span></pre></td></tr>
<tr> <td class="numLine">&nbsp;543</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp;<span class="comment"> * Executes Runnable in current thread, but only after setting a thread-local</span></pre></td></tr>
<tr> <td class="numLine">&nbsp;544</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp;<span class="comment"> * object. The code that will be run, is expected to take notice of the set</span></pre></td></tr>
<tr> <td class="numLine">&nbsp;545</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp;<span class="comment"> * variable and abort immediately. This is a hack.</span></pre></td></tr>
<tr> <td class="numLine">&nbsp;546</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp;<span class="comment"> */</span></pre></td></tr>
<tr> <td class="numLine">&nbsp;547</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp; <span class="keyword">private</span> <span class="keyword">static</span> <span class="keyword">class</span> SuggestHandlerAbortPolicy</pre></td></tr>
<tr> <td class="numLine">&nbsp;548</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp; <span class="keyword">implements</span> RejectedExecutionHandler {</pre></td></tr>
<tr> <td class="numLine">&nbsp;549</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp; <span class="keyword">private</span> <span class="keyword">final</span> ThreadLocal&lt;Object&gt; abortImmediately;</pre></td></tr>
<tr> <td class="numLineCover">&nbsp;550</td> <td class="nbHitsCovered">&nbsp;12</td> <td class="src"><pre class="src">&nbsp; <span class="keyword">private</span> <span class="keyword">final</span> Object signal = <span class="keyword">new</span> Object();</pre></td></tr>
<tr> <td class="numLine">&nbsp;551</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr> <td class="numLineCover">&nbsp;552</td> <td class="nbHitsCovered">&nbsp;12</td> <td class="src"><pre class="src">&nbsp; <span class="keyword">public</span> SuggestHandlerAbortPolicy(ThreadLocal&lt;Object&gt; abortImmediately) {</pre></td></tr>
<tr> <td class="numLineCover">&nbsp;553</td> <td class="nbHitsCovered">&nbsp;12</td> <td class="src"><pre class="src">&nbsp; <span class="keyword">this</span>.abortImmediately = abortImmediately;</pre></td></tr>
<tr> <td class="numLineCover">&nbsp;554</td> <td class="nbHitsCovered">&nbsp;12</td> <td class="src"><pre class="src">&nbsp; }</pre></td></tr>
<tr> <td class="numLine">&nbsp;555</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr> <td class="numLine">&nbsp;556</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp; @Override</pre></td></tr>
<tr> <td class="numLine">&nbsp;557</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp; <span class="keyword">public</span> <span class="keyword">void</span> rejectedExecution(Runnable r, ThreadPoolExecutor executor) {</pre></td></tr>
<tr> <td class="numLineCover">&nbsp;558</td> <td class="nbHitsUncovered">&nbsp;0</td> <td class="src"><pre class="src"><span class="srcUncovered">&nbsp; abortImmediately.set(signal);</span></pre></td></tr>
<tr> <td class="numLine">&nbsp;559</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp; <span class="keyword">try</span> {</pre></td></tr>
<tr> <td class="numLineCover">&nbsp;560</td> <td class="nbHitsUncovered">&nbsp;0</td> <td class="src"><pre class="src"><span class="srcUncovered">&nbsp; r.run();</span></pre></td></tr>
<tr> <td class="numLine">&nbsp;561</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp; } <span class="keyword">finally</span> {</pre></td></tr>
<tr> <td class="numLineCover">&nbsp;562</td> <td class="nbHitsUncovered">&nbsp;0</td> <td class="src"><pre class="src"><span class="srcUncovered">&nbsp; abortImmediately.set(<span class="keyword">null</span>);</span></pre></td></tr>
<tr> <td class="numLineCover">&nbsp;563</td> <td class="nbHitsUncovered">&nbsp;0</td> <td class="src"><pre class="src"><span class="srcUncovered">&nbsp; }</span></pre></td></tr>
<tr> <td class="numLineCover">&nbsp;564</td> <td class="nbHitsUncovered">&nbsp;0</td> <td class="src"><pre class="src"><span class="srcUncovered">&nbsp; }</span></pre></td></tr>
<tr> <td class="numLine">&nbsp;565</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp; }</pre></td></tr>
<tr> <td class="numLine">&nbsp;566</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr> <td class="numLineCover">&nbsp;567</td> <td class="nbHitsCovered">&nbsp;38</td> <td class="src"><pre class="src">&nbsp; <span class="keyword">private</span> <span class="keyword">class</span> ConfigModListener <span class="keyword">implements</span> ConfigModificationListener {</pre></td></tr>
<tr> <td class="numLine">&nbsp;568</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp; @Override</pre></td></tr>
<tr> <td class="numLine">&nbsp;569</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp; <span class="keyword">public</span> <span class="keyword">void</span> configModified(ConfigModificationEvent ev) {</pre></td></tr>
<tr> <td class="numLineCover">&nbsp;570</td> <td class="nbHitsCovered">&nbsp;2</td> <td class="src"><pre class="src">&nbsp; Set&lt;String&gt; modifiedKeys = ev.getModifiedKeys();</pre></td></tr>
<tr> <td class="numLineCover">&nbsp;571</td> <td class="nbHitsCovered"><a title="Line 571: Conditional coverage 100% (2/2).">&nbsp;2</a></td> <td class="src"><pre class="src">&nbsp;<a title="Line 571: Conditional coverage 100% (2/2)."> <span class="keyword">if</span> (modifiedKeys.contains(<span class="string">"adaptor.fullListingSchedule"</span>)) {</a></pre></td></tr>
<tr> <td class="numLineCover">&nbsp;572</td> <td class="nbHitsCovered">&nbsp;1</td> <td class="src"><pre class="src">&nbsp; gsa.rescheduleFullListing(</pre></td></tr>
<tr> <td class="numLine">&nbsp;573</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp; ev.getNewConfig().getAdaptorFullListingSchedule());</pre></td></tr>
<tr> <td class="numLine">&nbsp;574</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp; }</pre></td></tr>
<tr> <td class="numLine">&nbsp;575</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp;</pre></td></tr>
<tr> <td class="numLine">&nbsp;576</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp; <span class="comment">// List of "safe" keys that can be updated without a restart.</span></pre></td></tr>
<tr> <td class="numLineCover">&nbsp;577</td> <td class="nbHitsCovered">&nbsp;2</td> <td class="src"><pre class="src">&nbsp; List&lt;String&gt; safeKeys = Arrays.asList(<span class="string">"adaptor.fullListingSchedule"</span>);</pre></td></tr>
<tr> <td class="numLine">&nbsp;578</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp; <span class="comment">// Set of "unsafe" keys that have been modified.</span></pre></td></tr>
<tr> <td class="numLineCover">&nbsp;579</td> <td class="nbHitsCovered">&nbsp;2</td> <td class="src"><pre class="src">&nbsp; Set&lt;String&gt; modifiedKeysRequiringRestart</pre></td></tr>
<tr> <td class="numLine">&nbsp;580</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp; = <span class="keyword">new</span> HashSet&lt;String&gt;(modifiedKeys);</pre></td></tr>
<tr> <td class="numLineCover">&nbsp;581</td> <td class="nbHitsCovered">&nbsp;2</td> <td class="src"><pre class="src">&nbsp; modifiedKeysRequiringRestart.removeAll(safeKeys);</pre></td></tr>
<tr> <td class="numLine">&nbsp;582</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp; <span class="comment">// If there are modified "unsafe" keys, then we restart things to make</span></pre></td></tr>
<tr> <td class="numLine">&nbsp;583</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp; <span class="comment">// sure all the code is up-to-date with the new values.</span></pre></td></tr>
<tr> <td class="numLineCover">&nbsp;584</td> <td class="nbHitsCovered"><a title="Line 584: Conditional coverage 100% (2/2).">&nbsp;2</a></td> <td class="src"><pre class="src">&nbsp;<a title="Line 584: Conditional coverage 100% (2/2)."> <span class="keyword">if</span> (!modifiedKeysRequiringRestart.isEmpty()) {</a></pre></td></tr>
<tr> <td class="numLineCover">&nbsp;585</td> <td class="nbHitsCovered">&nbsp;1</td> <td class="src"><pre class="src">&nbsp; log.warning(<span class="string">"Unsafe configuration keys modified. To ensure a sane "</span></pre></td></tr>
<tr> <td class="numLine">&nbsp;586</td> <td class="nbHits">&nbsp;</td>
<td class="src"><pre class="src">&nbsp; + <span class="string">"state, the adaptor is restarting."</span>);</pre></td></tr>
<tr>