The failing test does this (amongst other things):
final int THREAD_NUM = 20;
Thread[] thread = new Thread[THREAD_NUM];
for (int i = 0; i < THREAD_NUM; i++) {
thread[i] = new Thread() {
public void run() {
try {
sink
.write(ByteBuffer.wrap("bytes"
***** .getBytes(ISO8859_1)));
} catch (IOException e) {
throw new RuntimeException(e);
}
}
};
}
for (int i = 0; i < THREAD_NUM; i++) {
thread[i].start();
}
If String#getBytes(String) is not thread safe then we are doomed ;-)
How about:
@@ -104,14 +104,13 @@
public void test_write_LByteBuffer_mutliThread() throws IOException,
InterruptedException {
final int THREAD_NUM = 20;
+ final byte[] strbytes = "bytes".getBytes(ISO8859_1);
Thread[] thread = new Thread[THREAD_NUM];
for (int i = 0; i < THREAD_NUM; i++) {
thread[i] = new Thread() {
public void run() {
try {
- sink
- .write(ByteBuffer.wrap("bytes"
- .getBytes(ISO8859_1)));
+ sink.write(ByteBuffer.wrap(strbytes));
} catch (IOException e) {
throw new RuntimeException(e);
}
Regards,
Tim
Apache Harmony Build wrote:
<snip>
> [exec] [junit] java.lang.IllegalStateException
> [exec] [junit] at
> java.nio.charset.CharsetEncoder.encode(CharsetEncoder.java:480)
> [exec] [junit] at
> java.nio.charset.CharsetEncoder.encode(CharsetEncoder.java:347)
> [exec] [junit] at
> java.nio.charset.Charset.encode(Charset.java:639)
> [exec] [junit] at java.lang.String.getBytes(String.java:838)
> [exec] [junit] at
> org.apache.harmony.tests.java.nio.channels.SinkChannelTest$1.run(SinkChannelTest.java:112)
> [exec] [junit] Tests FAILED
--
Tim Ellison ([EMAIL PROTECTED])
IBM Java technology centre, UK.
---------------------------------------------------------------------
Terms of use : http://incubator.apache.org/harmony/mailing.html
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]