@@ -548,11 +548,11 @@ public static ResponseStatus createResponseStatus(JsonObject obj) {
548548 Object field = obj .get (key );
549549
550550 if (varName .toLowerCase ().equals ("errorcode" )) {
551- status .setErrorCode (jsonElementEntry .getValue (). getAsString ( ));
551+ status .setErrorCode (getAsStringOrNull ( jsonElementEntry .getValue ()));
552552 } else if (varName .toLowerCase ().equals ("message" )) {
553- status .setMessage (jsonElementEntry .getValue (). getAsString ( ));
553+ status .setMessage (getAsStringOrNull ( jsonElementEntry .getValue ()));
554554 } else if (varName .toLowerCase ().equals ("stacktrace" )) {
555- status .setStackTrace (jsonElementEntry .getValue (). getAsString ( ));
555+ status .setStackTrace (getAsStringOrNull ( jsonElementEntry .getValue ()));
556556 } else if (varName .toLowerCase ().equals ("errors" )) {
557557
558558 if (field instanceof JsonArray ){
@@ -567,11 +567,11 @@ public static ResponseStatus createResponseStatus(JsonObject obj) {
567567 String fieldName = Utils .sanitizeVarName (fieldKey );
568568
569569 if (fieldName .toLowerCase ().equals ("errorcode" )) {
570- fieldError .setErrorCode (entry .getValue (). getAsString ( ));
570+ fieldError .setErrorCode (getAsStringOrNull ( entry .getValue ()));
571571 } else if (fieldName .toLowerCase ().equals ("message" )) {
572- fieldError .setMessage (entry .getValue (). getAsString ( ));
572+ fieldError .setMessage (getAsStringOrNull ( entry .getValue ()));
573573 } else if (fieldName .toLowerCase ().equals ("fieldname" )) {
574- fieldError .setFieldName (entry .getValue (). getAsString ( ));
574+ fieldError .setFieldName (getAsStringOrNull ( entry .getValue ()));
575575 }
576576
577577 }
@@ -729,6 +729,10 @@ public static byte[] toBase64Bytes(byte[] source, int off, int len) {
729729 }
730730 }
731731
732+ private static String getAsStringOrNull (JsonElement jsonElement ) {
733+ return jsonElement .isJsonNull () ? null : jsonElement .getAsString ();
734+ }
735+
732736 private final static byte EQUALS_SIGN = (byte )'=' ;
733737
734738 private final static byte [] _STANDARD_ALPHABET = {
0 commit comments