qpid-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From lqu...@apache.org
Subject svn commit: r1753191 [2/2] - in /qpid/java/trunk: broker-core/src/main/java/org/apache/qpid/server/configuration/updater/ broker-core/src/main/java/org/apache/qpid/server/model/ broker-core/src/main/java/org/apache/qpid/server/model/adapter/ broker-cor...
Date Mon, 18 Jul 2016 10:02:26 GMT
Modified: qpid/java/trunk/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/servlet/rest/RestServlet.java
URL: http://svn.apache.org/viewvc/qpid/java/trunk/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/servlet/rest/RestServlet.java?rev=1753191&r1=1753190&r2=1753191&view=diff
==============================================================================
--- qpid/java/trunk/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/servlet/rest/RestServlet.java
(original)
+++ qpid/java/trunk/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/servlet/rest/RestServlet.java
Mon Jul 18 10:02:25 2016
@@ -16,6 +16,8 @@
  */
 package org.apache.qpid.server.management.plugin.servlet.rest;
 
+import static org.apache.qpid.server.management.plugin.HttpManagementConfiguration.DEFAULT_PREFERENCE_OPERTAION_TIMEOUT;
+import static org.apache.qpid.server.management.plugin.HttpManagementConfiguration.PREFERENCE_OPERTAION_TIMEOUT_CONTEXT_NAME;
 import static org.apache.qpid.server.management.plugin.HttpManagementUtil.ensureFilenameIsRfc2183;
 
 import java.io.IOException;
@@ -58,6 +60,7 @@ import org.apache.qpid.server.model.Cont
 import org.apache.qpid.server.model.IllegalStateTransitionException;
 import org.apache.qpid.server.model.IntegrityViolationException;
 import org.apache.qpid.server.model.Model;
+import org.apache.qpid.server.model.OperationTimeoutException;
 import org.apache.qpid.server.model.preferences.UserPreferences;
 import org.apache.qpid.server.util.ServerScopedRuntimeException;
 import org.apache.qpid.server.util.urlstreamhandler.data.Handler;
@@ -103,6 +106,7 @@ public class RestServlet extends Abstrac
     private final ConfiguredObjectToMapConverter _objectConverter = new ConfiguredObjectToMapConverter();
     private final boolean _hierarchyInitializationRequired;
     private volatile RequestInfoParser _requestInfoParser;
+    private RestUserPreferenceHandler _userPreferenceHandler;
 
     @SuppressWarnings("unused")
     public RestServlet()
@@ -128,6 +132,10 @@ public class RestServlet extends Abstrac
         }
         _requestInfoParser = new RequestInfoParser(_hierarchy);
         Handler.register();
+        Long preferenceOperationTimeout = getManagementConfiguration().getContextValue(Long.class,
PREFERENCE_OPERTAION_TIMEOUT_CONTEXT_NAME);
+        _userPreferenceHandler = new RestUserPreferenceHandler(preferenceOperationTimeout
== null
+                                                                       ? DEFAULT_PREFERENCE_OPERTAION_TIMEOUT
+                                                                       : preferenceOperationTimeout);
     }
 
     @SuppressWarnings("unchecked")
@@ -662,7 +670,7 @@ public class RestServlet extends Abstrac
                 final UserPreferences userPreferences = target.getUserPreferences();
                 try
                 {
-                    final Object preferences = new RestUserPreferenceHandler().handleGET(userPreferences,
requestInfo);
+                    final Object preferences = _userPreferenceHandler.handleGET(userPreferences,
requestInfo);
                     if (preferences == null || (preferences instanceof Collection
                                                 && ((Collection) preferences).isEmpty())
|| (preferences instanceof Map
                                                                                         
    && ((Map) preferences).isEmpty()))
@@ -683,7 +691,7 @@ public class RestServlet extends Abstrac
             ConfiguredObject<?> target = allObjects.iterator().next();
             final UserPreferences userPreferences = target.getUserPreferences();
 
-            responseObject = new RestUserPreferenceHandler().handleGET(userPreferences, requestInfo);
+            responseObject = _userPreferenceHandler.handleGET(userPreferences, requestInfo);
         }
         sendJsonResponse(responseObject, request, response);
     }
