Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8334467

serializing request json of int field empty after convertion give default value

XMLWordPrintable

      ADDITIONAL SYSTEM INFORMATION :
      Anything

      A DESCRIPTION OF THE PROBLEM :
      Dear Team,
                        I have faced int value giving default value of zero when i am giving a "". Is this right?. Please code given below

               
      UserDetails Pojo:
      public class UserDetails implements Serializable {

          int userdetuserid;
          String userdetloginname;
          int useradminstate;
      }
            
      Request Json of UserDetails

      {
        "userdetuserid" : "1",
      "userdetloginname" : "john",
      "useradminstate" : ""
      }

      Conversion happening with default value while load request json to the pojo

       UserDetails(userdetuserid=1, userdetloginname=john, useradminstate=0)

      REGRESSION : Last worked in version 8u411

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      UserDetails Pojo:
      public class UserDetails implements Serializable {

          int userdetuserid;
          String userdetloginname;
          int useradminstate;
      }
            
      Request Json of UserDetails

      {
        "userdetuserid" : "1",
      "userdetloginname" : "john",
      "useradminstate" : ""
      }

      Conversion happening with default value while load request json to the pojo

       UserDetails(userdetuserid=1, userdetloginname=john, useradminstate=0)


      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      Number Format Exception
      ACTUAL -
      UserDetails(userdetuserid=1, userdetloginname=john, useradminstate=0)

      ---------- BEGIN SOURCE ----------
      Request Json of UserDetails

      {
        "userdetuserid" : "1",
      "userdetloginname" : "john",
      "useradminstate" : ""
      }

      Conversion happening with default value while load request json to the pojo

       UserDetails(userdetuserid=1, userdetloginname=john, useradminstate=0)
      ---------- END SOURCE ----------

      CUSTOMER SUBMITTED WORKAROUND :
      Request Json of UserDetails

      {
        "userdetuserid" : "1",
      "userdetloginname" : "john",
      "useradminstate" : ""
      }

      Conversion happening with default value while load request json to the pojo

       UserDetails(userdetuserid=1, userdetloginname=john, useradminstate=0)

      FREQUENCY : always


            tongwan Andrew Wang
            webbuggrp Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: