flink-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "ASF GitHub Bot (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (FLINK-11122) SafetyNetCloseableRegistryTest fails with ClassCastException
Date Wed, 12 Dec 2018 10:22:00 GMT

    [ https://issues.apache.org/jira/browse/FLINK-11122?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16718739#comment-16718739
] 

ASF GitHub Bot commented on FLINK-11122:
----------------------------------------

StefanRRichter commented on a change in pull request #7273: [FLINK-11122][core] Change signature
of WrappingProxyUtil#stripProxy(T)
URL: https://github.com/apache/flink/pull/7273#discussion_r240955517
 
 

 ##########
 File path: flink-core/src/test/java/org/apache/flink/core/fs/AbstractCloseableRegistryTest.java
 ##########
 @@ -225,4 +209,55 @@ public synchronized void close() throws IOException {
 			refCount.decrementAndGet();
 		}
 	}
+
+	/**
+	 * A noop {@link Closeable} implementation that blocks inside {@link #close()}.
+	 */
+	private static class BlockingTestCloseable implements Closeable {
+
+		private final CountDownLatch closeCalledLatch = new CountDownLatch(1);
+
+		private final CountDownLatch blockCloseLatch = new CountDownLatch(1);
+
+		@Override
+		public void close() throws IOException {
+			closeCalledLatch.countDown();
+			try {
+				blockCloseLatch.await();
+			} catch (InterruptedException e) {
+				Thread.currentThread().interrupt();
+			}
+		}
+
+		/**
+		 * Unblocks {@link #close()}.
+		 */
+		public void unblockClose() {
+			blockCloseLatch.countDown();
+		}
+
+		/**
+		 * Causes the current thread to wait until {@link #close()} is called.
+		 */
+		public void awaitClose(final long timeout, final TimeUnit timeUnit) throws InterruptedException
{
+			closeCalledLatch.await(timeout, timeUnit);
+		}
+	}
+
+	/**
+	 * A noop {@link Closeable} implementation that tracks whether it was closed.
+	 */
+	private static class TestCloseable implements Closeable {
+
+		private final AtomicBoolean closed = new AtomicBoolean();
+
+		@Override
+		public void close() throws IOException {
+			closed.set(true);
 
 Review comment:
   We could make the test a bit stricter by ensuring `compareAndSet(false, true)` to check
that close should also be called only once. A small improvent that would be cheap to do.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


> SafetyNetCloseableRegistryTest fails with ClassCastException
> ------------------------------------------------------------
>
>                 Key: FLINK-11122
>                 URL: https://issues.apache.org/jira/browse/FLINK-11122
>             Project: Flink
>          Issue Type: Sub-task
>          Components: Tests
>            Reporter: Gary Yao
>            Assignee: Gary Yao
>            Priority: Major
>              Labels: pull-request-available
>             Fix For: 1.8.0
>
>
> When compiling and running {{SafetyNetCloseableRegistryTest}} with Java 9, some tests
fail with a {{ClassCastException}}
> {noformat}
> java.lang.AssertionError: java.lang.ClassCastException: org.apache.flink.core.fs.local.LocalDataOutputStream
cannot be cast to org.apache.flink.core.fs.WrappingProxyCloseable
> 	at org.apache.flink.core.fs.SafetyNetCloseableRegistry$PhantomDelegatingCloseableRef.<init>(SafetyNetCloseableRegistry.java:156)
> 	at org.apache.flink.core.fs.SafetyNetCloseableRegistry.doRegister(SafetyNetCloseableRegistry.java:99)
> 	at org.apache.flink.core.fs.SafetyNetCloseableRegistry.doRegister(SafetyNetCloseableRegistry.java:50)
> 	at org.apache.flink.util.AbstractCloseableRegistry.registerCloseable(AbstractCloseableRegistry.java:79)
> 	at org.apache.flink.core.fs.ClosingFSDataOutputStream.wrapSafe(ClosingFSDataOutputStream.java:101)
> 	at org.apache.flink.core.fs.SafetyNetWrapperFileSystem.create(SafetyNetWrapperFileSystem.java:127)
> 	at org.apache.flink.core.fs.SafetyNetCloseableRegistryTest$3.go(SafetyNetCloseableRegistryTest.java:120)
> 	at org.apache.flink.core.testutils.CheckedThread.run(CheckedThread.java:74)
> {noformat}
> This is due to the problematic signature in {{WrappingProxyUtil#stripProxy(T)}}, which
expects a generic type {{T}} and also returns {{T}}. 



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Mime
View raw message