@@ -694,19 +702,16 @@ public class RestServlet extends Abstrac
     {
         ConfiguredObject<?> target = getTarget(requestInfo);
 
-        final UserPreferences userPreferences = target.getUserPreferences();
-        final RestUserPreferenceHandler restUserPreferenceHandler = new RestUserPreferenceHandler();
-
         if ("POST".equals(request.getMethod()))
         {
             Object providedObject = getRequestProvidedObject(request, requestInfo, Object.class);
-            restUserPreferenceHandler.handlePOST(target, requestInfo, providedObject);
+            _userPreferenceHandler.handlePOST(target, requestInfo, providedObject);
         }
         else if ("PUT".equals(request.getMethod()))
         {
             Map<String, Object> providedObject = getRequestProvidedObject(request,
requestInfo);
             final RestUserPreferenceHandler.ActionTaken actionTaken =
-                    restUserPreferenceHandler.handlePUT(target, requestInfo, providedObject);
+                    _userPreferenceHandler.handlePUT(target, requestInfo, providedObject);
 
             switch(actionTaken)
             {
@@ -1135,6 +1140,20 @@ public class RestServlet extends Abstrac
                 }
                 responseCode = SC_UNPROCESSABLE_ENTITY;
             }
+            else if (e instanceof OperationTimeoutException)
+            {
+                message = "Timeout occurred";
+                if (LOGGER.isDebugEnabled())
+                {
+                    LOGGER.debug(message, e);
+                }
+                else
+                {
+                    LOGGER.info(e.getMessage());
+                }
+
+                responseCode = HttpServletResponse.SC_BAD_GATEWAY;
+            }
             else if (e instanceof NoClassDefFoundError)
             {
                 message = "Not found: " + message;
@@ -1197,7 +1216,7 @@ public class RestServlet extends Abstrac
                 }
                 for (ConfiguredObject o : allObjects)
                 {
-                    new RestUserPreferenceHandler().handleDELETE(o.getUserPreferences(),
requestInfo);
+                    _userPreferenceHandler.handleDELETE(o.getUserPreferences(), requestInfo);
                 }
                 break;
             }

Modified: qpid/java/trunk/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/servlet/rest/RestUserPreferenceHandler.java
URL: http://svn.apache.org/viewvc/qpid/java/trunk/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/servlet/rest/RestUserPreferenceHandler.java?rev=1753191&r1=1753190&r2=1753191&view=diff
==============================================================================
--- qpid/java/trunk/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/servlet/rest/RestUserPreferenceHandler.java
(original)
+++ qpid/java/trunk/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/servlet/rest/RestUserPreferenceHandler.java
Mon Jul 18 10:02:25 2016
@@ -26,16 +26,20 @@ import java.util.Collection;
 import java.util.Collections;
 import java.util.HashMap;
 import java.util.HashSet;
+import java.util.LinkedHashSet;
 import java.util.List;
 import java.util.Map;
 import java.util.Objects;
 import java.util.Set;
 import java.util.UUID;
+import java.util.concurrent.TimeUnit;
 
 import javax.security.auth.Subject;
 
 import com.google.common.base.Joiner;
+import com.google.common.util.concurrent.ListenableFuture;
 
+import org.apache.qpid.server.util.FutureHelper;
 import org.apache.qpid.server.model.ConfiguredObject;
 import org.apache.qpid.server.model.preferences.Preference;
 import org.apache.qpid.server.model.preferences.PreferenceFactory;
