diff --git a/src/checkstyle/com/puppycrawl/tools/checkstyle/api/Utils.java b/src/checkstyle/com/puppycrawl/tools/checkstyle/api/Utils.java index eda059ce5..6c9b2ec5b 100644 --- a/src/checkstyle/com/puppycrawl/tools/checkstyle/api/Utils.java +++ b/src/checkstyle/com/puppycrawl/tools/checkstyle/api/Utils.java @@ -43,10 +43,12 @@ public final class Utils /** Map of all created regular expressions **/ private static final Map CREATED_RES = new HashMap(); + ///CLOVER:ON /** stop instances being created **/ private Utils() { } + ///CLOVER:OFF /** * Returns whether the specified string contains only whitespace up to the @@ -129,21 +131,6 @@ public final class Utils return retVal; } - /** - * Conditionally add a String to a set of properties. - * @param aProps the Properties to add to - * @param aKey the key to add the property under - * @param aValue if not null, then the value to add the property with - */ - public static void addObjectString(Properties aProps, - String aKey, - Object aValue) - { - if (aValue != null) { - aProps.put(aKey, aValue.toString()); - } - } - /** * Loads the contents of a file in a String array. * @return the lines in the file diff --git a/src/tests/com/puppycrawl/tools/checkstyle/UtilsTest.java b/src/tests/com/puppycrawl/tools/checkstyle/UtilsTest.java index 9f76b00ca..f0f249bc5 100644 --- a/src/tests/com/puppycrawl/tools/checkstyle/UtilsTest.java +++ b/src/tests/com/puppycrawl/tools/checkstyle/UtilsTest.java @@ -3,6 +3,7 @@ package com.puppycrawl.tools.checkstyle; import java.util.Properties; import junit.framework.TestCase; +import org.apache.commons.beanutils.ConversionException; import org.apache.regexp.RE; import com.puppycrawl.tools.checkstyle.api.CheckstyleException; @@ -100,6 +101,17 @@ public class UtilsTest } } + public void testBadRegex() + { + try { + Utils.createRE("["); + fail("expected to get conversion exception"); + } + catch (ConversionException e) { + ; // what is expected + } + } + private Properties initProperties() { final Properties props = new Properties();