From 8948021500147d24d6b0b10092e945235de16c54 Mon Sep 17 00:00:00 2001 From: Martin Kurz Date: Tue, 8 Oct 2013 16:02:36 +0200 Subject: [PATCH] switched from HashSet to LinkedHashSet where ordering of elements is relevant, HashSet doesn't guarantee the ordering of its elements (fixes #116) --- .../java/com/sun/syndication/feed/impl/CopyFromHelper.java | 3 ++- .../feed/synd/impl/ConverterForRSS091Userland.java | 4 ++-- .../sun/syndication/feed/synd/impl/ConverterForRSS094.java | 6 +++--- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/src/main/java/com/sun/syndication/feed/impl/CopyFromHelper.java b/src/main/java/com/sun/syndication/feed/impl/CopyFromHelper.java index 7e95797..76136be 100644 --- a/src/main/java/com/sun/syndication/feed/impl/CopyFromHelper.java +++ b/src/main/java/com/sun/syndication/feed/impl/CopyFromHelper.java @@ -25,6 +25,7 @@ import java.util.Date; import java.util.HashMap; import java.util.HashSet; import java.util.Iterator; +import java.util.LinkedHashSet; import java.util.Map; import java.util.Map.Entry; import java.util.Set; @@ -148,7 +149,7 @@ public class CopyFromHelper { // expecting SETs or LISTs only, going default implementation of them final Collection newColl; if (collection instanceof Set) { - newColl = new HashSet(); + newColl = new LinkedHashSet(); } else { newColl = new ArrayList(); } diff --git a/src/main/java/com/sun/syndication/feed/synd/impl/ConverterForRSS091Userland.java b/src/main/java/com/sun/syndication/feed/synd/impl/ConverterForRSS091Userland.java index 31d8ad4..4ffa9fe 100644 --- a/src/main/java/com/sun/syndication/feed/synd/impl/ConverterForRSS091Userland.java +++ b/src/main/java/com/sun/syndication/feed/synd/impl/ConverterForRSS091Userland.java @@ -18,7 +18,7 @@ package com.sun.syndication.feed.synd.impl; import java.util.ArrayList; import java.util.Date; -import java.util.HashSet; +import java.util.LinkedHashSet; import java.util.List; import java.util.Set; @@ -72,7 +72,7 @@ public class ConverterForRSS091Userland extends ConverterForRSS090 { final List creators = ((DCModule) syndFeed.getModule(DCModule.URI)).getCreators(); if (!creators.contains(author)) { - final Set s = new HashSet(); // using a set to + final Set s = new LinkedHashSet(); // using a set to // remove // duplicates s.addAll(creators); // DC creators diff --git a/src/main/java/com/sun/syndication/feed/synd/impl/ConverterForRSS094.java b/src/main/java/com/sun/syndication/feed/synd/impl/ConverterForRSS094.java index 69ceb1a..9495e57 100644 --- a/src/main/java/com/sun/syndication/feed/synd/impl/ConverterForRSS094.java +++ b/src/main/java/com/sun/syndication/feed/synd/impl/ConverterForRSS094.java @@ -17,7 +17,7 @@ package com.sun.syndication.feed.synd.impl; import java.util.ArrayList; -import java.util.HashSet; +import java.util.LinkedHashSet; import java.util.List; import java.util.Set; @@ -52,7 +52,7 @@ public class ConverterForRSS094 extends ConverterForRSS093 { super.copyInto(channel, syndFeed); final List cats = channel.getCategories(); // c if (cats.size() > 0) { - final Set s = new HashSet(); // using a + final Set s = new LinkedHashSet(); // using a // set to // remove // duplicates @@ -73,7 +73,7 @@ public class ConverterForRSS094 extends ConverterForRSS093 { if (author != null) { final List creators = ((DCModule) syndEntry.getModule(DCModule.URI)).getCreators(); if (!creators.contains(author)) { - final Set s = new HashSet(); // using a set to + final Set s = new LinkedHashSet(); // using a set to // remove // duplicates s.addAll(creators); // DC creators