6879463
Xueming Shen
Xueming.Shen at Sun.COM
Sun Oct 18 12:50:11 PDT 2009
looks fine.
Alan Bateman wrote:
> Sherman,
>
> Do you mind reviewing this JCK failure? The openjdk servers have been
> down so I couldn't push it to cr.openjdk.java.net. The bug is that
> the iterator methods are specific to throw a
> ConcurrentModificationException with cause
> ClosedDirectoryStreamException if invoked when the stream is closed.
> Unfortunately I didn't have this quite right in a few places.
>
> Thanks,
>
>
> -Alan.
>
> diff -r f6770138c0fa
> src/solaris/classes/sun/nio/fs/UnixDirectoryStream.java
> --- a/src/solaris/classes/sun/nio/fs/UnixDirectoryStream.java Sat
> Oct 10 10:14:51 2009 +0100
> +++ b/src/solaris/classes/sun/nio/fs/UnixDirectoryStream.java Tue
> Oct 13 21:28:04 2009 +0100
> @@ -235,7 +235,8 @@ class UnixDirectoryStream
> @Override
> public void remove() {
> if (isClosed) {
> - throw new ClosedDirectoryStreamException();
> + throwAsConcurrentModificationException(new
> + ClosedDirectoryStreamException());
> }
> Path entry;
> synchronized (this) {
> diff -r f6770138c0fa
> src/windows/classes/sun/nio/fs/WindowsDirectoryStream.java
> ---
> a/src/windows/classes/sun/nio/fs/WindowsDirectoryStream.java
> Sat Oct 10 10:14:51 2009 +0100
> +++
> b/src/windows/classes/sun/nio/fs/WindowsDirectoryStream.java
> Tue Oct 13 21:28:04 2009 +0100
> @@ -179,7 +179,7 @@ class WindowsDirectoryStream
> synchronized (closeLock) {
> if (!isOpen)
> throwAsConcurrentModificationException(new
> - IllegalStateException("Directory stream
> is closed"));
> + ClosedDirectoryStreamException());
> try {
> name = FindNextFile(handle,
> findDataBuffer.address());
> if (name == null) {
> @@ -236,7 +236,8 @@ class WindowsDirectoryStream
> @Override
> public void remove() {
> if (!isOpen) {
> - throw new IllegalStateException("Directory stream is
> closed");
> + throwAsConcurrentModificationException(new
> + ClosedDirectoryStreamException());
> }
> Path entry;
> synchronized (this) {
> diff -r f6770138c0fa test/java/nio/file/DirectoryStream/Basic.java
> --- a/test/java/nio/file/DirectoryStream/Basic.java Sat Oct 10
> 10:14:51 2009 +0100
> +++ b/test/java/nio/file/DirectoryStream/Basic.java Tue Oct 13
> 21:28:04 2009 +0100
> @@ -154,8 +154,10 @@ public class Basic {
> stream.close();
>
> // test IllegalStateException
> + dir.resolve(foo).createFile();
> stream = dir.newDirectoryStream();
> i = stream.iterator();
> + i.next();
> try {
> stream.iterator();
> throw new RuntimeException("IllegalStateException not
> thrown as expected");
> @@ -172,17 +174,26 @@ public class Basic {
> throw new
> RuntimeException("ConcurrentModificationException not thrown as
> expected");
> } catch (ConcurrentModificationException x) {
> Throwable t = x.getCause();
> - if (!(t instanceof IllegalStateException))
> - throw new RuntimeException("Cause is not
> IllegalStateException as expected");
> + if (!(t instanceof ClosedDirectoryStreamException))
> + throw new RuntimeException("Cause is not
> ClosedDirectoryStreamException as expected");
> }
> try {
> i.next();
> - throw new RuntimeException("IllegalStateException not
> thrown as expected");
> - } catch (ConcurrentModificationException x) {
> - Throwable t = x.getCause();
> - if (!(t instanceof IllegalStateException))
> - throw new RuntimeException("Cause is not
> IllegalStateException as expected");
> - }
> + throw new
> RuntimeException("ConcurrentModificationException not thrown as
> expected");
> + } catch (ConcurrentModificationException x) {
> + Throwable t = x.getCause();
> + if (!(t instanceof ClosedDirectoryStreamException))
> + throw new RuntimeException("Cause is not
> ClosedDirectoryStreamException as expected");
> + }
> + try {
> + i.remove();
> + throw new
> RuntimeException("ConcurrentModificationException not thrown as
> expected");
> + } catch (ConcurrentModificationException x) {
> + Throwable t = x.getCause();
> + if (!(t instanceof ClosedDirectoryStreamException))
> + throw new RuntimeException("Cause is not
> ClosedDirectoryStreamException as expected");
> + }
> +
> }
>
> public static void main(String[] args) throws IOException {
>
>
>
>
>
>
More information about the nio-dev
mailing list