You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@harmony.apache.org by te...@apache.org on 2009/07/13 17:09:58 UTC
svn commit: r793606 - in /harmony/enhanced/classlib/trunk/modules/luni/src:
main/java/java/io/ main/java/org/apache/harmony/luni/util/
test/api/common/org/apache/harmony/luni/tests/java/io/
Author: tellison
Date: Mon Jul 13 15:09:58 2009
New Revision: 793606
URL: http://svn.apache.org/viewvc?rev=793606&view=rev
Log:
Apply slightly modified fix for HARMONY-6259 ([classlib][luni] PipedInputStream.read throw different info when IOException is raised)
Modified:
harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/PipedInputStream.java
harmony/enhanced/classlib/trunk/modules/luni/src/main/java/org/apache/harmony/luni/util/ExternalMessages.properties
harmony/enhanced/classlib/trunk/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/io/PipedInputStreamTest.java
Modified: harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/PipedInputStream.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/PipedInputStream.java?rev=793606&r1=793605&r2=793606&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/PipedInputStream.java (original)
+++ harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/PipedInputStream.java Mon Jul 13 15:09:58 2009
@@ -150,11 +150,18 @@
@Override
public synchronized int read() throws IOException {
if (!isConnected) {
+ // K0074=Not connected
throw new IOException(Msg.getString("K0074")); //$NON-NLS-1$
}
if (buffer == null) {
+ // K0075=InputStream is closed
throw new IOException(Msg.getString("K0075")); //$NON-NLS-1$
}
+
+ if (lastWriter != null && !lastWriter.isAlive() && (in < 0)) {
+ // KA030=Write end dead
+ throw new IOException(Msg.getString("KA030")); //$NON-NLS-1$
+ }
/**
* Set the last thread to be reading on this PipedInputStream. If
* lastReader dies while someone is waiting to write an IOException of
@@ -169,6 +176,7 @@
return -1;
}
if ((attempts-- <= 0) && lastWriter != null && !lastWriter.isAlive()) {
+ // K0076=Pipe broken
throw new IOException(Msg.getString("K0076")); //$NON-NLS-1$
}
// Notify callers of receive()
@@ -239,13 +247,20 @@
}
if (!isConnected) {
+ // K0074=Not connected
throw new IOException(Msg.getString("K0074")); //$NON-NLS-1$
}
if (buffer == null) {
+ // K0075=InputStream is closed
throw new IOException(Msg.getString("K0075")); //$NON-NLS-1$
}
+ if (lastWriter != null && !lastWriter.isAlive() && (in < 0)) {
+ // KA030=Write end dead
+ throw new IOException(Msg.getString("KA030")); //$NON-NLS-1$
+ }
+
/**
* Set the last thread to be reading on this PipedInputStream. If
* lastReader dies while someone is waiting to write an IOException of
@@ -260,6 +275,7 @@
return -1;
}
if ((attempts-- <= 0) && lastWriter != null && !lastWriter.isAlive()) {
+ // K0076=Pipe broken
throw new IOException(Msg.getString("K0076")); //$NON-NLS-1$
}
// Notify callers of receive()
Modified: harmony/enhanced/classlib/trunk/modules/luni/src/main/java/org/apache/harmony/luni/util/ExternalMessages.properties
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/org/apache/harmony/luni/util/ExternalMessages.properties?rev=793606&r1=793605&r2=793606&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/luni/src/main/java/org/apache/harmony/luni/util/ExternalMessages.properties (original)
+++ harmony/enhanced/classlib/trunk/modules/luni/src/main/java/org/apache/harmony/luni/util/ExternalMessages.properties Mon Jul 13 15:09:58 2009
@@ -323,3 +323,4 @@
KA027=Inputstream of the JarURLConnection has been closed
KA028=Cannot set protocol version when stream in use
KA029=Can't find resource for bundle {0}, key {1}
+KA030=Write end dead
Modified: harmony/enhanced/classlib/trunk/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/io/PipedInputStreamTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/io/PipedInputStreamTest.java?rev=793606&r1=793605&r2=793606&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/io/PipedInputStreamTest.java (original)
+++ harmony/enhanced/classlib/trunk/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/io/PipedInputStreamTest.java Mon Jul 13 15:09:58 2009
@@ -73,6 +73,33 @@
pis.available();
}
+
+ /**
+ * @test java.io.PipedInputStream#read()
+ */
+ public void test_readException() {
+ pis = new PipedInputStream();
+ pos = new PipedOutputStream();
+
+ try {
+ pis.connect(pos);
+ t = new Thread(pw = new PWriter(pos, 1000));
+ t.start();
+ assertTrue(t.isAlive());
+ while (true) {
+ pis.read();
+ t.interrupted();
+ }
+ } catch (IOException e) {
+ assertTrue(e.getMessage().contains("Write end dead"));
+ } finally {
+ try {
+ pis.close();
+ pos.close();
+ } catch (IOException ee) {}
+ }
+ }
+
/**
* @tests java.io.PipedInputStream#available()
*/