<p dir="auto"><strong><a href="https://jira.spring.io/secure/ViewProfile.jspa?name=olivergierke" rel="nofollow">Oliver Drotbohm</a></strong> opened <strong><a href="https://jira.spring.io/browse/SPR-8554?redirect=false" rel="nofollow">SPR-8554</a></strong> and commented</p>
<p dir="auto">In line 62 of <code class="notranslate">MapToMapConverter</code> the implementation simply returns the source <code class="notranslate">Map</code> in case it is empty. This is invalid in the following scenario: suppose you have a simple empty <code class="notranslate">LinkedHashMap</code> and the target type is a <code class="notranslate">SortedMap</code>. Given the current implementation we'd return the <code class="notranslate">LinkedHashMap</code> unconverted which does not implement <code class="notranslate">SortedMap</code> (that's why the conversion was triggered initially).</p>
<p dir="auto">Simply removing that clause should do the trick as for an empty <code class="notranslate">Map</code> the only code being executed after that is the creation of the new <code class="notranslate">Map</code> type anyway.</p>
<p dir="auto">Candidate for 3.0.6 back-porting?</p>
<hr>
<p dir="auto"><strong>Affects:</strong> 3.0.5</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="398108613" data-permission-text="Title is private" data-url="https://github.com/spring-projects/spring-framework/issues/12384" data-hovercard-type="issue" data-hovercard-url="/spring-projects/spring-framework/issues/12384/hovercard" href="https://github.com/spring-projects/spring-framework/issues/12384">#12384</a> CollectionToCollectionConverter does not convert if the source is empty (<em><strong>"duplicates"</strong></em>)</li>
</ul>
<p dir="auto">1 votes, 1 watchers</p>
<p dir="auto"><strong><a href="https://jira.spring.io/secure/ViewProfile.jspa?name=hc" rel="nofollow">HC</a></strong> opened <strong><a href="https://jira.spring.io/browse/SPR-7728?redirect=false" rel="nofollow">SPR-7728</a></strong> and commented</p>
<p dir="auto">CollectionToCollectionConverter returns the original source object if the collection is empty. Relevant source code is attached (see convertEmptyVector_shouldReturnEmptyArrayList unit test)</p>
<p dir="auto">Best Regards</p>
<p dir="auto">Horatiu</p>
<hr>
<p dir="auto"><strong>Affects:</strong> 3.0.4</p>
<p dir="auto"><strong>Attachments:</strong></p>
<ul dir="auto">
<li><a href="https://jira.spring.io/secure/attachment/17343/CollectionToCollectionConverterTest.java" rel="nofollow">CollectionToCollectionConverterTest.java</a> (<em>1.44 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="398113677" data-permission-text="Title is private" data-url="https://github.com/spring-projects/spring-framework/issues/13198" data-hovercard-type="issue" data-hovercard-url="/spring-projects/spring-framework/issues/13198/hovercard" href="https://github.com/spring-projects/spring-framework/issues/13198">#13198</a> MapToMapConverter invalidly returns source map for empty maps (<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/58d68cef986aaaf4b6a296b234f8ca4744d357e3/hovercard" href="https://github.com/spring-projects/spring-framework/commit/58d68cef986aaaf4b6a296b234f8ca4744d357e3"><tt>58d68ce</tt></a></p>
<p dir="auto"><strong>Backported to:</strong> <a href="https://github.com/spring-projects/spring-framework/milestone/74?closed=1">3.0.7</a></p>