8241883: (zipfs) SeekableByteChannel:close followed by SeekableByteChannel:close will throw an NPE coverage
Reviewed-by: clanger, alanb
This commit is contained in:
parent
f11d4628c1
commit
93831d4ed2
@ -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 @@ public class ByteArrayChannel implements SeekableByteChannel {
|
||||
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 @@ class ZipFileSystem extends FileSystem {
|
||||
|
||||
@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 class ChannelTests extends ZipFsBaseTest {
|
||||
/**
|
||||
* 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");
|
||||
|
Loading…
Reference in New Issue
Block a user