Skip to content
Permalink
Browse files
8241883: (zipfs) SeekableByteChannel:close followed by SeekableByteCh…
…annel:close will throw an NPE coverage

Reviewed-by: clanger, alanb
  • Loading branch information
Lance Andersen committed Apr 10, 2020
1 parent f11d462 commit 93831d4ed257fc7b9ba298189791fd3bfddf4df0
Showing 3 changed files with 15 additions and 10 deletions.
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2018, 2020, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -194,11 +194,11 @@ private void ensureOpen() throws IOException {
throw new ClosedChannelException();
}

private final void beginWrite() {
final void beginWrite() {
rwlock.writeLock().lock();
}

private final void endWrite() {
final void endWrite() {
rwlock.writeLock().unlock();
}

@@ -892,11 +892,18 @@ private class EntryOutputChannel extends ByteArrayChannel {

@Override
public void close() throws IOException {
// will update the entry
try (OutputStream os = getOutputStream(e)) {
os.write(toByteArray());
super.beginWrite();
try {
if (!isOpen())
return;
// will update the entry
try (OutputStream os = getOutputStream(e)) {
os.write(toByteArray());
}
super.close();
} finally {
super.endWrite();
}
super.close();
}
}

@@ -339,14 +339,12 @@ public void sbcFAETest(final Map<String, String> env,
/**
* Validate when SeekableByteChannel::close is called more than once, that
* no error occurs
* <p>
* Note: this is currently disabled due to bug JDK-8241883
*
* @param env Zip FS properties to use when creating the Zip file
* @param compression The compression used when writing the entries
* @throws Exception If an error occurs
*/
@Test(dataProvider = "zipfsMap", enabled = false)
@Test(dataProvider = "zipfsMap")
public void sbcCloseTest(final Map<String, String> env,
final int compression) throws Exception {
Path zipFile = generatePath(HERE, "test", ".zip");

0 comments on commit 93831d4

Please sign in to comment.