Example usage for org.apache.commons.pool ObjectPool invalidateObject

List of usage examples for org.apache.commons.pool ObjectPool invalidateObject

Introduction

In this page you can find the example usage for org.apache.commons.pool ObjectPool invalidateObject.

Prototype

void invalidateObject(Object p0) throws Exception;

Source Link

Usage

From source file:org.openrepose.filters.translation.httpx.HttpxMarshaller.java

private void marshall(Object o, OutputStream out) {
    Marshaller pooledObject = null;
    ObjectPool<Marshaller> marshallerPool = HttpxMarshallerUtility.marshallerPool;
    try {/*  w  ww .ja va 2s. c o  m*/
        try {
            pooledObject = marshallerPool.borrowObject();
            pooledObject.marshal(o, out);
        } catch (Exception ex) {
            marshallerPool.invalidateObject(pooledObject);
            pooledObject = null;
            throw new HttpxException("Error marshalling HTTPX object", ex);
        } finally {
            if (pooledObject != null) {
                marshallerPool.returnObject(pooledObject);
            }
        }
    } catch (Exception e) {
        throw new HttpxException("Error marshalling HTTPX object", e);
    }
}