You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by gg...@apache.org on 2023/06/23 18:52:12 UTC

[commons-jcs] branch master updated: Throw a specialized RuntimeException instead of RuntimeException

This is an automated email from the ASF dual-hosted git repository.

ggregory pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-jcs.git


The following commit(s) were added to refs/heads/master by this push:
     new bd2ffc6b Throw a specialized RuntimeException instead of RuntimeException
bd2ffc6b is described below

commit bd2ffc6b107815c4546e0d9213b1339ea2f36c08
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Fri Jun 23 14:52:08 2023 -0400

    Throw a specialized RuntimeException instead of
    RuntimeException
---
 .../src/main/java/org/apache/commons/jcs3/admin/JCSAdminBean.java   | 6 +++---
 .../commons/jcs3/auxiliary/AbstractAuxiliaryCacheAttributes.java    | 4 ++--
 .../apache/commons/jcs3/auxiliary/disk/block/BlockDiskCache.java    | 2 +-
 .../commons/jcs3/auxiliary/disk/jdbc/JDBCDiskCacheFactory.java      | 2 +-
 .../org/apache/commons/jcs3/engine/CompositeCacheAttributes.java    | 2 +-
 .../main/java/org/apache/commons/jcs3/engine/ElementAttributes.java | 2 +-
 .../src/main/java/org/apache/commons/jcs3/log/LogManager.java       | 2 +-
 .../main/java/org/apache/commons/jcs3/utils/access/JCSWorker.java   | 2 +-
 .../commons/jcs3/utils/serialization/EncryptingSerializer.java      | 2 +-
 .../org/apache/commons/jcs3/utils/threadpool/ThreadPoolManager.java | 2 +-
 .../jcs3/auxiliary/disk/jdbc/JDBCDataSourceFactoryUnitTest.java     | 4 ++--
 11 files changed, 15 insertions(+), 15 deletions(-)

diff --git a/commons-jcs-core/src/main/java/org/apache/commons/jcs3/admin/JCSAdminBean.java b/commons-jcs-core/src/main/java/org/apache/commons/jcs3/admin/JCSAdminBean.java
index 617801fc..ea0de214 100644
--- a/commons-jcs-core/src/main/java/org/apache/commons/jcs3/admin/JCSAdminBean.java
+++ b/commons-jcs-core/src/main/java/org/apache/commons/jcs3/admin/JCSAdminBean.java
@@ -64,7 +64,7 @@ public class JCSAdminBean implements JCSJMXBean
         }
         catch (final CacheException e)
         {
-            throw new RuntimeException("Could not retrieve cache manager instance", e);
+            throw new IllegalStateException("Could not retrieve cache manager instance", e);
         }
     }
 
@@ -196,7 +196,7 @@ public class JCSAdminBean implements JCSJMXBean
 			}
 			catch (final IOException e)
 			{
-                throw new RuntimeException("IOException while trying to get a cached element", e);
+                throw new IllegalStateException("IOException while trying to get a cached element", e);
 			}
 
 			if (ice == null)
@@ -220,7 +220,7 @@ public class JCSAdminBean implements JCSJMXBean
                 }
                 catch (final IOException e)
                 {
-                    throw new RuntimeException("IOException while trying to measure the size of the cached element", e);
+                    throw new IllegalStateException("IOException while trying to measure the size of the cached element", e);
                 }
                 finally
                 {
diff --git a/commons-jcs-core/src/main/java/org/apache/commons/jcs3/auxiliary/AbstractAuxiliaryCacheAttributes.java b/commons-jcs-core/src/main/java/org/apache/commons/jcs3/auxiliary/AbstractAuxiliaryCacheAttributes.java
index f3f166ac..d2a40b90 100644
--- a/commons-jcs-core/src/main/java/org/apache/commons/jcs3/auxiliary/AbstractAuxiliaryCacheAttributes.java
+++ b/commons-jcs-core/src/main/java/org/apache/commons/jcs3/auxiliary/AbstractAuxiliaryCacheAttributes.java
@@ -136,11 +136,11 @@ public abstract class AbstractAuxiliaryCacheAttributes
     {
         try
         {
-            return (AbstractAuxiliaryCacheAttributes)super.clone();
+            return (AbstractAuxiliaryCacheAttributes) super.clone();
         }
         catch (final CloneNotSupportedException e)
         {
-            throw new RuntimeException("Clone not supported. This should never happen.", e);
+            throw new IllegalStateException("Clone not supported. This should never happen.", e);
         }
     }
 }
