We have some code performing var1 + "\t" + var2 ... where var1 and var2 are of type String, but it is producing the following stack trace:
Caused by: java.lang.ArrayStoreException
at java.lang.String.getChars(String.java:814) [rt.jar:1.8.0_40]
at java.lang.AbstractStringBuilder.append(AbstractStringBuilder.java:422) [rt.jar:1.8.0_40]
at java.lang.StringBuilder.append(StringBuilder.java:136) [rt.jar:1.8.0_40]
The OS here is CentOS 6.6 with Oracle Java 1.8.0_40
How is this even possible? String.getChars is performing a System.arraycopy(...) and passing src and tgt vars typed as char[]
The only thing I could find online that remotely came close to this issue was this bug report for "Firefox for Android" https://bugzilla.mozilla.org/show_bug.cgi?id=861660 from 2013 that has no followups.
This is the actual line of code that triggers the call to StringBuilder.append:
bw.write(
id + "\t" + effectiveTime + "\t" + active + "\t"
+ moduleId + "\t" + lhsId + "\t" + rhsId + "\t"
+ roleGroup + "\t" + roleId + "\t"
+ inferredTypeId + "\t" + someId);
All the variables here are of type String and bw is a BufferedWriter (not that I expect that to matter). Also, there are no Threads to speak of at this point in the system. Unfortunately, we cannot replicate the bug in our tests, only those of our customer.