There's a really strange issue in a stress test. The issue can not be 100% reproduced, so I used following codes and successfully reproduced it:
269 >---String16 test1 = String16("0");
270 >---String16 test2 = String16("0");
271 >---String16 test3 = String16("1");
272 >---String16 test4 = String16("1");
273 >---String16 test5 = String16("12");
274 >---String8 test6 = String8("12");
275 >---const char* s1 = String8(test1).string();
276 >---PLOGI("s1: %s", s1);
277 >---const char* s2 = String8(test2);
278 >---PLOGI("s2: %s", s2);
279 >---const char* s3 = String8(test3).string();
280 >---PLOGI("s3: %s", s3);
281 >---const char* s4 = String8(test4);
282 >---PLOGI("s4: %s", s4);
283 >---const char* s5 = String8(test5);
284 >---PLOGI("s5: %s", s5);
285 >---const char* s6 = test6;
286 >---PLOGI("s6: %s", s6);
Most of the logs output are as expected:
2432 I/PHService( 127): s1: 0
2433 I/PHService( 127): s2: 0
2434 I/PHService( 127): s3: 1
2435 I/PHService( 127): s4: 1
2436 I/PHService( 127): s5: 12
2437 I/PHService( 127): s6: 12
But few of them are like:
2458 I/PHService( 127): s1: ^X
2459 I/PHService( 127): s2: ^X
2460 I/PHService( 127): s3: ^X
2461 I/PHService( 127): s4: ^X
2462 I/PHService( 127): s5: ^X
2463 I/PHService( 127): s6: 12
It seems that the data after converted was corrupted(^X is the corrupted data), but it only happened to String8(Strng16) but not to String8(). I'm not sure how this happened. I used operator
String8::operator const char*() const
which should be workable for String8(Strng16) as well.