flink-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From yanghua <...@git.apache.org>
Subject [GitHub] flink pull request #6081: [FLINK-8067] User code ClassLoader not set before ...
Date Wed, 13 Jun 2018 15:16:07 GMT
Github user yanghua commented on a diff in the pull request:

    https://github.com/apache/flink/pull/6081#discussion_r195124501
  
    --- Diff: flink-streaming-java/src/test/java/org/apache/flink/streaming/runtime/tasks/StreamTaskTest.java
---
    @@ -806,6 +811,44 @@ public void testOperatorClosingBeforeStopRunning() throws Throwable
{
     		}
     	}
     
    +	/**
    +	 * Test set user code ClassLoader before calling ProcessingTimeCallback.
    +	 */
    +	@Test
    +	public void testSetsUserCodeClassLoaderForTimerThreadFactory() throws Throwable {
    +		syncLatch = new OneShotLatch();
    +
    +		try (MockEnvironment mockEnvironment =
    +			new MockEnvironmentBuilder()
    +				.setUserCodeClassLoader(new TestUserCodeClassLoader())
    +				.build()) {
    +			TimeServiceTask timerServiceTask = new TimeServiceTask(mockEnvironment);
    +
    +			final AtomicReference<Throwable> atomicThrowable = new AtomicReference<>(null);
    +
    +			CompletableFuture<Void> invokeFuture = CompletableFuture.runAsync(
    +				() -> {
    +					try {
    +						timerServiceTask.invoke();
    +					} catch (Exception e) {
    +						atomicThrowable.set(e);
    +					}
    +				},
    +				TestingUtils.defaultExecutor());
    +
    +			// wait until the invoke is complete
    +			invokeFuture.get();
    +
    +			assertThat(timerServiceTask.getClassLoaders(), hasSize(greaterThanOrEqualTo(1)));
    +			assertThat(timerServiceTask.getClassLoaders(), everyItem(instanceOf(TestUserCodeClassLoader.class)));
    +
    +			// check if an exception occurred
    --- End diff --
    
    hold on, will fix it~


---

Mime
View raw message