diff --git a/commons-jcs-core/src/main/java/org/apache/commons/jcs3/auxiliary/disk/block/BlockDiskCache.java b/commons-jcs-core/src/main/java/org/apache/commons/jcs3/auxiliary/disk/block/BlockDiskCache.java
index a0809833..c59ac077 100644
--- a/commons-jcs-core/src/main/java/org/apache/commons/jcs3/auxiliary/disk/block/BlockDiskCache.java
+++ b/commons-jcs-core/src/main/java/org/apache/commons/jcs3/auxiliary/disk/block/BlockDiskCache.java
@@ -197,7 +197,7 @@ public class BlockDiskCache<K, V>
                     }
                     catch (final IOException | ClassNotFoundException e)
                     {
-                        throw new RuntimeException(logCacheName
+                        throw new IllegalStateException(logCacheName
                                 + " Couldn't find data for key [" + entry.getKey() + "]", e);
                     }
                 });
diff --git a/commons-jcs-core/src/main/java/org/apache/commons/jcs3/auxiliary/disk/jdbc/JDBCDiskCacheFactory.java b/commons-jcs-core/src/main/java/org/apache/commons/jcs3/auxiliary/disk/jdbc/JDBCDiskCacheFactory.java
index 5545cf51..e227efc5 100644
--- a/commons-jcs-core/src/main/java/org/apache/commons/jcs3/auxiliary/disk/jdbc/JDBCDiskCacheFactory.java
+++ b/commons-jcs-core/src/main/java/org/apache/commons/jcs3/auxiliary/disk/jdbc/JDBCDiskCacheFactory.java
@@ -254,7 +254,7 @@ public class JDBCDiskCacheFactory
             }
             catch (final SQLException e)
             {
-                throw new RuntimeException(e);
+                throw new IllegalStateException(e);
             }
     	    return newDsFactory;
     	});
diff --git a/commons-jcs-core/src/main/java/org/apache/commons/jcs3/engine/CompositeCacheAttributes.java b/commons-jcs-core/src/main/java/org/apache/commons/jcs3/engine/CompositeCacheAttributes.java
index 6c14388b..517b77f2 100644
--- a/commons-jcs-core/src/main/java/org/apache/commons/jcs3/engine/CompositeCacheAttributes.java
+++ b/commons-jcs-core/src/main/java/org/apache/commons/jcs3/engine/CompositeCacheAttributes.java
@@ -436,7 +436,7 @@ public class CompositeCacheAttributes
         }
         catch (final CloneNotSupportedException e)
         {
-            throw new RuntimeException("Clone not supported. This should never happen.", e);
+            throw new IllegalStateException("Clone not supported. This should never happen.", e);
         }
     }
 }
diff --git a/commons-jcs-core/src/main/java/org/apache/commons/jcs3/engine/ElementAttributes.java b/commons-jcs-core/src/main/java/org/apache/commons/jcs3/engine/ElementAttributes.java
index cb5150a3..bef4094a 100644
--- a/commons-jcs-core/src/main/java/org/apache/commons/jcs3/engine/ElementAttributes.java
+++ b/commons-jcs-core/src/main/java/org/apache/commons/jcs3/engine/ElementAttributes.java
@@ -453,7 +453,7 @@ public class ElementAttributes
         }
         catch (final CloneNotSupportedException e)
         {
-            throw new RuntimeException("Clone not supported. This should never happen.", e);
+            throw new IllegalStateException("Clone not supported. This should never happen.", e);
         }
     }
 }
diff --git a/commons-jcs-core/src/main/java/org/apache/commons/jcs3/log/LogManager.java b/commons-jcs-core/src/main/java/org/apache/commons/jcs3/log/LogManager.java
index ac05b39e..2a8b4f0a 100644
--- a/commons-jcs-core/src/main/java/org/apache/commons/jcs3/log/LogManager.java
+++ b/commons-jcs-core/src/main/java/org/apache/commons/jcs3/log/LogManager.java
@@ -99,7 +99,7 @@ public class LogManager
 
             // No log system could be found --> report errors to stderr
             errors.forEach(e -> System.err.println(e.getMessage()));
