Uploaded image for project: 'Infinispan'
  1. Infinispan
  2. ISPN-2187

Pre-Invocation flag PUT_FOR_EXTERNAL_READ throws exception

    XMLWordPrintable

Details

    Description

      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.

      Attachments

        Issue Links

          Activity

            People

              rh-ee-galder Galder ZamarreƱo
              amanukya@redhat.com Anna Manukyan
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: