<p dir="auto"><strong><a href="https://jira.spring.io/secure/ViewProfile.jspa?name=ceharris414" rel="nofollow">Carl Harris</a></strong> opened <strong><a href="https://jira.spring.io/browse/SPR-7911?redirect=false" rel="nofollow">SPR-7911</a></strong> and commented</p>
<p dir="auto">Some REST web services return 204 No Content as the result for a GET in certain circumstances.  With this status, the response has no entity body and thus no Content-Type header.</p>
<p dir="auto">RestTemplate.getForEntity throws an exception when receiving such a response:</p>
<p dir="auto">org.springframework.web.client.RestClientException: Cannot extract response: no Content-Type found</p>
<p dir="auto">An improvement for RestTemplate.getForEntity would be to return a ResponseEntity instance with the statusCode property set as appropriate for 204 No Content, and null values for the body and contentType properties.</p>
<p dir="auto">I considered trying to extend RestTemplate to make it behave in this manner.  Unfortunately, the extensive use of private static classes in the implementation makes it difficult to override the behavior of getForEntity -- can't just replace the ResponseEntityResponseExtractor implementation without also replacing other unrelated collaborators (e.g. AcceptHeaderRequestCallback).  It's possible to do it, it would just require a lot more code duplication than really seems warranted.</p>
<p dir="auto">If you don't wish to change the behavior of RestTemplate.getForEntity, perhaps you might consider relaxing the access modifiers on these collaborator classes so that a subclass could make use of them?</p>
<hr>
<p dir="auto"><strong>Affects:</strong> 3.1 M1</p>
<p dir="auto"><strong>Issue Links:</strong></p>
<ul dir="auto">
<li><a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="398110546" data-permission-text="Title is private" data-url="https://github.com/spring-projects/spring-framework/issues/12671" data-hovercard-type="issue" data-hovercard-url="/spring-projects/spring-framework/issues/12671/hovercard" href="https://github.com/spring-projects/spring-framework/issues/12671">#12671</a> RestTemplate - support response mapping to entity with potentially empty response body. (<em><strong>"is duplicated by"</strong></em>)</li>
</ul>
<p dir="auto"><strong>Referenced from:</strong> commits <a class="commit-link" data-hovercard-type="commit" data-hovercard-url="https://github.com/spring-projects/spring-framework/commit/c42671a78aa68f7ab8125311b2c9ce167b166c2c/hovercard" href="https://github.com/spring-projects/spring-framework/commit/c42671a78aa68f7ab8125311b2c9ce167b166c2c"><tt>c42671a</tt></a>, <a class="commit-link" data-hovercard-type="commit" data-hovercard-url="https://github.com/spring-projects/spring-framework/commit/98870251f9fb27123353c549ae22fcf3679ebbd5/hovercard" href="https://github.com/spring-projects/spring-framework/commit/98870251f9fb27123353c549ae22fcf3679ebbd5"><tt>9887025</tt></a></p>
<p dir="auto">1 votes, 1 watchers</p>
<p dir="auto"><strong><a href="https://jira.spring.io/secure/ViewProfile.jspa?name=yozh" rel="nofollow">Stepan Koltsov</a></strong> opened <strong><a href="https://jira.spring.io/browse/SPR-7979?redirect=false" rel="nofollow">SPR-7979</a></strong> and commented</p>
<p dir="auto">Have simple configuration:</p>
<p dir="auto">public abstract class Aaaaa { }</p>
<p dir="auto">public class Bbbbb extends Aaaaa { }</p>
<p dir="auto"><code class="notranslate">@Configuration</code><br>
<code class="notranslate">@ComponentScan</code>(<br>
basePackages="com.mycompany",<br>
useDefaultFilters=false,<br>
includeFilters={<br>
<code class="notranslate">@ComponentScan</code>.Filter(type=FilterType.ASSIGNABLE_TYPE, value=Aaaaa.class)<br>
}<br>
)public class Conf {</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="@Autowired
private Bbbbb bbbbb;"><pre class="notranslate"><code class="notranslate">@Autowired
private Bbbbb bbbbb;
</code></pre></div>
<p dir="auto">}</p>
<p dir="auto">when loaded with</p>
<p dir="auto">new AnnotationConfigApplicationContext(Conf.class)</p>
<p dir="auto">works fine, however, when loaded with XML config that references Conf.class:</p>
<p dir="auto">&lt;beans&gt;<br>
&lt;bean class="com.mycompany.Conf"/&gt;<br>
&lt;/beans&gt;</p>
<p dir="auto">new ClassPathXmlApplicationContext("classpath:com/mycompany/conf.xml");</p>
<p dir="auto">it fails with exception: cannot autowire Conf.bbbbb field. Full stack trace: <a href="https://gist.github.com/835493">https://gist.github.com/835493</a> .</p>
<hr>
<p dir="auto"><strong>Affects:</strong> 3.1 M1</p>
<p dir="auto"><strong>Attachments:</strong></p>
<ul dir="auto">
<li><a href="https://jira.spring.io/secure/attachment/17998/mylyn-context.zip" rel="nofollow">mylyn-context.zip</a> (<em>236.68 kB</em>)</li>
</ul>
<p dir="auto"><strong>Issue Links:</strong></p>
<ul dir="auto">
<li><a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="398114714" data-permission-text="Title is private" data-url="https://github.com/spring-projects/spring-framework/issues/13361" data-hovercard-type="issue" data-hovercard-url="/spring-projects/spring-framework/issues/13361/hovercard" href="https://github.com/spring-projects/spring-framework/issues/13361">#13361</a> <code class="notranslate">@ComponentScan</code>(includeFilters=<code class="notranslate">@Filter</code>(...)) fails when <code class="notranslate">@Import</code>'ed (<em><strong>"duplicates"</strong></em>)</li>
<li><a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="398116710" data-permission-text="Title is private" data-url="https://github.com/spring-projects/spring-framework/issues/13670" data-hovercard-type="issue" data-hovercard-url="/spring-projects/spring-framework/issues/13670/hovercard" href="https://github.com/spring-projects/spring-framework/issues/13670">#13670</a> <code class="notranslate">@ComponentScan</code> with includeFilters on <code class="notranslate">@Import-ed</code> context does not work</li>
<li><a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="398117136" data-permission-text="Title is private" data-url="https://github.com/spring-projects/spring-framework/issues/13738" data-hovercard-type="issue" data-hovercard-url="/spring-projects/spring-framework/issues/13738/hovercard" href="https://github.com/spring-projects/spring-framework/issues/13738">#13738</a> ClassPathBeanDefinitionScanner vs ClassPathBeanDefinitionScanner: difference in behavior when dealing with <code class="notranslate">@ComponentScan</code> excludeFilters</li>
</ul>
<p dir="auto"><strong>Referenced from:</strong> commits <a class="commit-link" data-hovercard-type="commit" data-hovercard-url="https://github.com/spring-projects/spring-framework/commit/d9f7fdd120409fff4491561215e5b2dda74e2b02/hovercard" href="https://github.com/spring-projects/spring-framework/commit/d9f7fdd120409fff4491561215e5b2dda74e2b02"><tt>d9f7fdd</tt></a></p>
<p dir="auto">1 votes, 0 watchers</p>