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/juneau.git
commit 6d1514eee478970fa833c6d91ae59794c7a5cb38 Author: Gary Gregory <[email protected]> AuthorDate: Fri Jun 23 13:48:26 2023 -0400 [juneau-marshall] Throw IllegalArgumentException instead of RuntimeException --- .../src/main/java/org/apache/juneau/BeanBuilder.java | 4 ++-- .../src/main/java/org/apache/juneau/BeanPropertyMeta.java | 6 +++--- .../src/main/java/org/apache/juneau/annotation/AnnotationImpl.java | 2 +- .../src/main/java/org/apache/juneau/collections/JsonMap.java | 2 +- .../src/main/java/org/apache/juneau/cp/BeanStore.java | 4 ++-- .../src/main/java/org/apache/juneau/cp/ContextBeanCreator.java | 2 +- .../src/main/java/org/apache/juneau/internal/ListBuilder.java | 4 ++-- .../src/main/java/org/apache/juneau/internal/MapBuilder.java | 4 ++-- .../src/main/java/org/apache/juneau/internal/SetBuilder.java | 2 +- 9 files changed, 15 insertions(+), 15 deletions(-) diff --git a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/BeanBuilder.java b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/BeanBuilder.java index 775659192..41f349702 100644 --- a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/BeanBuilder.java +++ b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/BeanBuilder.java @@ -87,7 +87,7 @@ public class BeanBuilder<T> { */ protected BeanCreator<? extends T> creator() { return beanStore - .createBean(type().orElseThrow(()->new RuntimeException("Type not specified."))) + .createBean(type().orElseThrow(() -> new IllegalStateException("Type not specified."))) .builder(BeanBuilder.class, this); } @@ -98,7 +98,7 @@ public class BeanBuilder<T> { */ protected T buildDefault() { return beanStore - .createBean(type().orElseThrow(()->new RuntimeException("Type not specified."))) + .createBean(type().orElseThrow(() -> new IllegalStateException("Type not specified."))) .builder(BeanBuilder.class, this) .run(); } diff --git a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/BeanPropertyMeta.java b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/BeanPropertyMeta.java index a5706add3..428d33eb8 100644 --- a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/BeanPropertyMeta.java +++ b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/BeanPropertyMeta.java @@ -331,13 +331,13 @@ public final class BeanPropertyMeta implements Comparable<BeanPropertyMeta> { if (ci.isChildOf(ObjectSwap.class)) { ObjectSwap ps = BeanCreator.of(ObjectSwap.class).type(c).run(); if (ps.forMediaTypes() != null) - throw new RuntimeException("TODO - Media types on swaps not yet supported on bean properties."); + throw new UnsupportedOperationException("TODO - Media types on swaps not yet supported on bean properties."); if (ps.withTemplate() != null) - throw new RuntimeException("TODO - Templates on swaps not yet supported on bean properties."); + throw new UnsupportedOperationException("TODO - Templates on swaps not yet supported on bean properties."); return ps; } if (ci.isChildOf(Surrogate.class)) - throw new RuntimeException("TODO - Surrogate swaps not yet supported on bean properties."); + throw new UnsupportedOperationException("TODO - Surrogate swaps not yet supported on bean properties."); throw new BasicRuntimeException("Invalid class used in @Swap annotation. Must be a subclass of ObjectSwap or Surrogate. {0}", c); } diff --git a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/annotation/AnnotationImpl.java b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/annotation/AnnotationImpl.java index 3e91180ec..684b08e6c 100644 --- a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/annotation/AnnotationImpl.java +++ b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/annotation/AnnotationImpl.java @@ -71,7 +71,7 @@ public class AnnotationImpl implements Annotation { @Override /* Object */ public int hashCode() { if (hashCode == -1) - throw new RuntimeException("Programming error. postConstruct() was never called on annotation."); + throw new IllegalArgumentException("Programming error. postConstruct() was never called on annotation."); return hashCode; } diff --git a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/collections/JsonMap.java b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/collections/JsonMap.java index 2cbcbf4bb..438b9ec38 100644 --- a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/collections/JsonMap.java +++ b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/collections/JsonMap.java @@ -371,7 +371,7 @@ public class JsonMap extends LinkedHashMap<String,Object> { */ public JsonMap(Object... keyValuePairs) { if (keyValuePairs.length % 2 != 0) - throw new RuntimeException("Odd number of parameters passed into JsonMap(Object...)"); + throw new IllegalArgumentException("Odd number of parameters passed into JsonMap(Object...)"); for (int i = 0; i < keyValuePairs.length; i+=2) put(stringify(keyValuePairs[i]), keyValuePairs[i+1]); } diff --git a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/cp/BeanStore.java b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/cp/BeanStore.java index 3eb46fd8a..96e477468 100644 --- a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/cp/BeanStore.java +++ b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/cp/BeanStore.java @@ -576,7 +576,7 @@ public class BeanStore { * @return The method finder. Never <jk>null</jk>. */ public <T> BeanCreateMethodFinder<T> createMethodFinder(Class<T> beanType) { - return new BeanCreateMethodFinder<>(beanType, outer.orElseThrow(()->new RuntimeException("Method cannot be used without outer bean definition.")), this); + return new BeanCreateMethodFinder<>(beanType, outer.orElseThrow(() -> new IllegalArgumentException("Method cannot be used without outer bean definition.")), this); } /** @@ -694,7 +694,7 @@ public class BeanStore { private void assertCanWrite() { if (readOnly) - throw new RuntimeException("Method cannot be used because BeanStore is read-only."); + throw new IllegalStateException("Method cannot be used because BeanStore is read-only."); } private JsonMap properties() { diff --git a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/cp/ContextBeanCreator.java b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/cp/ContextBeanCreator.java index eaca9b5d3..4308b7f72 100644 --- a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/cp/ContextBeanCreator.java +++ b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/cp/ContextBeanCreator.java @@ -92,7 +92,7 @@ public class ContextBeanCreator<T> { public ContextBeanCreator<T> type(Class<? extends T> value) { builder = Context.createBuilder((Class<? extends Context>) value); if (builder == null) - throw new RuntimeException("Creator for class {0} not found." + value.getName()); + throw new IllegalArgumentException("Creator for class {0} not found." + value.getName()); return this; } diff --git a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/internal/ListBuilder.java b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/internal/ListBuilder.java index 0fcde38ef..4d3447e81 100644 --- a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/internal/ListBuilder.java +++ b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/internal/ListBuilder.java @@ -226,9 +226,9 @@ public final class ListBuilder<E> { * @param values The values to add. * @return This object. */ - public ListBuilder<E> addAny(Object...values) { + public ListBuilder<E> addAny(Object... values) { if (elementType == null) - throw new RuntimeException("Unknown element type. Cannot use this method."); + throw new IllegalStateException("Unknown element type. Cannot use this method."); try { if (values != null) { for (Object o : values) { diff --git a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/internal/MapBuilder.java b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/internal/MapBuilder.java index 053190942..e6a84b94f 100644 --- a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/internal/MapBuilder.java +++ b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/internal/MapBuilder.java @@ -204,7 +204,7 @@ public final class MapBuilder<K,V> { @SuppressWarnings("unchecked") public MapBuilder<K,V> addAny(Object...values) { if (keyType == null || valueType == null) - throw new RuntimeException("Unknown key and value types. Cannot use this method."); + throw new IllegalStateException("Unknown key and value types. Cannot use this method."); try { for (Object o : values) { if (o != null) { @@ -232,7 +232,7 @@ public final class MapBuilder<K,V> { @SuppressWarnings("unchecked") public MapBuilder<K,V> addPairs(Object...pairs) { if (pairs.length % 2 != 0) - throw new RuntimeException("Odd number of parameters passed into AMap.ofPairs()"); + throw new IllegalArgumentException("Odd number of parameters passed into AMap.ofPairs()"); for (int i = 0; i < pairs.length; i+=2) add((K)pairs[i], (V)pairs[i+1]); return this; diff --git a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/internal/SetBuilder.java b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/internal/SetBuilder.java index 18247ce94..4e8e5336a 100644 --- a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/internal/SetBuilder.java +++ b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/internal/SetBuilder.java @@ -211,7 +211,7 @@ public final class SetBuilder<E> { */ public SetBuilder<E> addAny(Object...values) { if (elementType == null) - throw new RuntimeException("Unknown element type. Cannot use this method."); + throw new IllegalStateException("Unknown element type. Cannot use this method."); try { if (values != null) { for (Object o : values) {
