HttpCacheOperationException to signal that HttpCacheStorage encountered an error performing an caching operation

git-svn-id: https://svn.apache.org/repos/asf/httpcomponents/httpclient/trunk@987818 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Oleg Kalnichevski 2010-08-21 19:49:03 +00:00
parent 2112061b16
commit 218f06e113
2 changed files with 51 additions and 1 deletions

View File

@ -0,0 +1,49 @@
/*
* ====================================================================
* 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.client.cache;
import java.io.IOException;
/**
* Signals that {@link HttpCacheStorage} encountered an error performing an caching operation.
*
* @since 4.1
*/
public class HttpCacheOperationException extends IOException {
private static final long serialVersionUID = 823573584868632876L;
public HttpCacheOperationException(String message) {
super(message);
}
public HttpCacheOperationException(String message, Throwable cause) {
super(message);
initCause(cause);
}
}

View File

@ -35,6 +35,7 @@ import net.sf.ehcache.Element;
import org.apache.http.client.cache.HttpCacheEntry; import org.apache.http.client.cache.HttpCacheEntry;
import org.apache.http.client.cache.HttpCacheEntrySerializer; import org.apache.http.client.cache.HttpCacheEntrySerializer;
import org.apache.http.client.cache.HttpCacheOperationException;
import org.apache.http.client.cache.HttpCacheStorage; import org.apache.http.client.cache.HttpCacheStorage;
import org.apache.http.client.cache.HttpCacheUpdateCallback; import org.apache.http.client.cache.HttpCacheUpdateCallback;
import org.apache.http.impl.client.cache.DefaultHttpCacheEntrySerializer; import org.apache.http.impl.client.cache.DefaultHttpCacheEntrySerializer;
@ -95,7 +96,7 @@ public class EhcacheHttpCacheStorage implements HttpCacheStorage {
serializer.writeTo(updatedEntry, bos); serializer.writeTo(updatedEntry, bos);
Element newElement = new Element(key, bos.toByteArray()); Element newElement = new Element(key, bos.toByteArray());
if (!cache.replace(oldElement, newElement)) { if (!cache.replace(oldElement, newElement)) {
throw new IOException(); throw new HttpCacheOperationException("Replace operation failed");
} }
} }
} }