-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix exception wrapping for member/client comm (#17203)
* Fix exception wrapping for member/client comm Exceptions that comes from remote are wrapped to HazelcastEx if they are not RuntimeExceptions. That prevents clients to act accordingly to exceptions. With this pr, we are removing the wrapping. fixes #17022 * Changed RuntimeExceptionFactory to ExceptionWrapper * simplify test
- Loading branch information
sancar
committed
Jul 14, 2020
1 parent
2767be4
commit 67f9456
Showing
5 changed files
with
121 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
71 changes: 71 additions & 0 deletions
71
...lient/src/test/java/com/hazelcast/client/executor/ClientExecutorServiceExceptionTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
/* | ||
* Copyright (c) 2008-2020, Hazelcast, Inc. All Rights Reserved. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package com.hazelcast.client.executor; | ||
|
||
import com.hazelcast.client.config.ClientConfig; | ||
import com.hazelcast.client.test.TestHazelcastFactory; | ||
import com.hazelcast.core.HazelcastInstance; | ||
import com.hazelcast.core.IExecutorService; | ||
import com.hazelcast.spi.exception.RetryableIOException; | ||
import com.hazelcast.test.HazelcastParallelClassRunner; | ||
import com.hazelcast.test.annotation.ParallelTest; | ||
import com.hazelcast.test.annotation.QuickTest; | ||
import org.junit.After; | ||
import org.junit.Test; | ||
import org.junit.experimental.categories.Category; | ||
import org.junit.runner.RunWith; | ||
|
||
import java.io.Serializable; | ||
import java.util.concurrent.Callable; | ||
import java.util.concurrent.atomic.AtomicInteger; | ||
|
||
import static org.junit.Assert.assertEquals; | ||
|
||
@RunWith(HazelcastParallelClassRunner.class) | ||
@Category({QuickTest.class, ParallelTest.class}) | ||
public class ClientExecutorServiceExceptionTest { | ||
|
||
private final TestHazelcastFactory hazelcastFactory = new TestHazelcastFactory(); | ||
|
||
@After | ||
public void tearDown() { | ||
hazelcastFactory.terminateAll(); | ||
} | ||
|
||
public static class SecondTimeSuccessCallable implements Serializable, Callable { | ||
private static AtomicInteger runCount = new AtomicInteger(); | ||
|
||
@Override | ||
public Object call() throws Exception { | ||
if (runCount.incrementAndGet() == 1) { | ||
throw new RetryableIOException(); | ||
} | ||
return "SUCCESS"; | ||
} | ||
} | ||
|
||
@Test | ||
public void testRetriableIOException() throws Throwable { | ||
hazelcastFactory.newHazelcastInstance(); | ||
ClientConfig clientConfig = new ClientConfig(); | ||
clientConfig.getNetworkConfig().setSmartRouting(false); | ||
HazelcastInstance client = hazelcastFactory.newHazelcastClient(clientConfig); | ||
IExecutorService executorService = client.getExecutorService("test"); | ||
|
||
assertEquals("SUCCESS", executorService.submit(new SecondTimeSuccessCallable()).get()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters