Work-round for PMD crash

git-svn-id: https://svn.apache.org/repos/asf/commons/proper/collections/trunk@1299228 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Sebastian Bazley 2012-03-10 16:13:31 +00:00
parent 8b374ab6ff
commit d4747e7edc
1 changed files with 8 additions and 2 deletions

View File

@ -1704,8 +1704,14 @@ public class ExtendedProperties extends Hashtable<String, Object> {
public static ExtendedProperties convertProperties(Properties props) { public static ExtendedProperties convertProperties(Properties props) {
ExtendedProperties c = new ExtendedProperties(); ExtendedProperties c = new ExtendedProperties();
for (@SuppressWarnings("unchecked") // Properties are supposed to have string keys ... @SuppressWarnings("unchecked") // Properties are supposed to have string keys ...
Enumeration<String> e = (Enumeration<String>) props.propertyNames(); e.hasMoreElements();) { Enumeration<String> e = (Enumeration<String>) props.propertyNames();
// Unfortunately PMD 4.3 cannot handle the original code where the @Suppress
// was in the for loop:
// for (@SuppressWarnings("unchecked") // Properties are supposed to have string keys ...
// Enumeration<String> e = (Enumeration<String>) props.propertyNames(); e.hasMoreElements();) {
// String s = e.nextElement(); // ... if props does not, this line would fail anyway ...
while (e.hasMoreElements()) {
String s = e.nextElement(); // ... if props does not, this line would fail anyway ... String s = e.nextElement(); // ... if props does not, this line would fail anyway ...
String value = props.getProperty(s); String value = props.getProperty(s);
if(value != null) { if(value != null) {