-            throw new RuntimeException("Could not find factory implementation for log subsystem " + logSystem);
+            throw new IllegalStateException("Could not find factory implementation for log subsystem " + logSystem);
         }
     }
 
diff --git a/commons-jcs-core/src/main/java/org/apache/commons/jcs3/utils/access/JCSWorker.java b/commons-jcs-core/src/main/java/org/apache/commons/jcs3/utils/access/JCSWorker.java
index b771dc48..515ab40e 100644
--- a/commons-jcs-core/src/main/java/org/apache/commons/jcs3/utils/access/JCSWorker.java
+++ b/commons-jcs-core/src/main/java/org/apache/commons/jcs3/utils/access/JCSWorker.java
@@ -126,7 +126,7 @@ public class JCSWorker<K, V>
         }
         catch ( final CacheException e )
         {
-            throw new RuntimeException( e.getMessage() );
+            throw new IllegalArgumentException( e.getMessage() );
         }
     }
 
diff --git a/commons-jcs-core/src/main/java/org/apache/commons/jcs3/utils/serialization/EncryptingSerializer.java b/commons-jcs-core/src/main/java/org/apache/commons/jcs3/utils/serialization/EncryptingSerializer.java
index bbe9b8d7..1efed5f8 100644
--- a/commons-jcs-core/src/main/java/org/apache/commons/jcs3/utils/serialization/EncryptingSerializer.java
+++ b/commons-jcs-core/src/main/java/org/apache/commons/jcs3/utils/serialization/EncryptingSerializer.java
@@ -95,7 +95,7 @@ public class EncryptingSerializer extends StandardSerializer
         }
         catch (NoSuchAlgorithmException e)
         {
-            throw new RuntimeException("Could not set up encryption tools", e);
+            throw new IllegalStateException("Could not set up encryption tools", e);
         }
     }
 
diff --git a/commons-jcs-core/src/main/java/org/apache/commons/jcs3/utils/threadpool/ThreadPoolManager.java b/commons-jcs-core/src/main/java/org/apache/commons/jcs3/utils/threadpool/ThreadPoolManager.java
index 8a7c1617..35854de4 100644
--- a/commons-jcs-core/src/main/java/org/apache/commons/jcs3/utils/threadpool/ThreadPoolManager.java
+++ b/commons-jcs-core/src/main/java/org/apache/commons/jcs3/utils/threadpool/ThreadPoolManager.java
@@ -163,7 +163,7 @@ public class ThreadPoolManager
                 break;
 
             case WAIT:
-                throw new RuntimeException("POLICY_WAIT no longer supported");
+                throw new UnsupportedOperationException("POLICY_WAIT no longer supported");
 
             case DISCARDOLDEST:
                 pool.setRejectedExecutionHandler(new ThreadPoolExecutor.DiscardOldestPolicy());
diff --git a/commons-jcs-core/src/test/java/org/apache/commons/jcs3/auxiliary/disk/jdbc/JDBCDataSourceFactoryUnitTest.java b/commons-jcs-core/src/test/java/org/apache/commons/jcs3/auxiliary/disk/jdbc/JDBCDataSourceFactoryUnitTest.java
index bdfbbe4a..17393d54 100644
--- a/commons-jcs-core/src/test/java/org/apache/commons/jcs3/auxiliary/disk/jdbc/JDBCDataSourceFactoryUnitTest.java
+++ b/commons-jcs-core/src/test/java/org/apache/commons/jcs3/auxiliary/disk/jdbc/JDBCDataSourceFactoryUnitTest.java
@@ -178,7 +178,7 @@ public class JDBCDataSourceFactoryUnitTest
             catch (final NamingException e)
             {
             	// can't happen.
-                throw new RuntimeException(e);
+                throw new IllegalStateException(e);
             }
         }
 
@@ -197,7 +197,7 @@ public class JDBCDataSourceFactoryUnitTest
             catch (final NamingException e)
             {
             	// can't happen.
-                throw new RuntimeException(e);
+                throw new IllegalArgumentException(e);
             }
         }
     }