[Git][java-team/httpcomponents-client][master] 2 commits: Compiling sources depending on libspymemcached-java.
Andrius Merkys
gitlab at salsa.debian.org
Tue Nov 12 07:33:36 GMT 2019
Andrius Merkys pushed to branch master at Debian Java Maintainers / httpcomponents-client
Commits:
4aecb9bf by Andrius Merkys at 2019-11-12T07:32:05Z
Compiling sources depending on libspymemcached-java.
- - - - -
3815be5b by Andrius Merkys at 2019-11-12T07:33:17Z
Updating changelog.
- - - - -
5 changed files:
- debian/changelog
- debian/control
- debian/maven.ignoreRules
- − debian/patches/04-remove-MemcachedHttpCacheStorage.patch
- debian/patches/series
Changes:
=====================================
debian/changelog
=====================================
@@ -1,3 +1,10 @@
+httpcomponents-client (4.5.10-3) UNRELEASED; urgency=medium
+
+ * Team upload.
+ * Compiling sources depending on libspymemcached-java.
+
+ -- Andrius Merkys <merkys at debian.org> Tue, 12 Nov 2019 02:33:10 -0500
+
httpcomponents-client (4.5.10-2) unstable; urgency=medium
* Team upload.
=====================================
debian/control
=====================================
@@ -19,7 +19,8 @@ Build-Depends:
libmaven-bundle-plugin-java,
libmaven-javadoc-plugin-java,
libmockito-java,
- maven-debian-helper
+ maven-debian-helper,
+ libspymemcached-java
Standards-Version: 4.4.1
Vcs-Git: https://salsa.debian.org/java-team/httpcomponents-client.git
Vcs-Browser: https://salsa.debian.org/java-team/httpcomponents-client
=====================================
debian/maven.ignoreRules
=====================================
@@ -14,7 +14,6 @@
# from the POM
# junit junit jar s/3\..*/3.x/
-net.spy spymemcached
org.easymock easymockclassextension
org.apache.httpcomponents httpclient test-jar
* animal-sniffer-maven-plugin
=====================================
debian/patches/04-remove-MemcachedHttpCacheStorage.patch deleted
=====================================
@@ -1,917 +0,0 @@
-Description: Removing classes which depend on libspymemcached-java, as the
- former is not yet in Debian. Once libspymemcached-java clears through NEW,
- this patch should be removed.
-Author: Andrius Merkys <merkys at debian.org>
---- a/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/memcached/MemcachedHttpCacheStorage.java
-+++ /dev/null
-@@ -1,298 +0,0 @@
--/*
-- * ====================================================================
-- * 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.
-- * ====================================================================
-- *
-- * This software consists of voluntary contributions made by many
-- * individuals on behalf of the Apache Software Foundation. For more
-- * information on the Apache Software Foundation, please see
-- * <http://www.apache.org/>.
-- *
-- */
--package org.apache.http.impl.client.cache.memcached;
--
--import java.io.IOException;
--import java.net.InetSocketAddress;
--
--import net.spy.memcached.CASResponse;
--import net.spy.memcached.CASValue;
--import net.spy.memcached.MemcachedClient;
--import net.spy.memcached.MemcachedClientIF;
--import net.spy.memcached.OperationTimeoutException;
--
--import org.apache.commons.logging.Log;
--import org.apache.commons.logging.LogFactory;
--import org.apache.http.client.cache.HttpCacheEntry;
--import org.apache.http.client.cache.HttpCacheEntrySerializer;
--import org.apache.http.client.cache.HttpCacheStorage;
--import org.apache.http.client.cache.HttpCacheUpdateCallback;
--import org.apache.http.client.cache.HttpCacheUpdateException;
--import org.apache.http.impl.client.cache.CacheConfig;
--
--/**
-- * <p>
-- * This class is a storage backend that uses an external <i>memcached</i>
-- * for storing cached origin responses. This storage option provides a
-- * couple of interesting advantages over the default in-memory storage
-- * backend:
-- * </p>
-- * <ol>
-- * <li>in-memory cached objects can survive an application restart since
-- * they are held in a separate process</li>
-- * <li>it becomes possible for several cooperating applications to share
-- * a large <i>memcached</i> farm together</li>
-- * </ol>
-- * <p>
-- * Note that in a shared memcached pool setting you may wish to make use
-- * of the Ketama consistent hashing algorithm to reduce the number of
-- * cache misses that might result if one of the memcached cluster members
-- * fails (see the <a href="http://dustin.github.com/java-memcached-client/apidocs/net/spy/memcached/KetamaConnectionFactory.html">
-- * KetamaConnectionFactory</a>).
-- * </p>
-- * <p>
-- * Because memcached places limits on the size of its keys, we need to
-- * introduce a key hashing scheme to map the annotated URLs the higher-level
-- * caching HTTP client wants to use as keys onto ones that are suitable
-- * for use with memcached. Please see {@link KeyHashingScheme} if you would
-- * like to use something other than the provided {@link SHA256KeyHashingScheme}.
-- * </p>
-- *
-- * <p>
-- * Because this hashing scheme can potentially result in key collisions (though
-- * highly unlikely), we need to store the higher-level logical storage key along
-- * with the {@link HttpCacheEntry} so that we can re-check it on retrieval. There
-- * is a default serialization scheme provided for this, although you can provide
-- * your own implementations of {@link MemcachedCacheEntry} and
-- * {@link MemcachedCacheEntryFactory} to customize this serialization.
-- * </p>
-- *
-- * <p>
-- * Please refer to the <a href="http://code.google.com/p/memcached/wiki/NewStart">
-- * memcached documentation</a> and in particular to the documentation for
-- * the <a href="http://code.google.com/p/spymemcached/">spymemcached
-- * documentation</a> for details about how to set up and configure memcached
-- * and the Java client used here, respectively.
-- * </p>
-- *
-- * @since 4.1
-- */
--public class MemcachedHttpCacheStorage implements HttpCacheStorage {
--
-- private static final Log log = LogFactory.getLog(MemcachedHttpCacheStorage.class);
--
-- private final MemcachedClientIF client;
-- private final KeyHashingScheme keyHashingScheme;
-- private final MemcachedCacheEntryFactory memcachedCacheEntryFactory;
-- private final int maxUpdateRetries;
--
-- /**
-- * Create a storage backend talking to a <i>memcached</i> instance
-- * listening on the specified host and port. This is useful if you
-- * just have a single local memcached instance running on the same
-- * machine as your application, for example.
-- * @param address where the <i>memcached</i> daemon is running
-- * @throws IOException in case of an error
-- */
-- public MemcachedHttpCacheStorage(final InetSocketAddress address) throws IOException {
-- this(new MemcachedClient(address));
-- }
--
-- /**
-- * Create a storage backend using the pre-configured given
-- * <i>memcached</i> client.
-- * @param cache client to use for communicating with <i>memcached</i>
-- */
-- public MemcachedHttpCacheStorage(final MemcachedClientIF cache) {
-- this(cache, CacheConfig.DEFAULT, new MemcachedCacheEntryFactoryImpl(),
-- new SHA256KeyHashingScheme());
-- }
--
-- /**
-- * Create a storage backend using the given <i>memcached</i> client and
-- * applying the given cache configuration and cache entry serialization
-- * mechanism. <b>Deprecation note:</b> In the process of fixing a bug
-- * based on the need to hash logical storage keys onto memcached cache
-- * keys, the serialization process was revamped. This constructor still
-- * works, but the serializer argument will be ignored and default
-- * implementations of the new framework will be used. You can still
-- * provide custom serialization by using the
-- * {@link #MemcachedHttpCacheStorage(MemcachedClientIF, CacheConfig,
-- * MemcachedCacheEntryFactory, KeyHashingScheme)} constructor.
-- * @param client how to talk to <i>memcached</i>
-- * @param config apply HTTP cache-related options
-- * @param serializer <b>ignored</b>
-- *
-- * @deprecated (4.2) do not use
-- */
-- @Deprecated
-- public MemcachedHttpCacheStorage(final MemcachedClientIF client, final CacheConfig config,
-- final HttpCacheEntrySerializer serializer) {
-- this(client, config, new MemcachedCacheEntryFactoryImpl(),
-- new SHA256KeyHashingScheme());
-- }
--
-- /**
-- * Create a storage backend using the given <i>memcached</i> client and
-- * applying the given cache configuration, serialization, and hashing
-- * mechanisms.
-- * @param client how to talk to <i>memcached</i>
-- * @param config apply HTTP cache-related options
-- * @param memcachedCacheEntryFactory Factory pattern used for obtaining
-- * instances of alternative cache entry serialization mechanisms
-- * @param keyHashingScheme how to map higher-level logical "storage keys"
-- * onto "cache keys" suitable for use with memcached
-- */
-- public MemcachedHttpCacheStorage(final MemcachedClientIF client, final CacheConfig config,
-- final MemcachedCacheEntryFactory memcachedCacheEntryFactory,
-- final KeyHashingScheme keyHashingScheme) {
-- this.client = client;
-- this.maxUpdateRetries = config.getMaxUpdateRetries();
-- this.memcachedCacheEntryFactory = memcachedCacheEntryFactory;
-- this.keyHashingScheme = keyHashingScheme;
-- }
--
-- @Override
-- public void putEntry(final String url, final HttpCacheEntry entry) throws IOException {
-- final byte[] bytes = serializeEntry(url, entry);
-- final String key = getCacheKey(url);
-- if (key == null) {
-- return;
-- }
-- try {
-- client.set(key, 0, bytes);
-- } catch (final OperationTimeoutException ex) {
-- throw new MemcachedOperationTimeoutException(ex);
-- }
-- }
--
-- private String getCacheKey(final String url) {
-- try {
-- return keyHashingScheme.hash(url);
-- } catch (final MemcachedKeyHashingException mkhe) {
-- return null;
-- }
-- }
--
-- private byte[] serializeEntry(final String url, final HttpCacheEntry hce) throws IOException {
-- final MemcachedCacheEntry mce = memcachedCacheEntryFactory.getMemcachedCacheEntry(url, hce);
-- try {
-- return mce.toByteArray();
-- } catch (final MemcachedSerializationException mse) {
-- final IOException ioe = new IOException();
-- ioe.initCause(mse);
-- throw ioe;
-- }
-- }
--
-- private byte[] convertToByteArray(final Object o) {
-- if (o == null) {
-- return null;
-- }
-- if (!(o instanceof byte[])) {
-- log.warn("got a non-bytearray back from memcached: " + o);
-- return null;
-- }
-- return (byte[])o;
-- }
--
-- private MemcachedCacheEntry reconstituteEntry(final Object o) {
-- final byte[] bytes = convertToByteArray(o);
-- if (bytes == null) {
-- return null;
-- }
-- final MemcachedCacheEntry mce = memcachedCacheEntryFactory.getUnsetCacheEntry();
-- try {
-- mce.set(bytes);
-- } catch (final MemcachedSerializationException mse) {
-- return null;
-- }
-- return mce;
-- }
--
-- @Override
-- public HttpCacheEntry getEntry(final String url) throws IOException {
-- final String key = getCacheKey(url);
-- if (key == null) {
-- return null;
-- }
-- try {
-- final MemcachedCacheEntry mce = reconstituteEntry(client.get(key));
-- if (mce == null || !url.equals(mce.getStorageKey())) {
-- return null;
-- }
-- return mce.getHttpCacheEntry();
-- } catch (final OperationTimeoutException ex) {
-- throw new MemcachedOperationTimeoutException(ex);
-- }
-- }
--
-- @Override
-- public void removeEntry(final String url) throws IOException {
-- final String key = getCacheKey(url);
-- if (key == null) {
-- return;
-- }
-- try {
-- client.delete(key);
-- } catch (final OperationTimeoutException ex) {
-- throw new MemcachedOperationTimeoutException(ex);
-- }
-- }
--
-- @Override
-- public void updateEntry(final String url, final HttpCacheUpdateCallback callback)
-- throws HttpCacheUpdateException, IOException {
-- int numRetries = 0;
-- final String key = getCacheKey(url);
-- if (key == null) {
-- throw new HttpCacheUpdateException("couldn't generate cache key");
-- }
-- do {
-- try {
-- final CASValue<Object> v = client.gets(key);
-- MemcachedCacheEntry mce = (v == null) ? null
-- : reconstituteEntry(v.getValue());
-- if (mce != null && (!url.equals(mce.getStorageKey()))) {
-- mce = null;
-- }
-- final HttpCacheEntry existingEntry = (mce == null) ? null
-- : mce.getHttpCacheEntry();
-- final HttpCacheEntry updatedEntry = callback.update(existingEntry);
--
-- if (existingEntry == null) {
-- putEntry(url, updatedEntry);
-- return;
--
-- } else {
-- final byte[] updatedBytes = serializeEntry(url, updatedEntry);
-- final CASResponse casResult = client.cas(key, v.getCas(),
-- updatedBytes);
-- if (casResult != CASResponse.OK) {
-- numRetries++;
-- } else {
-- return;
-- }
-- }
-- } catch (final OperationTimeoutException ex) {
-- throw new MemcachedOperationTimeoutException(ex);
-- }
-- } while (numRetries <= maxUpdateRetries);
--
-- throw new HttpCacheUpdateException("Failed to update");
-- }
--}
---- a/httpclient-cache/src/test/java/org/apache/http/impl/client/cache/memcached/TestMemcachedHttpCacheStorage.java
-+++ /dev/null
-@@ -1,609 +0,0 @@
--/*
-- * ====================================================================
-- * 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.
-- * ====================================================================
-- *
-- * This software consists of voluntary contributions made by many
-- * individuals on behalf of the Apache Software Foundation. For more
-- * information on the Apache Software Foundation, please see
-- * <http://www.apache.org/>.
-- *
-- */
--package org.apache.http.impl.client.cache.memcached;
--
--import static org.mockito.Mockito.doThrow;
--import static org.mockito.Mockito.mock;
--import static org.mockito.Mockito.times;
--import static org.mockito.Mockito.verify;
--import static org.mockito.Mockito.verifyNoMoreInteractions;
--import static org.mockito.Mockito.when;
--
--import java.io.IOException;
--import java.io.UnsupportedEncodingException;
--
--import junit.framework.TestCase;
--import net.spy.memcached.CASResponse;
--import net.spy.memcached.CASValue;
--import net.spy.memcached.MemcachedClientIF;
--import net.spy.memcached.OperationTimeoutException;
--
--import org.apache.http.client.cache.HttpCacheEntry;
--import org.apache.http.client.cache.HttpCacheUpdateCallback;
--import org.apache.http.client.cache.HttpCacheUpdateException;
--import org.apache.http.impl.client.cache.CacheConfig;
--import org.apache.http.impl.client.cache.HttpTestUtils;
--import org.junit.Before;
--import org.junit.Test;
--
--public class TestMemcachedHttpCacheStorage extends TestCase {
-- private MemcachedHttpCacheStorage impl;
-- private MemcachedClientIF mockMemcachedClient;
-- private KeyHashingScheme mockKeyHashingScheme;
-- private MemcachedCacheEntryFactory mockMemcachedCacheEntryFactory;
-- private MemcachedCacheEntry mockMemcachedCacheEntry;
-- private MemcachedCacheEntry mockMemcachedCacheEntry2;
-- private MemcachedCacheEntry mockMemcachedCacheEntry3;
-- private MemcachedCacheEntry mockMemcachedCacheEntry4;
--
-- @Override
-- @Before
-- public void setUp() throws Exception {
-- mockMemcachedClient = mock(MemcachedClientIF.class);
-- mockKeyHashingScheme = mock(KeyHashingScheme.class);
-- mockMemcachedCacheEntryFactory = mock(MemcachedCacheEntryFactory.class);
-- mockMemcachedCacheEntry = mock(MemcachedCacheEntry.class);
-- mockMemcachedCacheEntry2 = mock(MemcachedCacheEntry.class);
-- mockMemcachedCacheEntry3 = mock(MemcachedCacheEntry.class);
-- mockMemcachedCacheEntry4 = mock(MemcachedCacheEntry.class);
-- final CacheConfig config = CacheConfig.custom().setMaxUpdateRetries(1).build();
-- impl = new MemcachedHttpCacheStorage(mockMemcachedClient, config,
-- mockMemcachedCacheEntryFactory, mockKeyHashingScheme);
-- }
--
-- @Test
-- public void testSuccessfulCachePut() throws IOException {
-- final String url = "foo";
-- final String key = "key";
-- final HttpCacheEntry value = HttpTestUtils.makeCacheEntry();
-- final byte[] serialized = HttpTestUtils.getRandomBytes(128);
--
-- when(mockMemcachedCacheEntryFactory.getMemcachedCacheEntry(url, value))
-- .thenReturn(mockMemcachedCacheEntry);
-- when(mockMemcachedCacheEntry.toByteArray())
-- .thenReturn(serialized);
-- when(mockKeyHashingScheme.hash(url))
-- .thenReturn(key);
-- when(mockMemcachedClient.set(key, 0, serialized))
-- .thenReturn(null);
--
-- impl.putEntry(url, value);
-- verify(mockMemcachedCacheEntryFactory).getMemcachedCacheEntry(url, value);
-- verify(mockMemcachedCacheEntry).toByteArray();
-- verify(mockKeyHashingScheme).hash(url);
-- verify(mockMemcachedClient).set(key, 0, serialized);
-- }
--
-- @Test
-- public void testCachePutFailsSilentlyWhenWeCannotHashAKey() throws IOException {
-- final String url = "foo";
-- final HttpCacheEntry value = HttpTestUtils.makeCacheEntry();
-- final byte[] serialized = HttpTestUtils.getRandomBytes(128);
--
-- when(mockMemcachedCacheEntryFactory.getMemcachedCacheEntry(url, value))
-- .thenReturn(mockMemcachedCacheEntry);
-- when(mockMemcachedCacheEntry.toByteArray())
-- .thenReturn(serialized);
-- when(mockKeyHashingScheme.hash(url))
-- .thenThrow(new MemcachedKeyHashingException(new Exception()));
--
-- impl.putEntry(url, value);
--
-- verify(mockMemcachedCacheEntryFactory).getMemcachedCacheEntry(url, value);
-- verify(mockMemcachedCacheEntry).toByteArray();
-- verify(mockKeyHashingScheme).hash(url);
-- }
--
-- public void testThrowsIOExceptionWhenMemcachedPutTimesOut() {
-- final String url = "foo";
-- final String key = "key";
-- final HttpCacheEntry value = HttpTestUtils.makeCacheEntry();
-- final byte[] serialized = HttpTestUtils.getRandomBytes(128);
--
-- when(mockMemcachedCacheEntryFactory.getMemcachedCacheEntry(url, value))
-- .thenReturn(mockMemcachedCacheEntry);
-- when(mockMemcachedCacheEntry.toByteArray())
-- .thenReturn(serialized);
-- when(mockKeyHashingScheme.hash(url))
-- .thenReturn(key);
-- when(mockMemcachedClient.set(key, 0, serialized))
-- .thenThrow(new OperationTimeoutException("timed out"));
--
-- try {
-- impl.putEntry(url, value);
-- fail("should have thrown exception");
-- } catch (final IOException expected) {
-- }
--
-- verify(mockMemcachedCacheEntryFactory).getMemcachedCacheEntry(url, value);
-- verify(mockMemcachedCacheEntry).toByteArray();
-- verify(mockKeyHashingScheme).hash(url);
-- verify(mockMemcachedClient).set(key, 0, serialized);
-- }
--
-- @Test
-- public void testCachePutThrowsIOExceptionIfCannotSerializeEntry() {
-- final String url = "foo";
-- final String key = "key";
-- final HttpCacheEntry value = HttpTestUtils.makeCacheEntry();
--
-- when(mockMemcachedCacheEntryFactory.getMemcachedCacheEntry(url, value))
-- .thenReturn(mockMemcachedCacheEntry);
-- when(mockMemcachedCacheEntry.toByteArray())
-- .thenThrow(new MemcachedSerializationException(new Exception()));
--
-- try {
-- impl.putEntry(url, value);
-- fail("should have thrown exception");
-- } catch (final IOException expected) {
--
-- }
--
-- verify(mockMemcachedCacheEntryFactory).getMemcachedCacheEntry(url, value);
-- verify(mockMemcachedCacheEntry).toByteArray();
-- }
--
-- @Test
-- public void testSuccessfulCacheGet() throws UnsupportedEncodingException,
-- IOException {
-- final String url = "foo";
-- final String key = "key";
-- final byte[] serialized = HttpTestUtils.getRandomBytes(128);
-- final HttpCacheEntry cacheEntry = HttpTestUtils.makeCacheEntry();
--
-- when(mockKeyHashingScheme.hash(url)).thenReturn(key);
-- when(mockMemcachedClient.get(key)).thenReturn(serialized);
-- when(mockMemcachedCacheEntryFactory.getUnsetCacheEntry())
-- .thenReturn(mockMemcachedCacheEntry);
-- when(mockMemcachedCacheEntry.getStorageKey()).thenReturn(url);
-- when(mockMemcachedCacheEntry.getHttpCacheEntry()).thenReturn(cacheEntry);
--
-- final HttpCacheEntry resultingEntry = impl.getEntry(url);
--
-- verify(mockKeyHashingScheme).hash(url);
-- verify(mockMemcachedClient).get(key);
-- verify(mockMemcachedCacheEntryFactory).getUnsetCacheEntry();
-- verify(mockMemcachedCacheEntry).set(serialized);
-- verify(mockMemcachedCacheEntry).getStorageKey();
-- verify(mockMemcachedCacheEntry).getHttpCacheEntry();
--
-- assertSame(cacheEntry, resultingEntry);
-- }
--
-- @Test
-- public void testTreatsNoneByteArrayFromMemcachedAsCacheMiss() throws UnsupportedEncodingException,
-- IOException {
-- final String url = "foo";
-- final String key = "key";
--
-- when(mockKeyHashingScheme.hash(url)).thenReturn(key);
-- when(mockMemcachedClient.get(key)).thenReturn(new Object());
--
-- final HttpCacheEntry resultingEntry = impl.getEntry(url);
--
-- verify(mockKeyHashingScheme).hash(url);
-- verify(mockMemcachedClient).get(key);
--
-- assertNull(resultingEntry);
-- }
--
-- @Test
-- public void testTreatsNullFromMemcachedAsCacheMiss() throws UnsupportedEncodingException,
-- IOException {
-- final String url = "foo";
-- final String key = "key";
--
-- when(mockKeyHashingScheme.hash(url)).thenReturn(key);
-- when(mockMemcachedClient.get(key)).thenReturn(null);
--
-- final HttpCacheEntry resultingEntry = impl.getEntry(url);
--
-- verify(mockKeyHashingScheme).hash(url);
-- verify(mockMemcachedClient).get(key);
--
-- assertNull(resultingEntry);
-- }
--
-- @Test
-- public void testTreatsAsCacheMissIfCannotReconstituteEntry() throws UnsupportedEncodingException,
-- IOException {
-- final String url = "foo";
-- final String key = "key";
-- final byte[] serialized = HttpTestUtils.getRandomBytes(128);
--
-- when(mockKeyHashingScheme.hash(url)).thenReturn(key);
-- when(mockMemcachedClient.get(key)).thenReturn(serialized);
-- when(mockMemcachedCacheEntryFactory.getUnsetCacheEntry())
-- .thenReturn(mockMemcachedCacheEntry);
-- doThrow(new MemcachedSerializationException(new Exception())).when(mockMemcachedCacheEntry).set(serialized);
--
-- assertNull(impl.getEntry(url));
--
-- verify(mockKeyHashingScheme).hash(url);
-- verify(mockMemcachedClient).get(key);
-- verify(mockMemcachedCacheEntryFactory).getUnsetCacheEntry();
-- verify(mockMemcachedCacheEntry).set(serialized);
-- }
--
-- @Test
-- public void testTreatsAsCacheMissIfCantHashStorageKey() throws UnsupportedEncodingException,
-- IOException {
-- final String url = "foo";
--
-- when(mockKeyHashingScheme.hash(url)).thenThrow(new MemcachedKeyHashingException(new Exception()));
--
-- assertNull(impl.getEntry(url));
-- verify(mockKeyHashingScheme).hash(url);
-- }
--
-- @Test
-- public void testThrowsIOExceptionIfMemcachedTimesOutOnGet() {
-- final String url = "foo";
-- final String key = "key";
-- when(mockKeyHashingScheme.hash(url)).thenReturn(key);
-- when(mockMemcachedClient.get(key))
-- .thenThrow(new OperationTimeoutException(""));
--
-- try {
-- impl.getEntry(url);
-- fail("should have thrown exception");
-- } catch (final IOException expected) {
-- }
-- verify(mockKeyHashingScheme).hash(url);
-- verify(mockMemcachedClient).get(key);
-- }
--
-- @Test
-- public void testCacheRemove() throws IOException {
-- final String url = "foo";
-- final String key = "key";
-- when(mockKeyHashingScheme.hash(url)).thenReturn(key);
-- when(mockMemcachedClient.delete(key)).thenReturn(null);
--
-- impl.removeEntry(url);
--
-- verify(mockKeyHashingScheme).hash(url);
-- verify(mockMemcachedClient).delete(key);
-- }
--
-- @Test
-- public void testCacheRemoveHandlesKeyHashingFailure() throws IOException {
-- final String url = "foo";
-- when(mockKeyHashingScheme.hash(url)).thenReturn(null);
-- impl.removeEntry(url);
-- verify(mockKeyHashingScheme).hash(url);
-- }
--
-- @Test
-- public void testCacheRemoveThrowsIOExceptionOnMemcachedTimeout() {
-- final String url = "foo";
-- final String key = "key";
-- when(mockKeyHashingScheme.hash(url)).thenReturn(key);
-- when(mockMemcachedClient.delete(key))
-- .thenThrow(new OperationTimeoutException(""));
--
-- try {
-- impl.removeEntry(url);
-- fail("should have thrown exception");
-- } catch (final IOException expected) {
-- }
--
-- verify(mockKeyHashingScheme).hash(url);
-- verify(mockMemcachedClient).delete(key);
-- }
--
-- @Test
-- public void testCacheUpdateCanUpdateNullEntry() throws IOException,
-- HttpCacheUpdateException {
-- final String url = "foo";
-- final String key = "key";
-- final HttpCacheEntry updatedValue = HttpTestUtils.makeCacheEntry();
-- final byte[] serialized = HttpTestUtils.getRandomBytes(128);
--
-- final HttpCacheUpdateCallback callback = new HttpCacheUpdateCallback() {
-- @Override
-- public HttpCacheEntry update(final HttpCacheEntry old) {
-- assertNull(old);
-- return updatedValue;
-- }
-- };
--
-- // get empty old entry
-- when(mockKeyHashingScheme.hash(url)).thenReturn(key);
-- when(mockMemcachedClient.gets(key)).thenReturn(null);
-- when(mockMemcachedCacheEntryFactory.getMemcachedCacheEntry(url, updatedValue))
-- .thenReturn(mockMemcachedCacheEntry);
-- when(mockMemcachedCacheEntry.toByteArray()).thenReturn(serialized);
-- when(
-- mockMemcachedClient.set(key, 0,
-- serialized)).thenReturn(null);
--
-- impl.updateEntry(url, callback);
--
-- verify(mockKeyHashingScheme, times(2)).hash(url);
-- verify(mockMemcachedClient).gets(key);
-- verify(mockMemcachedCacheEntryFactory).getMemcachedCacheEntry(url, updatedValue);
-- verify(mockMemcachedCacheEntry).toByteArray();
-- verify(mockMemcachedClient).set(key, 0, serialized);
-- }
--
-- @Test
-- public void testCacheUpdateOverwritesNonMatchingHashCollision() throws IOException,
-- HttpCacheUpdateException {
-- final String url = "foo";
-- final String key = "key";
-- final HttpCacheEntry updatedValue = HttpTestUtils.makeCacheEntry();
-- final byte[] oldBytes = HttpTestUtils.getRandomBytes(128);
-- final CASValue<Object> casValue = new CASValue<Object>(-1, oldBytes);
-- final byte[] newBytes = HttpTestUtils.getRandomBytes(128);
--
-- final HttpCacheUpdateCallback callback = new HttpCacheUpdateCallback() {
-- @Override
-- public HttpCacheEntry update(final HttpCacheEntry old) {
-- assertNull(old);
-- return updatedValue;
-- }
-- };
--
-- // get empty old entry
-- when(mockKeyHashingScheme.hash(url)).thenReturn(key);
-- when(mockMemcachedClient.gets(key)).thenReturn(casValue);
-- when(mockMemcachedCacheEntryFactory.getUnsetCacheEntry())
-- .thenReturn(mockMemcachedCacheEntry);
-- when(mockMemcachedCacheEntry.getStorageKey()).thenReturn("not" + url);
--
-- when(mockMemcachedCacheEntryFactory.getMemcachedCacheEntry(url, updatedValue))
-- .thenReturn(mockMemcachedCacheEntry2);
-- when(mockMemcachedCacheEntry2.toByteArray()).thenReturn(newBytes);
-- when(
-- mockMemcachedClient.set(key, 0,
-- newBytes)).thenReturn(null);
--
-- impl.updateEntry(url, callback);
--
-- verify(mockKeyHashingScheme, times(2)).hash(url);
-- verify(mockMemcachedClient).gets(key);
-- verify(mockMemcachedCacheEntryFactory).getUnsetCacheEntry();
-- verify(mockMemcachedCacheEntry).getStorageKey();
-- verify(mockMemcachedCacheEntryFactory).getMemcachedCacheEntry(url, updatedValue);
-- verify(mockMemcachedCacheEntry2).toByteArray();
-- verify(mockMemcachedClient).set(key, 0, newBytes);
-- }
--
-- @Test
-- public void testCacheUpdateCanUpdateExistingEntry() throws IOException,
-- HttpCacheUpdateException {
-- final String url = "foo";
-- final String key = "key";
-- final HttpCacheEntry existingValue = HttpTestUtils.makeCacheEntry();
-- final HttpCacheEntry updatedValue = HttpTestUtils.makeCacheEntry();
-- final byte[] oldBytes = HttpTestUtils.getRandomBytes(128);
-- final CASValue<Object> casValue = new CASValue<Object>(1, oldBytes);
-- final byte[] newBytes = HttpTestUtils.getRandomBytes(128);
--
--
-- final HttpCacheUpdateCallback callback = new HttpCacheUpdateCallback() {
-- @Override
-- public HttpCacheEntry update(final HttpCacheEntry old) {
-- assertSame(existingValue, old);
-- return updatedValue;
-- }
-- };
--
-- // get empty old entry
-- when(mockKeyHashingScheme.hash(url)).thenReturn(key);
-- when(mockMemcachedClient.gets(key)).thenReturn(casValue);
-- when(mockMemcachedCacheEntryFactory.getUnsetCacheEntry())
-- .thenReturn(mockMemcachedCacheEntry);
-- when(mockMemcachedCacheEntry.getStorageKey()).thenReturn(url);
-- when(mockMemcachedCacheEntry.getHttpCacheEntry()).thenReturn(existingValue);
--
-- when(mockMemcachedCacheEntryFactory.getMemcachedCacheEntry(url, updatedValue))
-- .thenReturn(mockMemcachedCacheEntry2);
-- when(mockMemcachedCacheEntry2.toByteArray()).thenReturn(newBytes);
--
-- when(
-- mockMemcachedClient.cas(key, casValue.getCas(),
-- newBytes)).thenReturn(CASResponse.OK);
--
-- impl.updateEntry(url, callback);
--
-- verify(mockKeyHashingScheme).hash(url);
-- verify(mockMemcachedClient).gets(key);
-- verify(mockMemcachedCacheEntryFactory).getUnsetCacheEntry();
-- verify(mockMemcachedCacheEntry).getStorageKey();
-- verify(mockMemcachedCacheEntry).getHttpCacheEntry();
-- verify(mockMemcachedCacheEntryFactory).getMemcachedCacheEntry(url, updatedValue);
-- verify(mockMemcachedCacheEntry2).toByteArray();
-- verify(mockMemcachedClient).cas(key, casValue.getCas(), newBytes);
-- }
--
-- @Test
-- public void testCacheUpdateThrowsExceptionsIfCASFailsEnoughTimes() throws IOException {
-- final String url = "foo";
-- final String key = "key";
-- final HttpCacheEntry existingValue = HttpTestUtils.makeCacheEntry();
-- final HttpCacheEntry updatedValue = HttpTestUtils.makeCacheEntry();
-- final byte[] oldBytes = HttpTestUtils.getRandomBytes(128);
-- final CASValue<Object> casValue = new CASValue<Object>(1, oldBytes);
-- final byte[] newBytes = HttpTestUtils.getRandomBytes(128);
--
-- final CacheConfig config = CacheConfig.custom().setMaxUpdateRetries(0).build();
-- impl = new MemcachedHttpCacheStorage(mockMemcachedClient, config,
-- mockMemcachedCacheEntryFactory, mockKeyHashingScheme);
--
-- final HttpCacheUpdateCallback callback = new HttpCacheUpdateCallback() {
-- @Override
-- public HttpCacheEntry update(final HttpCacheEntry old) {
-- assertSame(existingValue, old);
-- return updatedValue;
-- }
-- };
--
-- // get empty old entry
-- when(mockKeyHashingScheme.hash(url)).thenReturn(key);
-- when(mockMemcachedClient.gets(key)).thenReturn(casValue);
-- when(mockMemcachedCacheEntryFactory.getUnsetCacheEntry())
-- .thenReturn(mockMemcachedCacheEntry);
-- when(mockMemcachedCacheEntry.getStorageKey()).thenReturn(url);
-- when(mockMemcachedCacheEntry.getHttpCacheEntry()).thenReturn(existingValue);
--
-- when(mockMemcachedCacheEntryFactory.getMemcachedCacheEntry(url, updatedValue))
-- .thenReturn(mockMemcachedCacheEntry2);
-- when(mockMemcachedCacheEntry2.toByteArray()).thenReturn(newBytes);
--
-- when(
-- mockMemcachedClient.cas(key, casValue.getCas(),
-- newBytes)).thenReturn(CASResponse.EXISTS);
--
-- try {
-- impl.updateEntry(url, callback);
-- fail("should have thrown exception");
-- } catch (final HttpCacheUpdateException expected) {
-- }
--
-- verify(mockKeyHashingScheme).hash(url);
-- verify(mockMemcachedClient).gets(key);
-- verify(mockMemcachedCacheEntryFactory).getUnsetCacheEntry();
-- verify(mockMemcachedCacheEntry).getStorageKey();
-- verify(mockMemcachedCacheEntry).getHttpCacheEntry();
-- verify(mockMemcachedCacheEntryFactory).getMemcachedCacheEntry(url, updatedValue);
-- verify(mockMemcachedCacheEntry2).toByteArray();
-- verify(mockMemcachedClient).cas(key, casValue.getCas(), newBytes);
-- }
--
--
-- @Test
-- public void testCacheUpdateCanUpdateExistingEntryWithRetry() throws IOException,
-- HttpCacheUpdateException {
-- final String url = "foo";
-- final String key = "key";
-- final HttpCacheEntry existingValue = HttpTestUtils.makeCacheEntry();
-- final HttpCacheEntry existingValue2 = HttpTestUtils.makeCacheEntry();
-- final HttpCacheEntry updatedValue = HttpTestUtils.makeCacheEntry();
-- final HttpCacheEntry updatedValue2 = HttpTestUtils.makeCacheEntry();
-- final byte[] oldBytes2 = HttpTestUtils.getRandomBytes(128);
-- final CASValue<Object> casValue2 = new CASValue<Object>(2, oldBytes2);
-- final byte[] newBytes2 = HttpTestUtils.getRandomBytes(128);
--
-- final HttpCacheUpdateCallback callback = new HttpCacheUpdateCallback() {
-- @Override
-- public HttpCacheEntry update(final HttpCacheEntry old) {
-- if (old == existingValue) {
-- return updatedValue;
-- }
-- assertSame(existingValue2, old);
-- return updatedValue2;
-- }
-- };
--
-- when(mockKeyHashingScheme.hash(url)).thenReturn(key);
--
-- // take two
-- when(mockMemcachedClient.gets(key)).thenReturn(casValue2);
-- when(mockMemcachedCacheEntryFactory.getUnsetCacheEntry())
-- .thenReturn(mockMemcachedCacheEntry3);
-- when(mockMemcachedCacheEntry3.getStorageKey()).thenReturn(url);
-- when(mockMemcachedCacheEntry3.getHttpCacheEntry()).thenReturn(existingValue2);
--
-- when(mockMemcachedCacheEntryFactory.getMemcachedCacheEntry(url, updatedValue2))
-- .thenReturn(mockMemcachedCacheEntry4);
-- when(mockMemcachedCacheEntry4.toByteArray()).thenReturn(newBytes2);
--
-- when(
-- mockMemcachedClient.cas(key, casValue2.getCas(),
-- newBytes2)).thenReturn(CASResponse.OK);
--
-- impl.updateEntry(url, callback);
--
-- verify(mockKeyHashingScheme).hash(url);
-- verify(mockMemcachedClient).gets(key);
-- verify(mockMemcachedCacheEntryFactory).getUnsetCacheEntry();
--
-- verify(mockMemcachedCacheEntry3).set(oldBytes2);
-- verify(mockMemcachedCacheEntry3).getStorageKey();
-- verify(mockMemcachedCacheEntry3).getHttpCacheEntry();
-- verify(mockMemcachedCacheEntryFactory).getMemcachedCacheEntry(url, updatedValue2);
-- verify(mockMemcachedCacheEntry4).toByteArray();
-- verify(mockMemcachedClient).cas(key, casValue2.getCas(), newBytes2);
--
-- verifyNoMoreInteractions(mockMemcachedClient);
-- verifyNoMoreInteractions(mockKeyHashingScheme);
-- verifyNoMoreInteractions(mockMemcachedCacheEntry);
-- verifyNoMoreInteractions(mockMemcachedCacheEntry2);
-- verifyNoMoreInteractions(mockMemcachedCacheEntry3);
-- verifyNoMoreInteractions(mockMemcachedCacheEntry4);
-- verifyNoMoreInteractions(mockMemcachedCacheEntryFactory);
-- }
--
--
-- @Test
-- public void testUpdateThrowsIOExceptionIfMemcachedTimesOut() throws HttpCacheUpdateException {
-- final String url = "foo";
-- final String key = "key";
-- final HttpCacheEntry updatedValue = HttpTestUtils.makeCacheEntry();
--
-- final HttpCacheUpdateCallback callback = new HttpCacheUpdateCallback() {
-- @Override
-- public HttpCacheEntry update(final HttpCacheEntry old) {
-- assertNull(old);
-- return updatedValue;
-- }
-- };
--
-- // get empty old entry
-- when(mockKeyHashingScheme.hash(url)).thenReturn(key);
-- when(mockMemcachedClient.gets(key))
-- .thenThrow(new OperationTimeoutException(""));
--
-- try {
-- impl.updateEntry(url, callback);
-- fail("should have thrown exception");
-- } catch (final IOException expected) {
-- }
--
-- verify(mockKeyHashingScheme).hash(url);
-- verify(mockMemcachedClient).gets(key);
-- }
--
--
-- @Test(expected=HttpCacheUpdateException.class)
-- public void testThrowsExceptionOnUpdateIfCannotHashStorageKey() throws Exception {
-- final String url = "foo";
--
-- when(mockKeyHashingScheme.hash(url))
-- .thenThrow(new MemcachedKeyHashingException(new Exception()));
--
-- try {
-- impl.updateEntry(url, null);
-- fail("should have thrown exception");
-- } catch (final HttpCacheUpdateException expected) {
-- }
--
-- verify(mockKeyHashingScheme).hash(url);
-- }
--}
=====================================
debian/patches/series
=====================================
@@ -1,4 +1,3 @@
01-generate_osgi_metadata.patch
02-include-suffix-list.patch
03-skip-failing-tests.patch
-04-remove-MemcachedHttpCacheStorage.patch
View it on GitLab: https://salsa.debian.org/java-team/httpcomponents-client/compare/603576e6fd2fafb997929ff5f5ae49169dc2d479...3815be5b56b36876f496e8449b699807fd29b87d
--
View it on GitLab: https://salsa.debian.org/java-team/httpcomponents-client/compare/603576e6fd2fafb997929ff5f5ae49169dc2d479...3815be5b56b36876f496e8449b699807fd29b87d
You're receiving this email because of your account on salsa.debian.org.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://alioth-lists.debian.net/pipermail/pkg-java-commits/attachments/20191112/bd5af953/attachment.html>
More information about the pkg-java-commits
mailing list