[infinispan-issues] [JBoss JIRA] (ISPN-2187) Pre-Invocation flag PUT_FOR_EXTERNAL_READ throws exception

Anna Manukyan (JIRA) jira-events at lists.jboss.org
Wed Aug 8 11:33:14 EDT 2012


Anna Manukyan created ISPN-2187:
-----------------------------------

             Summary: Pre-Invocation flag PUT_FOR_EXTERNAL_READ throws exception
                 Key: ISPN-2187
                 URL: https://issues.jboss.org/browse/ISPN-2187
             Project: Infinispan
          Issue Type: Bug
          Components: Core API
            Reporter: Anna Manukyan
            Assignee: Manik Surtani


Hi,

While writing tests for Infinispan Flag.PUT_FOR_EXTERNAL_READ the following issue has been found.

In documentation it is said: 

 PUT_FOR_EXTERNAL_READ 
          Flags the invocation as a Cache.putForExternalRead(Object, Object) call, as opposed to a regular Map.put(Object, Object).

And the documentation for Cache.putForExternalRead(Object, Object) says:

void putForExternalRead(K key,
                        V value)
...................
 Errors and exceptions are 'silent' - logged at a much lower level than normal, and this method does not throw exceptions

The issue is the following:

when trying to perform operation using PUT_FOR_EXTERNAL_READ flag, the exception is thrown, it is not 'silent'.

cache1.getAdvancedCache().withFlags(Flag.PUT_FOR_EXTERNAL_READ).put(key, value);

The test is the following: 

public void testExceptionSuppression() throws Exception {
      Cache cache1 = cache(0, "replSync");
      Cache cache2 = cache(1, "replSync");
      Transport mockTransport = mock(Transport.class);
      RpcManagerImpl rpcManager = (RpcManagerImpl) TestingUtil.extractComponent(cache1, RpcManager.class);
      Transport originalTransport = TestingUtil.extractComponent(cache1, Transport.class);
      try {

         Address mockAddress1 = mock(Address.class);
         Address mockAddress2 = mock(Address.class);

         List<Address> memberList = new ArrayList<Address>(2);
         memberList.add(mockAddress1);
         memberList.add(mockAddress2);

         rpcManager.setTransport(mockTransport);

         when(mockTransport.getMembers()).thenReturn(memberList);

         when(mockTransport.getViewId()).thenReturn(originalTransport.getViewId());

         when(mockTransport.invokeRemotely(anyAddresses(), (CacheRpcCommand) anyObject(), anyResponseMode(),
                                             anyLong(), anyBoolean(), (ResponseFilter) anyObject()))
               .thenThrow(new RuntimeException("Barf!"));

         try {
            cache1.put(key, value);
            fail("Should have barfed");
         }
         catch (RuntimeException re) {
         }

         // clean up any indeterminate state left over
         try {
            cache1.remove(key);
            fail("Should have barfed");
         }
         catch (RuntimeException re) {
         }

         assertNull("Should have cleaned up", cache1.get(key));

         // should not barf
         cache1.putForExternalRead(key, value);

         /** ------------------- Testing the same feature with Flag.PUT_FOR_EXTERNAL_READ **/
         try {
            cache1.remove(key);
            fail("Should have barfed");
         }
         catch (RuntimeException re) {
         }

         cache1.getAdvancedCache().withFlags(Flag.PUT_FOR_EXTERNAL_READ).put(key, value);
      }
      finally {
         if (rpcManager != null) rpcManager.setTransport(originalTransport);
      }
   }

Best regards,
Anna.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.jboss.org/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        


More information about the infinispan-issues mailing list