Skip to content

Commit

Permalink
IGNITE-8926 : Fixed handling of invoke result.
Browse files Browse the repository at this point in the history
  • Loading branch information
ilantukh authored and mcherkasov committed Aug 9, 2018
1 parent a5db25c commit a047465
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@
import javax.cache.processor.EntryProcessorException;
import javax.cache.processor.EntryProcessorResult;
import javax.cache.processor.MutableEntry;
import org.apache.ignite.IgniteException;
import org.apache.ignite.internal.UnregisteredBinaryTypeException;
import org.apache.ignite.internal.UnregisteredClassException;
import org.apache.ignite.internal.util.tostring.GridToStringInclude;
import org.apache.ignite.internal.util.typedef.internal.S;

Expand Down Expand Up @@ -96,6 +99,9 @@ public static <T> CacheInvokeResult<T> fromError(Exception err) {
/** {@inheritDoc} */
@Override public T get() throws EntryProcessorException {
if (err != null) {
if (err instanceof UnregisteredClassException || err instanceof UnregisteredBinaryTypeException)
throw (IgniteException) err;

if (err instanceof EntryProcessorException)
throw (EntryProcessorException)err;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@
import org.apache.ignite.IgniteLogger;
import org.apache.ignite.cache.eviction.EvictableEntry;
import org.apache.ignite.internal.NodeStoppingException;
import org.apache.ignite.internal.UnregisteredBinaryTypeException;
import org.apache.ignite.internal.UnregisteredClassException;
import org.apache.ignite.internal.pagemem.wal.StorageException;
import org.apache.ignite.internal.pagemem.wal.WALPointer;
import org.apache.ignite.internal.pagemem.wal.record.DataEntry;
Expand Down Expand Up @@ -5422,6 +5424,9 @@ private IgniteBiTuple<Object, Exception> runEntryProcessor(CacheInvokeEntry<Obje
return null;
}
catch (Exception e) {
if (e instanceof UnregisteredClassException || e instanceof UnregisteredBinaryTypeException)
throw (IgniteException) e;

writeObj = invokeEntry.valObj;

return new IgniteBiTuple<>(null, e);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
/**
*
*/
public class BinaryMetadataRegistrationInsideEntryProcessorTest extends GridCommonAbstractTest{
public class BinaryMetadataRegistrationInsideEntryProcessorTest extends GridCommonAbstractTest {
/** */
private static final String CACHE_NAME = "test-cache";

Expand All @@ -51,15 +51,16 @@ public class BinaryMetadataRegistrationInsideEntryProcessorTest extends GridComm
* @throws Exception If failed;
*/
public void test() throws Exception {
Ignite ignite = startGrid();
Ignite ignite = startGrids(2);

IgniteCache<String, Map<Integer, CustomObj>> cache = ignite.createCache(CACHE_NAME);
IgniteCache<Integer, Map<Integer, CustomObj>> cache = ignite.createCache(CACHE_NAME);

try {
cache.invoke("1", new CustomProcessor(), null);
for (int i = 0; i < 10_000; i++)
cache.invoke(i, new CustomProcessor());
}
catch (Exception e) {
Map<Integer, CustomObj> value = cache.get("1");
Map<Integer, CustomObj> value = cache.get(1);

if ((value != null) && (value.get(1) != null) && (value.get(1).getObj() == CustomEnum.ONE))
System.out.println("Data was saved.");
Expand All @@ -73,11 +74,11 @@ public void test() throws Exception {
/**
*
*/
private static class CustomProcessor implements EntryProcessor<String,
private static class CustomProcessor implements EntryProcessor<Integer,
Map<Integer, CustomObj>, Object> {
/** {@inheritDoc} */
@Override public Object process(
MutableEntry<String, Map<Integer, CustomObj>> entry,
MutableEntry<Integer, Map<Integer, CustomObj>> entry,
Object... objects) throws EntryProcessorException {
Map<Integer, CustomObj> map = new HashMap<>();

Expand Down Expand Up @@ -137,4 +138,4 @@ private enum CustomEnum {
}
}

}
}

0 comments on commit a047465

Please sign in to comment.