[ https://issues.apache.org/jira/browse/IGNITE-5994?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Alexander Menshikov updated IGNITE-5994: ---------------------------------------- Docs Text: (was: /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You 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 org.apache.ignite.internal.processors.cache; import javax.cache.CacheException; import javax.cache.processor.EntryProcessor; import javax.cache.processor.EntryProcessorException; import javax.cache.processor.EntryProcessorResult; import javax.cache.processor.MutableEntry; import org.apache.ignite.Ignite; import org.apache.ignite.IgniteCache; import org.apache.ignite.IgniteException; import org.apache.ignite.cache.CacheAtomicityMode; import org.apache.ignite.cluster.ClusterNode; import org.apache.ignite.configuration.CacheConfiguration; import org.apache.ignite.configuration.IgniteConfiguration; import org.apache.ignite.configuration.TransactionConfiguration; import org.apache.ignite.internal.IgniteInterruptedCheckedException; import org.apache.ignite.internal.IgniteKernal; import org.apache.ignite.internal.managers.communication.GridIoMessage; import org.apache.ignite.internal.processors.cache.distributed.near.GridNearTxLocal; import org.apache.ignite.internal.processors.cache.distributed.near.GridNearTxPrepareRequest; import org.apache.ignite.internal.util.typedef.internal.CU; import org.apache.ignite.internal.util.typedef.internal.U; import org.apache.ignite.lang.IgniteInClosure; import org.apache.ignite.plugin.extensions.communication.Message; import org.apache.ignite.spi.IgniteSpiException; import org.apache.ignite.spi.communication.tcp.TcpCommunicationSpi; import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; import org.apache.ignite.transactions.Transaction; import org.apache.ignite.transactions.TransactionTimeoutException; import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL; import static org.apache.ignite.transactions.TransactionConcurrency.PESSIMISTIC; import static org.apache.ignite.transactions.TransactionIsolation.READ_COMMITTED; /** * Test checks that grid transaction configuration doesn't influence system caches. */ public class IgniteCacheSelfTest extends GridCommonAbstractTest { /** Ip finder. */ private static final TcpDiscoveryIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true); /** Test cache name. */ private static final String CACHE_NAME = "cache_name"; /** Timeout of transaction. */ private static final long TX_TIMEOUT = 100; /** {@inheritDoc} */ @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName); ((TcpDiscoverySpi)cfg.getDiscoverySpi()).setIpFinder(IP_FINDER); CacheConfiguration ccfg = new CacheConfiguration(CACHE_NAME); ccfg.setAtomicityMode(atomicityMode()); ccfg.setBackups(1); cfg.setCacheConfiguration(ccfg); final TransactionConfiguration txCfg = new TransactionConfiguration(); txCfg.setDefaultTxTimeout(TX_TIMEOUT); cfg.setTransactionConfiguration(txCfg); return cfg; } /** * @return Cache atomicity mode. */ public CacheAtomicityMode atomicityMode() { return TRANSACTIONAL; } /** {@inheritDoc} */ @Override protected void beforeTestsStarted() throws Exception { startGrids(2); } /** {@inheritDoc} */ @Override protected void afterTestsStopped() throws Exception { stopAllGrids(); } /** * @throws Exception If failed. */ public void testSystemCacheInvoke() throws Exception { final Ignite ignite = grid(0); final IgniteInternalCache<Object, Object> utilCache = getSystemCache(ignite, CU.UTILITY_CACHE_NAME); utilCache.put("test", ""); final EntryProcessor<Object, Object, Object> ep = new EntryProcessor<Object, Object, Object>() { @Override public Object process(MutableEntry<Object, Object> entry, Object... objects) throws EntryProcessorException { return null; } }; EntryProcessorResult<Object> result = utilCache.invoke("test", ep); assertNotNull(result); assertNull(result.get()); result = utilCache.invokeAsync("test", ep).get(); assertNotNull(result); assertNull(result.get()); } /** * Extract system cache from kernal. * * @param ignite Ignite instance. * @param cacheName System cache name. * @return Internal cache instance. */ protected IgniteInternalCache<Object, Object> getSystemCache(final Ignite ignite, final String cacheName) { return ((IgniteKernal) ignite).context().cache().cache(cacheName); } } ) > IgniteInternalCache.invokeAsync().get() can return null > ------------------------------------------------------- > > Key: IGNITE-5994 > URL: https://issues.apache.org/jira/browse/IGNITE-5994 > Project: Ignite > Issue Type: Bug > Reporter: Alexander Menshikov > > The IgniteInternalCache.invoke() always return an EntryProcessorResult, but > the IgniteInternalCache.invokeAsync().get() can return the null in case when > an EntryProcessor has returned the null. > Code from reproducer: > ```Java > final EntryProcessor<Object, Object, Object> ep = new EntryProcessor<Object, > Object, Object>() { > @Override > public Object process(MutableEntry<Object, Object> entry, > Object... objects) throws EntryProcessorException { > return null; > } > }; > EntryProcessorResult<Object> result = utilCache.invoke("test", ep); > assertNotNull(result); > assertNull(result.get()); > result = utilCache.invokeAsync("test", ep).get(); > // Assert here!!! > assertNotNull(result); > assertNull(result.get()); > ``` > It can be optimization. Nevertheless results of invoke() must be equals with > results of invokeAsync().get(). So there are two options: > 1) To do so would be the invokeAsync(key, ep).get() returned the null too for > the optimization. > 2) Or to do so would be the invoke(key, ep) returned an EntryProcessorResult > for a logical consistency. > NOTE: Don't confuse with IgniteCache.invoke. -- This message was sent by Atlassian JIRA (v6.4.14#64029)