Sync docs from master to gh-pages
This commit is contained in:
@@ -606,4 +606,13 @@ matching response definition was picked.</p><p>To turn off this feature just bum
|
||||
`StubRunnerExtension`to dump all mappings per artifact id. Also the port at which the given stub server
|
||||
was started will be attached.</p></div><div class="section"><div class="titlepage"><div><div><h3 class="title"><a name="_can_i_reference_text_from_file" href="#_can_i_reference_text_from_file"></a>3.8.3 Can I reference text from file?</h3></div></div></div><p>Yes! With version 1.2.0 we’ve added such a possibility. It’s enough to call <code class="literal">file(…​)</code> method in the
|
||||
DSL and provide a path relative to where the contract lays.
|
||||
If you’re using YAML just use the <code class="literal">bodyFromFile</code> property.</p></div></div></div><div class="navfooter"><hr><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="multi__spring_cloud_contract_verifier_introduction.html">Prev</a> </td><td width="20%" align="center"> </td><td width="40%" align="right"> <a accesskey="n" href="multi__spring_cloud_contract_verifier_setup.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top">2. Spring Cloud Contract Verifier Introduction </td><td width="20%" align="center"><a accesskey="h" href="multi_spring-cloud-contract.html">Home</a></td><td width="40%" align="right" valign="top"> 4. Spring Cloud Contract Verifier Setup</td></tr></table></div></body></html>
|
||||
If you’re using YAML just use the <code class="literal">bodyFromFile</code> property.</p></div><div class="section"><div class="titlepage"><div><div><h3 class="title"><a name="_why_do_i_sometimes_get_socketexception" href="#_why_do_i_sometimes_get_socketexception"></a>3.8.4 Why do I sometimes get <code class="literal">SocketException</code></h3></div></div></div><p>When using an HTTP client (e.g. <code class="literal">RestTemplate</code>) and running several tests that share a Spring context, you might sometimes get the following exception:</p><pre class="screen">java.net.SocketException: Unexpected end of file from server</pre><p>Tom Akehurst, the creator of WireMock did the following analysis of this issue.</p><div class="blockquote"><blockquote class="blockquote"><p>I looked at tcpdump while running the failing test. <code class="literal">HttpUrlConnection</code> is doing something weird - it’s creating a connection in a previous test case, which works fine, then the usual <code class="literal">fin</code> → <code class="literal">fin ack</code> etc. ending handshake happens. But it seems it isn’t discarded, but reused after that. Because the server thinks (rightly) that the connection is closed, it just sends a RST packet. Calling the <code class="literal">/__admin</code> endpoint just happened to remove the dead connection from the pool. This also fixes the problem (which using the Java HTTP client): System.setProperty("http.keepAlive", "false");</p></blockquote></div><p>There are the ways to solve this problem.</p><p>First, just use a different HTTP client for <code class="literal">RestTemplate</code>. Example for using Apache HTTP client:</p><p><b>pom.xml. </b>
|
||||
</p><pre class="programlisting"><span xmlns:d="http://docbook.org/ns/docbook" class="hl-tag"><dependency></span>
|
||||
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-tag"><groupId></span>org.apache.httpcomponents<span xmlns:d="http://docbook.org/ns/docbook" class="hl-tag"></groupId></span>
|
||||
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-tag"><artifactId></span>httpclient<span xmlns:d="http://docbook.org/ns/docbook" class="hl-tag"></artifactId></span>
|
||||
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-tag"><scope></span>compile<span xmlns:d="http://docbook.org/ns/docbook" class="hl-tag"></scope></span>
|
||||
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-tag"></dependency></span></pre><p>
|
||||
</p><pre class="programlisting"><span xmlns:d="http://docbook.org/ns/docbook" class="hl-keyword">this</span>.restTemplate
|
||||
.setRequestFactory(<span xmlns:d="http://docbook.org/ns/docbook" class="hl-keyword">new</span> HttpComponentsClientHttpRequestFactory());</pre><p>Second option is to set the system property. You can set it either in code or pass it to your tests via a plugin.</p><pre class="programlisting"><span xmlns:d="http://docbook.org/ns/docbook" class="hl-keyword">static</span> {
|
||||
System.setProperty(<span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">"http.keepAlive"</span>, <span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">"false"</span>);
|
||||
}</pre></div></div></div><div class="navfooter"><hr><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="multi__spring_cloud_contract_verifier_introduction.html">Prev</a> </td><td width="20%" align="center"> </td><td width="40%" align="right"> <a accesskey="n" href="multi__spring_cloud_contract_verifier_setup.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top">2. Spring Cloud Contract Verifier Introduction </td><td width="20%" align="center"><a accesskey="h" href="multi_spring-cloud-contract.html">Home</a></td><td width="40%" align="right" valign="top"> 4. Spring Cloud Contract Verifier Setup</td></tr></table></div></body></html>
|
||||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@@ -2324,6 +2324,33 @@ was started will be attached.</simpara>
|
||||
DSL and provide a path relative to where the contract lays.
|
||||
If you’re using YAML just use the <literal>bodyFromFile</literal> property.</simpara>
|
||||
</section>
|
||||
<section xml:id="_why_do_i_sometimes_get_socketexception">
|
||||
<title>Why do I sometimes get <literal>SocketException</literal></title>
|
||||
<simpara>When using an HTTP client (e.g. <literal>RestTemplate</literal>) and running several tests that share a Spring context, you might sometimes get the following exception:</simpara>
|
||||
<screen>java.net.SocketException: Unexpected end of file from server</screen>
|
||||
<simpara>Tom Akehurst, the creator of WireMock did the following analysis of this issue.</simpara>
|
||||
<blockquote>
|
||||
<simpara>I looked at tcpdump while running the failing test. <literal>HttpUrlConnection</literal> is doing something weird - it’s creating a connection in a previous test case, which works fine, then the usual <literal>fin</literal> → <literal>fin ack</literal> etc. ending handshake happens. But it seems it isn’t discarded, but reused after that. Because the server thinks (rightly) that the connection is closed, it just sends a RST packet. Calling the <literal>/__admin</literal> endpoint just happened to remove the dead connection from the pool. This also fixes the problem (which using the Java HTTP client): System.setProperty("http.keepAlive", "false");</simpara>
|
||||
</blockquote>
|
||||
<simpara>There are the ways to solve this problem.</simpara>
|
||||
<simpara>First, just use a different HTTP client for <literal>RestTemplate</literal>. Example for using Apache HTTP client:</simpara>
|
||||
<formalpara>
|
||||
<title>pom.xml</title>
|
||||
<para>
|
||||
<programlisting language="xml" linenumbering="unnumbered"><dependency>
|
||||
<groupId>org.apache.httpcomponents</groupId>
|
||||
<artifactId>httpclient</artifactId>
|
||||
<scope>compile</scope>
|
||||
</dependency></programlisting>
|
||||
</para>
|
||||
</formalpara>
|
||||
<programlisting language="java" linenumbering="unnumbered">this.restTemplate
|
||||
.setRequestFactory(new HttpComponentsClientHttpRequestFactory());</programlisting>
|
||||
<simpara>Second option is to set the system property. You can set it either in code or pass it to your tests via a plugin.</simpara>
|
||||
<programlisting language="java" linenumbering="unnumbered">static {
|
||||
System.setProperty("http.keepAlive", "false");
|
||||
}</programlisting>
|
||||
</section>
|
||||
</section>
|
||||
</chapter>
|
||||
<chapter xml:id="_spring_cloud_contract_verifier_setup">
|
||||
|
||||
Reference in New Issue
Block a user