@@ -76,8 +76,12 @@ public Problem(
7676 this (type , title , status , detail , instance , buildMapFromExtensions (extensions ));
7777 }
7878
79+ /**
80+ * @throws IllegalArgumentException if extensions are not key-value pairs (odd number of elements)
81+ */
7982 public Problem (
80- URI type , String title , int status , String detail , URI instance , Object ... extensions ) {
83+ URI type , String title , int status , String detail , URI instance , Object ... extensions )
84+ throws IllegalArgumentException {
8185 this (type , title , status , detail , instance , buildMapFromRawArgs (extensions ));
8286 }
8387
@@ -95,7 +99,12 @@ private static Map<String, Object> buildMapFromExtensions(Extension[] extensions
9599 return map ;
96100 }
97101
98- private static Map <String , Object > buildMapFromRawArgs (Object [] arguments ) {
102+ private static Map <String , Object > buildMapFromRawArgs (Object [] arguments )
103+ throws IllegalArgumentException {
104+ if (arguments .length % 2 != 0 ) {
105+ throw new IllegalArgumentException ("extensions arguments must be key-value pairs" );
106+ }
107+
99108 Map <String , Object > map = new HashMap <>(arguments .length / 2 );
100109
101110 List <Object > valuesAsList = new ArrayList <>(Arrays .asList (arguments ));
0 commit comments