[MSHARED-564] Exceptions thrown on closing resources should not be suppressed silently.
git-svn-id: https://svn.apache.org/repos/asf/maven/shared/trunk@1749808 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/src/main/java/org/apache/maven/shared/utils/PropertyUtils.java b/src/main/java/org/apache/maven/shared/utils/PropertyUtils.java
index 5f435c9..4c211d5 100644
--- a/src/main/java/org/apache/maven/shared/utils/PropertyUtils.java
+++ b/src/main/java/org/apache/maven/shared/utils/PropertyUtils.java
@@ -51,8 +51,8 @@
* @return The loaded properties.
*
* @deprecated As of 3.1.0, please use method {@link #loadOptionalProperties(java.net.URL)}. This method should not
- * be used as it suppresses exceptions when loading properties fails and returns {@code null} instead of an empty
- * {@code Properties} instance when the given {@code URL} is {@code null}.
+ * be used as it suppresses exceptions silently when loading properties fails and returns {@code null} instead of an
+ * empty {@code Properties} instance when the given {@code URL} is {@code null}.
*/
@Deprecated
public static java.util.Properties loadProperties( @Nonnull URL url )
@@ -74,8 +74,8 @@
* @return The loaded properties.
*
* @deprecated As of 3.1.0, please use method {@link #loadOptionalProperties(java.io.File)}. This method should not
- * be used as it suppresses exceptions when loading properties fails and returns {@code null} instead of an empty
- * {@code Properties} instance when the given {@code File} is {@code null}.
+ * be used as it suppresses exceptions silently when loading properties fails and returns {@code null} instead of an
+ * empty {@code Properties} instance when the given {@code File} is {@code null}.
*/
@Deprecated
public static Properties loadProperties( @Nonnull File file )
@@ -97,7 +97,7 @@
* @return The loaded properties.
*
* @deprecated As of 3.1.0, please use method {@link #loadOptionalProperties(java.io.InputStream)}. This method
- * should not be used as it suppresses exceptions when loading properties fails.
+ * should not be used as it suppresses exceptions silently when loading properties fails.
*/
@Deprecated
public static Properties loadProperties( @Nullable InputStream is )
@@ -132,17 +132,18 @@
/**
* Loads {@code Properties} from a given {@code URL}.
+ * <p>
+ * If the given {@code URL} is not {@code null}, it is asserted to represent a valid and loadable properties
+ * resource.
+ * </p>
*
* @param url The {@code URL} of the properties resource to load or {@code null}.
*
* @return The loaded properties or an empty {@code Properties} instance if {@code url} is {@code null}.
*
- * @throws IOException if loading properties fails.
- *
* @since 3.1.0
*/
@Nonnull public static Properties loadOptionalProperties( final @Nullable URL url )
- throws IOException
{
InputStream in = null;
try
@@ -159,6 +160,10 @@
return properties;
}
+ catch ( final IOException e )
+ {
+ throw new AssertionError( e );
+ }
finally
{
IOUtil.close( in );
@@ -167,17 +172,18 @@
/**
* Loads {@code Properties} from a given {@code File}.
+ * <p>
+ * If the given {@code File} is not {@code null}, it is asserted to represent a valid and loadable properties
+ * resource.
+ * </p>
*
* @param file The {@code File} of the properties resource to load or {@code null}.
*
* @return The loaded properties or an empty {@code Properties} instance if {@code file} is {@code null}.
*
- * @throws IOException if loading properties fails.
- *
* @since 3.1.0
*/
@Nonnull public static Properties loadOptionalProperties( final @Nullable File file )
- throws IOException
{
InputStream in = null;
try
@@ -194,6 +200,10 @@
return properties;
}
+ catch ( final IOException e )
+ {
+ throw new AssertionError( e );
+ }
finally
{
IOUtil.close( in );
@@ -202,17 +212,18 @@
/**
* Loads {@code Properties} from a given {@code InputStream}.
+ * <p>
+ * If the given {@code InputStream} is not {@code null}, it is asserted to represent a valid and loadable properties
+ * resource.
+ * </p>
*
* @param inputStream The {@code InputStream} of the properties resource to load or {@code null}.
*
* @return The loaded properties or an empty {@code Properties} instance if {@code inputStream} is {@code null}.
*
- * @throws IOException if loading properties fails.
- *
* @since 3.1.0
*/
@Nonnull public static Properties loadOptionalProperties( final @Nullable InputStream inputStream )
- throws IOException
{
InputStream in = null;
try
@@ -229,6 +240,10 @@
return properties;
}
+ catch ( final IOException e )
+ {
+ throw new AssertionError( e );
+ }
finally
{
IOUtil.close( in );