@@ -43,6 +47,13 @@ import org.apache.qpid.server.model.pref
 
 public class RestUserPreferenceHandler
 {
+    private final long _preferenceOperationTimeout;
+
+    public RestUserPreferenceHandler(final long preferenceOperationTimeout)
+    {
+        _preferenceOperationTimeout = preferenceOperationTimeout;
+    }
+
     public void handleDELETE(final UserPreferences userPreferences, final RequestInfo requestInfo)
     {
         if (userPreferences == null)
@@ -52,56 +63,30 @@ public class RestUserPreferenceHandler
 
         final List<String> preferencesParts = requestInfo.getPreferencesParts();
         final Map<String, List<String>> queryParameters = requestInfo.getQueryParameters();
-        String id = getIdFromQueryParameters(queryParameters);
-
-        if (id != null)
-        {
-            final Set<Preference> allPreferences = userPreferences.getPreferences();
-            for (Preference preference : allPreferences)
-            {
-                if (id.equals(preference.getId().toString()))
-                {
-                    String type = null;
-                    String name = null;
-                    if (preferencesParts.size() == 2)
-                    {
-                        type = preferencesParts.get(0);
-                        name = preferencesParts.get(1);
-                    }
-                    else if (preferencesParts.size() == 1)
-                    {
-                        type = preferencesParts.get(0);
-                    }
-                    if ((type == null || type.equals(preference.getType()))
-                        && (name == null || name.equals(preference.getName())))
-                    {
-                        userPreferences.replaceByTypeAndName(preference.getType(), preference.getName(),
null);
-                    }
-                    return;
-                }
-            }
-        }
+        UUID id = getIdFromQueryParameters(queryParameters);
 
+        String type = null;
+        String name = null;
         if (preferencesParts.size() == 2)
         {
-            String type = preferencesParts.get(0);
-            String name = preferencesParts.get(1);
-            userPreferences.replaceByTypeAndName(type, name, null);
+            type = preferencesParts.get(0);
+            name = preferencesParts.get(1);
         }
         else if (preferencesParts.size() == 1)
         {
-            String type = preferencesParts.get(0);
-            userPreferences.replaceByType(type, Collections.<Preference>emptySet());
+            type = preferencesParts.get(0);
         }
         else if (preferencesParts.size() == 0)
         {
-            userPreferences.replace(Collections.<Preference>emptySet());
+            // pass
         }
         else
         {
             throw new IllegalArgumentException(String.format("unexpected path '%s'",
                                                              Joiner.on("/").join(preferencesParts)));
         }
+
+        awaitFuture(userPreferences.delete(type, name, id));
     }
 
     ActionTaken handlePUT(ConfiguredObject<?> target, RequestInfo requestInfo, Object
providedObject)
@@ -134,7 +119,7 @@ public class RestUserPreferenceHandler
 
             ensureValidVisibilityList(preference.getVisibilityList());
 
-            userPreferences.updateOrAppend(Collections.singleton(preference));
+            awaitFuture(userPreferences.updateOrAppend(Collections.singleton(preference)));
 
             return providedUuid == null ? ActionTaken.CREATED : ActionTaken.UPDATED;
         }
@@ -154,6 +139,7 @@ public class RestUserPreferenceHandler
         }
 
         final List<String> preferencesParts = requestInfo.getPreferencesParts();
+        final Set<Preference> preferences = new LinkedHashSet<>();
 
         if (preferencesParts.size() == 1)
         {
@@ -164,7 +150,6 @@ public class RestUserPreferenceHandler
             }
             List<Object> providedObjects = (List<Object>) providedObject;
 
-            Set<Preference> preferences = new HashSet<>(providedObjects.size());
             for (Object preferenceObject : providedObjects)
             {
                 if (!(preferenceObject instanceof Map))
@@ -182,7 +167,6 @@ public class RestUserPreferenceHandler
                 preferences.add(preference);
             }
 
-            userPreferences.updateOrAppend(preferences);
         }
         else if (preferencesParts.size() == 0)
         {
@@ -192,7 +176,6 @@ public class RestUserPreferenceHandler
             }
             Map<String, Object> providedObjectMap = (Map<String, Object>) providedObject;
 
-            Set<Preference> preferences = new HashSet<>();
             for (String type : providedObjectMap.keySet())
             {
                 if (!(providedObjectMap.get(type) instanceof List))
@@ -220,14 +203,14 @@ public class RestUserPreferenceHandler
                     preferences.add(preference);
                 }
             }
-
-            userPreferences.updateOrAppend(preferences);
         }
         else
         {
             throw new IllegalArgumentException(String.format("unexpected path '%s'",
                                                              Joiner.on("/").join(preferencesParts)));
         }
+
+        awaitFuture(userPreferences.updateOrAppend(preferences));
     }
 
     Object handleGET(UserPreferences userPreferences, RequestInfo requestInfo)
@@ -239,22 +222,24 @@ public class RestUserPreferenceHandler
 
         final List<String> preferencesParts = requestInfo.getPreferencesParts();
         final Map<String, List<String>> queryParameters = requestInfo.getQueryParameters();
-        String id = getIdFromQueryParameters(queryParameters);
+        UUID id = getIdFromQueryParameters(queryParameters);
 
-        final Set<Preference> allPreferences;
+        final ListenableFuture<Set<Preference>> allPreferencesFuture;
         if (requestInfo.getType() == RequestInfo.RequestType.USER_PREFERENCES)
         {
-            allPreferences = userPreferences.getPreferences();
+            allPreferencesFuture = userPreferences.getPreferences();
         }
         else if (requestInfo.getType() == RequestInfo.RequestType.VISIBLE_PREFERENCES)
         {
-            allPreferences = userPreferences.getVisiblePreferences();
+            allPreferencesFuture = userPreferences.getVisiblePreferences();
         }
         else
         {
             throw new IllegalStateException(String.format(
                     "RestUserPreferenceHandler called with a unsupported request type: %s",
requestInfo.getType()));
         }
