0

I'm trying to log in to soap request, if my input is just a String object, ReflectionToStringBuilder build a log with my object splitted char by char. The strange thing is that if I have a String inside an Object It log well. How fix this ?

Code in java method, c is the single object to log:

  ToStringStyle style = new RecursiveToStringStyle();
  style = new MultilineRecursiveToStringStyle();
  logClass.append(ReflectionToStringBuilder.toString(c,style.MULTI_LINE_STYLE));    

Soap request example:

  <v12:serviceName>
     <v12:cod1>05034</v12:cod1>
     <v12:obj>
        <v13:objName>GOOGLE</v13:objName>
        <v13:objCode>123456789</v13:objCode>
     </v12:obj>
  </v12:serviceName>

Log result:

  2019-04-08 15:54:49,237 INFO  [null] - serviceName - INPUT:
  java.lang.String@ebbb509[
    value={0,5,0,3,4}
    hash=45955692
  ]
   obj@183ef29d[
   objName=GOOGLE
   objCode=123456789
  ]

Expected log result:

  2019-04-08 15:54:49,237 INFO  [null] - serviceName - INPUT:
  java.lang.String@ebbb509[
    value=05034
    hash=45955692
  ]
   obj@183ef29d[
   objName=GOOGLE
   objCode=123456789
  ]
Storm
  • 73
  • 1
  • 1
  • 12
  • Well, first, you expect a String containing an extra 4: `050434`. I assume that is a typo, since the hash code of the string `05034` of the current implementation of `String`'s `hashCode()` is indeed `45955692`. Second, it looks like `value` and `hash` are just two of the properties of `String`. `value` is a `char[]`, that's why it is printed as `{0,5,0,3,4}`. – MC Emperor Apr 08 '19 at 14:16
  • @MCEmperor You have right it was a typo. You have right also about the result and I know that hash and char are two proprerty of the String. But I'm trying to obtain a log without them and just with the string. Moreover also objName is a String so why It doesn't print the chars and the hash of it – Storm Apr 09 '19 at 08:47

0 Answers0