@SuppressWarnings("unchecked")
    private static <T> T copyAndCloseWebSocketFrame(WebSocketFrame frame) {
        try {
            switch (frame.type()) {
                case CONTINUATION:
                    return (T) WebSocketFrame.ofContinuation(frame.array(), frame.isFinalFragment());
                case TEXT:
                    return (T) WebSocketFrame.ofText(frame.array(), frame.isFinalFragment());
                case BINARY:
                    return (T) WebSocketFrame.ofBinary(frame.array(), frame.isFinalFragment());
                case CLOSE:
                    return (T) WebSocketFrame.ofClose(frame.array());
                case PING:
                    return (T) WebSocketFrame.ofPing(frame.array());
                case PONG:
                    return (T) WebSocketFrame.ofPong(frame.array());
            }
        } finally {
            frame.close();
        }
        // Should never reach here.
        throw new Error();
    }
Creates an unpooled copy of the given {@link HttpData} and closes the given {@link HttpData}.
Returns the given object as is if it's not a pooled {@link HttpData}. This method is useful when
you need to pass your pooled {@link HttpData} instances to the third party who is not capable of
handling pooled {@link HttpData}.

@param obj maybe an {@link HttpData} to copy
core/src/main/java/com/linecorp/armeria/unsafe/PooledObjects.java