+        final Set<Preference> allPreferences;
+        allPreferences = awaitFuture(allPreferencesFuture);
 
         if (preferencesParts.size() == 2)
         {
@@ -267,7 +252,7 @@ public class RestUserPreferenceHandler
             {
                 if (preference.getType().equals(type) && preference.getName().equals(name))
                 {
-                    if (id == null || id.equals(preference.getId().toString()))
+                    if (id == null || id.equals(preference.getId()))
                     {
                         foundPreference = preference;
                     }
@@ -307,7 +292,7 @@ public class RestUserPreferenceHandler
             {
                 if (preference.getType().equals(type))
                 {
-                    if (id == null || id.equals(preference.getId().toString()))
+                    if (id == null || id.equals(preference.getId()))
                     {
                         preferences.add(preference.getAttributes());
                     }
@@ -321,7 +306,7 @@ public class RestUserPreferenceHandler
 
             for (Preference preference : allPreferences)
             {
-                if (id == null || id.equals(preference.getId().toString()))
+                if (id == null || id.equals(preference.getId()))
                 {
                     final String type = preference.getType();
                     if (!preferences.containsKey(type))
@@ -342,14 +327,19 @@ public class RestUserPreferenceHandler
         }
     }
 
-    private String getIdFromQueryParameters(final Map<String, List<String>> queryParameters)
+    private <T> T awaitFuture(final ListenableFuture<T> future)
+    {
+        return FutureHelper.<T, RuntimeException>await(future, _preferenceOperationTimeout,
TimeUnit.MILLISECONDS);
+    }
+
+    private UUID getIdFromQueryParameters(final Map<String, List<String>> queryParameters)
     {
         List<String> ids = queryParameters.get("id");
         if (ids != null && ids.size() > 1)
         {
             throw new IllegalArgumentException("Multiple ids in query string are not allowed");
         }
-        return (ids == null ? null : ids.get(0));
+        return (ids == null ? null : UUID.fromString(ids.get(0)));
     }
 
     private UUID getProvidedUuid(final Map<String, Object> providedObjectMap)

Modified: qpid/java/trunk/broker-plugins/management-http/src/test/java/org/apache/qpid/server/management/plugin/servlet/rest/RestUserPreferenceHandlerTest.java
URL: http://svn.apache.org/viewvc/qpid/java/trunk/broker-plugins/management-http/src/test/java/org/apache/qpid/server/management/plugin/servlet/rest/RestUserPreferenceHandlerTest.java?rev=1753191&r1=1753190&r2=1753191&view=diff
==============================================================================
--- qpid/java/trunk/broker-plugins/management-http/src/test/java/org/apache/qpid/server/management/plugin/servlet/rest/RestUserPreferenceHandlerTest.java
(original)
+++ qpid/java/trunk/broker-plugins/management-http/src/test/java/org/apache/qpid/server/management/plugin/servlet/rest/RestUserPreferenceHandlerTest.java
Mon Jul 18 10:02:25 2016
@@ -18,7 +18,9 @@
  */
 package org.apache.qpid.server.management.plugin.servlet.rest;
 
+import static org.apache.qpid.server.management.plugin.HttpManagementConfiguration.DEFAULT_PREFERENCE_OPERTAION_TIMEOUT;
 import static org.apache.qpid.server.management.plugin.servlet.rest.RestUserPreferenceHandler.ActionTaken;
+import static org.apache.qpid.server.model.preferences.PreferenceTestHelper.awaitPreferenceFuture;
 import static org.apache.qpid.server.model.preferences.PreferenceTestHelper.createPreferenceAttributes;
 import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.when;
@@ -38,6 +40,8 @@ import javax.security.auth.Subject;
 
 import com.google.common.collect.Sets;
 
+import org.apache.qpid.server.configuration.updater.CurrentThreadTaskExecutor;
+import org.apache.qpid.server.configuration.updater.TaskExecutor;
 import org.apache.qpid.server.model.ConfiguredObject;
 import org.apache.qpid.server.model.preferences.Preference;
 import org.apache.qpid.server.model.preferences.PreferenceFactory;
@@ -55,12 +59,13 @@ public class RestUserPreferenceHandlerTe
     private static final String MYGROUP = "mygroup";
     private static final String MYUSER = "myuser";
 
-    private RestUserPreferenceHandler _handler = new RestUserPreferenceHandler();
+    private RestUserPreferenceHandler _handler = new RestUserPreferenceHandler(DEFAULT_PREFERENCE_OPERTAION_TIMEOUT);
     private ConfiguredObject<?> _configuredObject;
     private UserPreferences _userPreferences;
     private Subject _subject;
     private GroupPrincipal _groupPrincipal;
     private PreferenceStore _preferenceStore;
+    private TaskExecutor _preferenceTaskExecutor;
 
     @Override
     public void setUp() throws Exception
@@ -68,8 +73,12 @@ public class RestUserPreferenceHandlerTe
         super.setUp();
         _configuredObject = mock(ConfiguredObject.class);
         _preferenceStore = mock(PreferenceStore.class);
-        _userPreferences =
-                new UserPreferencesImpl(_preferenceStore, Collections.<Preference>emptyList());
+        _preferenceTaskExecutor = new CurrentThreadTaskExecutor();
+        _preferenceTaskExecutor.start();
+        _userPreferences = new UserPreferencesImpl(_preferenceTaskExecutor,
+                                                   _configuredObject,
+                                                   _preferenceStore,
+                                                   Collections.<Preference>emptyList());
         _groupPrincipal = new GroupPrincipal(MYGROUP);
         _subject = new Subject(true,
                                Sets.newHashSet(new AuthenticatedPrincipal(MYUSER), _groupPrincipal),
@@ -78,6 +87,13 @@ public class RestUserPreferenceHandlerTe
         when(_configuredObject.getUserPreferences()).thenReturn(_userPreferences);
     }
 
+    @Override
+    public void tearDown() throws Exception
+    {
+        _preferenceTaskExecutor.stop();
+        super.tearDown();
+    }
+
     public void testPutWithVisibilityList_ValidGroup() throws Exception
     {
 
@@ -98,8 +114,9 @@ public class RestUserPreferenceHandlerTe
                                      _handler.handlePUT(_configuredObject, requestInfo, pref);
                              assertEquals(ActionTaken.CREATED, action);
 
-                             assertEquals("Unexpected number of preferences", 1, _userPreferences.getPreferences().size());
-                             Preference prefModel = _userPreferences.getPreferences().iterator().next();
+                             Set<Preference> preferences = awaitPreferenceFuture(_userPreferences.getPreferences());
+                             assertEquals("Unexpected number of preferences", 1, preferences.size());
+                             Preference prefModel = preferences.iterator().next();
                              final Set<Principal> visibilityList = prefModel.getVisibilityList();
                              assertEquals("Unexpected number of principals in visibility
list", 1, visibilityList.size());
                              Principal principal = visibilityList.iterator().next();
@@ -158,8 +175,9 @@ public class RestUserPreferenceHandlerTe
                          {
                              _handler.handlePOST(_configuredObject, typeRequestInfo, Collections.singletonList(pref));
 
-                             assertEquals("Unexpected number of preferences", 1, _userPreferences.getPreferences().size());
-                             Preference prefModel = _userPreferences.getPreferences().iterator().next();
+                             Set<Preference> preferences = awaitPreferenceFuture(_userPreferences.getPreferences());
+                             assertEquals("Unexpected number of preferences", 1, preferences.size());
+                             Preference prefModel = preferences.iterator().next();
                              final Set<Principal> visibilityList = prefModel.getVisibilityList();
                              assertEquals("Unexpected number of principals in visibility
list", 1, visibilityList.size());
                              Principal principal = visibilityList.iterator().next();
@@ -188,8 +206,9 @@ public class RestUserPreferenceHandlerTe
                                      Collections.singletonMap("X-testtype2", Collections.singletonList(pref));
                              _handler.handlePOST(_configuredObject, rootRequestInfo, payload);
 
-                             assertEquals("Unexpected number of preferences", 1, _userPreferences.getPreferences().size());
-                             Preference prefModel = _userPreferences.getPreferences().iterator().next();
+                             Set<Preference> preferences = awaitPreferenceFuture(_userPreferences.getPreferences());
+                             assertEquals("Unexpected number of preferences", 1, preferences.size());
+                             Preference prefModel = preferences.iterator().next();
                              final Set<Principal> visibilityList = prefModel.getVisibilityList();
                              assertEquals("Unexpected number of principals in visibility
list", 1, visibilityList.size());
                              Principal principal = visibilityList.iterator().next();
@@ -285,7 +304,7 @@ public class RestUserPreferenceHandlerTe
                                      Collections.singleton(_groupPrincipal.getName()),
                                      Collections.<String, Object>emptyMap());
                              Preference preference = PreferenceFactory.create(_configuredObject,
prefAttributes);
-                             _userPreferences.updateOrAppend(Collections.singleton(preference));
+                             awaitPreferenceFuture(_userPreferences.updateOrAppend(Collections.singleton(preference)));
 
                              Map<String, List<Map<String, Object>>> typeToPreferenceListMap
=
                                      (Map<String, List<Map<String, Object>>>)
_handler.handleGET(_userPreferences, rootRequestInfo);
@@ -332,7 +351,7 @@ public class RestUserPreferenceHandlerTe
                                      null,
                                      Collections.<String, Object>emptyMap());
                              Preference p2 = PreferenceFactory.create(_configuredObject,
pref2Attributes);
-                             _userPreferences.updateOrAppend(Arrays.asList(p1, p2));
+                             awaitPreferenceFuture(_userPreferences.updateOrAppend(Arrays.asList(p1,
p2)));
                              UUID id = p1.getId();
 
                              final RequestInfo rootRequestInfo =
@@ -384,7 +403,7 @@ public class RestUserPreferenceHandlerTe
                                      null,
                                      Collections.<String, Object>emptyMap());
                              Preference p2 = PreferenceFactory.create(_configuredObject,
pref2Attributes);
-                             _userPreferences.updateOrAppend(Arrays.asList(p1, p2));
+                             awaitPreferenceFuture(_userPreferences.updateOrAppend(Arrays.asList(p1,
p2)));
                              UUID id = p1.getId();
 
                              final RequestInfo rootRequestInfo =
@@ -395,7 +414,7 @@ public class RestUserPreferenceHandlerTe
 
                              _handler.handleDELETE(_userPreferences, rootRequestInfo);
 
-                             final Set<Preference> retrievedPreferences = _userPreferences.getPreferences();
+                             final Set<Preference> retrievedPreferences = awaitPreferenceFuture(_userPreferences.getPreferences());
                              assertEquals("Unexpected number of preferences", 1, retrievedPreferences.size());
                              assertTrue("Unexpected type in p1 map", retrievedPreferences.contains(p2));
                              return null;
@@ -481,7 +500,7 @@ public class RestUserPreferenceHandlerTe
                                      Collections.<String, Object>emptyMap());
                              Preference p2 = PreferenceFactory.create(_configuredObject,
pref2Attributes);
                              preferences.add(p2);
-                             _userPreferences.updateOrAppend(preferences);
+                             awaitPreferenceFuture(_userPreferences.updateOrAppend(preferences));
                              return null;
                          }
                      }
@@ -551,7 +570,7 @@ public class RestUserPreferenceHandlerTe
                                      Collections.<String, Object>emptyMap());
                              Preference p2 = PreferenceFactory.create(_configuredObject,
pref2Attributes);
                              preferences.add(p2);
-                             _userPreferences.updateOrAppend(preferences);
+                             awaitPreferenceFuture(_userPreferences.updateOrAppend(preferences));
                              return null;
                          }
                      }
@@ -616,7 +635,7 @@ public class RestUserPreferenceHandlerTe
                                      Collections.<String, Object>emptyMap());
                              Preference p2 = PreferenceFactory.create(_configuredObject,
pref2Attributes);
                              preferences.add(p2);
-                             _userPreferences.updateOrAppend(preferences);
+                             awaitPreferenceFuture(_userPreferences.updateOrAppend(preferences));
                              return null;
                          }
                      }
@@ -659,13 +678,13 @@ public class RestUserPreferenceHandlerTe
                                      Collections.<String, Object>emptyMap());
                              Preference preference = PreferenceFactory.create(_configuredObject,
                                                                               preferenceAttributes);
-                             _userPreferences.updateOrAppend(Collections.singleton(preference));
-                             Set<Preference> retrievedPreferences = _userPreferences.getPreferences();
+                             awaitPreferenceFuture(_userPreferences.updateOrAppend(Collections.singleton(preference)));
+                             Set<Preference> retrievedPreferences = awaitPreferenceFuture(_userPreferences.getPreferences());
                              assertEquals("adding pref failed", 1, retrievedPreferences.size());
 
                              _handler.handleDELETE(_userPreferences, requestInfo);
 
-                             retrievedPreferences = _userPreferences.getPreferences();
+                             retrievedPreferences = awaitPreferenceFuture(_userPreferences.getPreferences());
                              assertEquals("Deletion of preference failed", 0, retrievedPreferences.size());
 
                              // this should be a noop



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org


Mime
View raw message